fix: onnx resize op input is none bug

This commit is contained in:
zhangyunze 2024-04-30 10:53:40 +08:00 committed by OdinaryWord
parent 907239cf34
commit 377b3bf391
1 changed files with 19 additions and 7 deletions

View File

@ -85,7 +85,7 @@ class OnnxStub:
while len(sorted_nodes) < len(model.graph.node): while len(sorted_nodes) < len(model.graph.node):
updated = False updated = False
for i, node in enumerate(model.graph.node): for i, node in enumerate(model.graph.node):
if all(t in known_edge for t in node.input): if all(t in known_edge or t == "" for t in node.input):
node.name = str(len(sorted_nodes)) + "_" + node.name node.name = str(len(sorted_nodes)) + "_" + node.name
sorted_nodes.append(i) sorted_nodes.append(i)
known_edge.update(node.output) known_edge.update(node.output)
@ -653,15 +653,15 @@ class OnnxStub:
"nearest_mode", "nearest_mode",
] ]
) )
if len(node.input) > 1: if len(node.input) > 1 and node.input[1] in data:
roiVal = _parse_data(data[node.input[1]]) roiVal = _parse_data(data[node.input[1]])
else: else:
roiVal = [] roiVal = []
if len(node.input) > 2: if len(node.input) > 2 and node.input[2] in data:
scalesVal = _parse_data(data[node.input[2]]) scalesVal = _parse_data(data[node.input[2]])
else: else:
scalesVal = [] scalesVal = []
if len(node.input) > 3: if len(node.input) > 3 and node.input[3] in data:
sizesVal = _parse_data(data[node.input[3]]) sizesVal = _parse_data(data[node.input[3]])
else: else:
sizesVal = [] sizesVal = []
@ -669,9 +669,21 @@ class OnnxStub:
tensors[node.input[0]], tensors[node.input[0]],
output, output,
axes, axes,
tensors[node.input[3]] if len(node.input) > 3 else None, (
tensors[node.input[2]] if len(node.input) > 2 else None, tensors[node.input[3]]
tensors[node.input[1]] if len(node.input) > 1 else None, if len(node.input) > 3 and node.input[3] != ""
else None
),
(
tensors[node.input[2]]
if len(node.input) > 2 and node.input[2] != ""
else None
),
(
tensors[node.input[1]]
if len(node.input) > 1 and node.input[1] != ""
else None
),
sizesVal, sizesVal,
scalesVal, scalesVal,
roiVal, roiVal,