Skip to content

Commit 395c657

Browse files
committed
remove useless codes
1 parent a665274 commit 395c657

File tree

1 file changed

+0
-5
lines changed

1 file changed

+0
-5
lines changed

tf2onnx/tfonnx.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1060,7 +1060,6 @@ def upsample_op9(ctx, node, name, args):
10601060
# first create "scales" info for onnx upsample
10611061
# if shape of input and output known then "scale" is calculated statically and set as a const node
10621062
shape = ctx.get_shape(node.input[0])
1063-
added_nodes = []
10641063
if shape and shape[2] != -1 and shape[1] != -1 and node.inputs[1].is_const():
10651064
target_shape = node.inputs[1].get_tensor_value()
10661065
n, h, w, c = shape
@@ -1069,7 +1068,6 @@ def upsample_op9(ctx, node, name, args):
10691068
# the reason not storing data at raw field is because of the bug: https://github.com/onnx/onnx/issues/1852
10701069
scale_val = np.array([1.0, 1.0, float(nh) / h, float(nw) / w]).astype(np.float32)
10711070
scales = ctx.make_const(utils.make_name("scales"), scale_val, raw=False)
1072-
added_nodes.append(scales)
10731071
else:
10741072
ori_shape = ctx.make_node("Shape", [node.input[0]])
10751073
ori_shape_hw = ctx.make_node("Slice", ori_shape.output, {"axes": [0], "starts": [1], "ends": [3]})
@@ -1083,9 +1081,6 @@ def upsample_op9(ctx, node, name, args):
10831081
const_one_array = ctx.make_const(utils.make_name("one"), np.array([1.0, 1.0]).astype(np.float32))
10841082
# scales is nchw
10851083
scales = ctx.make_node("Concat", [const_one_array.output[0], scales_hw.output[0]], {"axis": 0})
1086-
added_nodes.extend([ori_shape, ori_shape_hw, ori_shape_hw_float, target_hw_float,
1087-
scales_hw, const_one_array, scales])
1088-
10891084
# because onnxruntime only supports to scale the last two dims so transpose is inserted
10901085
input_nchw = ctx.make_node("Transpose", [node.input[0]], {"perm": [0, 3, 1, 2]})
10911086
upsample = ctx.make_node("Upsample", [input_nchw.output[0], scales.output[0]], attr={"mode": args[0]})

0 commit comments

Comments
 (0)