Skip to content

Commit db14785

Browse files
committed
bug fix
when perm is dynamic, we can't assume it's a reversed transpose.
1 parent d03b003 commit db14785

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

tf2onnx/onnx_opset/tensor.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -175,12 +175,10 @@ def version_4(cls, ctx, node, **kwargs):
175175
if perm.is_const():
176176
# perms is passed as const
177177
dims = perm.get_tensor_value()
178+
ctx.remove_input(node, node.input[1])
179+
node.set_attr("perm", dims)
178180
else:
179-
# calculate perms from shape
180-
shape = ctx.get_shape(node.input[1])
181-
dims = [i for i in range(len(shape) - 1, -1)]
182-
ctx.remove_input(node, node.input[1])
183-
node.set_attr("perm", dims)
181+
utils.make_sure(False, "perm can't be dynamic in ONNX")
184182
else:
185183
# graph rewrite moved perm to attribute
186184
pass

0 commit comments

Comments
 (0)