Skip to content

Make tflite consider [] to designate unknown rank #1311

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
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