Skip to content

Commit b570374

Browse files
committed
Fix a bug when multiple input are removed
1 parent 1b03b07 commit b570374

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

tf2onnx/onnx_opset/tensor.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,9 +262,12 @@ def version_1(cls, ctx, node, **kwargs):
262262
# if any input is empty, remove the input and concat the others
263263
# NOTE: workaround for https://github.com/Microsoft/onnxruntime/issues/681
264264
node.type = "Concat"
265+
removed_indices = []
265266
for i, inp in enumerate(node.inputs):
266267
if inp.is_const() and inp.get_tensor_value(as_list=False).size == 0:
267-
ctx.remove_input(node, node.input[i], i)
268+
removed_indices.append(i)
269+
for i in reverse(dremoved_indices):
270+
ctx.remove_input(node, node.input[i], i)
268271
# all inputs are deleted
269272
if not node.input:
270273
raise RuntimeError("all inputs of {} are empty".format(node.name))

0 commit comments

Comments
 (0)