Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions tf2onnx/tflite_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,13 +171,14 @@ def parse_tflite_graph(tflite_g, opcodes_map, model, input_prefix=''):
tensor_names[i] = name
name_to_tensor[name] = tensor

if tensor.ShapeIsNone():
output_shapes[name] = None
elif tensor.ShapeSignatureIsNone():
if not tensor.ShapeSignatureIsNone():
output_shapes[name] = tensor.ShapeSignatureAsNumpy().tolist()
elif not tensor.ShapeIsNone() and len(tensor.ShapeAsNumpy().tolist()) > 0:
# The shape signature uses -1 to signify unknown dims. Old models don't have this and use Shape instead.
# Annoyingly, an empty shape can actually mean the rank is unknown.
output_shapes[name] = tensor.ShapeAsNumpy().tolist()
else:
output_shapes[name] = tensor.ShapeSignatureAsNumpy().tolist()
output_shapes[name] = None
buf = model.Buffers(tensor.Buffer())
dtypes[name] = map_tflite_dtype_to_onnx(tensor.Type())
if not buf.DataIsNone() and tensor.Buffer() > 0:
Expand Down