Skip to content

Commit d462c46

Browse files
committed
shape is not always needed at squeeze_op
1 parent 81c872b commit d462c46

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

tf2onnx/tfonnx.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,15 +268,16 @@ def squeeze_op(ctx, node, name, args):
268268
else:
269269
del node.attr["axis"]
270270

271-
shape = ctx.get_shape(node.input[0])
272271
if axis and axis.ints:
273272
axis = axis.ints
274273
neg_axis = any([val < 0 for val in axis])
275274
if neg_axis:
275+
shape = ctx.get_shape(node.input[0])
276276
utils.make_sure(shape is not None, "squeeze input shape cannot be None")
277277
shape_len = len(shape)
278278
axis = [a + shape_len if a < 0 else a for a in axis]
279279
else:
280+
shape = ctx.get_shape(node.input[0])
280281
utils.make_sure(shape is not None, "squeeze input shape cannot be None")
281282
axis = [i for i, j in enumerate(shape) if j == 1]
282283
node.set_attr("axes", axis)

tf2onnx/utils.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,6 @@ def get_onnx_version():
428428
return onnx.__version__
429429

430430

431-
432431
def make_opsetid(domain, version):
433432
make_sure(isinstance(version, int), "version must be an integer")
434433
return helper.make_opsetid(domain, version)
@@ -438,4 +437,3 @@ def is_onnx_domain(domain):
438437
if domain is None or domain == "":
439438
return True
440439
return False
441-

0 commit comments

Comments
 (0)