Skip to content

Commit 87fc6eb

Browse files
committed
Fix None shape error when one input to ConcatV2 has a shape.
I tried to convert a network where one of the inputs to a concatenation along dimension -1 had shape None. The other input did however have a shape. The conversion failed because the code only looked att the shape of the first input to determine what positive axis value to use in the concatenation. If the order of the inputs had been reversed, the conversion would have worked. I have now changed the code to look at the shapes of both input nodes. With the new code, I can convert the network. I have also verified that the resulting onnx-file works.
1 parent 82ae7c4 commit 87fc6eb

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

tf2onnx/onnx_opset/tensor.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,8 +297,13 @@ def version_1(cls, ctx, node, **kwargs):
297297
ctx.remove_input(node, node.input[-1], len(node.input) - 1)
298298

299299
if axis_val < 0: # onnxruntime does not support -1 axis, but TF supports.
300-
input_shape = ctx.get_shape(node.input[0])
301-
utils.make_sure(input_shape is not None, "shape of {} is None".format(node.input[0]))
300+
input_shape = None
301+
for node_input in node.input:
302+
input_shape = ctx.get_shape(node_input)
303+
if input_shape is not None:
304+
break
305+
utils.make_sure(input_shape is not None,
306+
"the shapes of the following inputs are None: {}".format(', '.join(node.input)))
302307
axis_val = len(input_shape) + axis_val
303308
node.set_attr("axis", axis_val)
304309

0 commit comments

Comments
 (0)