@@ -1060,7 +1060,6 @@ def upsample_op9(ctx, node, name, args):
1060
1060
# first create "scales" info for onnx upsample
1061
1061
# if shape of input and output known then "scale" is calculated statically and set as a const node
1062
1062
shape = ctx .get_shape (node .input [0 ])
1063
- added_nodes = []
1064
1063
if shape and shape [2 ] != - 1 and shape [1 ] != - 1 and node .inputs [1 ].is_const ():
1065
1064
target_shape = node .inputs [1 ].get_tensor_value ()
1066
1065
n , h , w , c = shape
@@ -1069,7 +1068,6 @@ def upsample_op9(ctx, node, name, args):
1069
1068
# the reason not storing data at raw field is because of the bug: https://github.com/onnx/onnx/issues/1852
1070
1069
scale_val = np .array ([1.0 , 1.0 , float (nh ) / h , float (nw ) / w ]).astype (np .float32 )
1071
1070
scales = ctx .make_const (utils .make_name ("scales" ), scale_val , raw = False )
1072
- added_nodes .append (scales )
1073
1071
else :
1074
1072
ori_shape = ctx .make_node ("Shape" , [node .input [0 ]])
1075
1073
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):
1083
1081
const_one_array = ctx .make_const (utils .make_name ("one" ), np .array ([1.0 , 1.0 ]).astype (np .float32 ))
1084
1082
# scales is nchw
1085
1083
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
-
1089
1084
# because onnxruntime only supports to scale the last two dims so transpose is inserted
1090
1085
input_nchw = ctx .make_node ("Transpose" , [node .input [0 ]], {"perm" : [0 , 3 , 1 , 2 ]})
1091
1086
upsample = ctx .make_node ("Upsample" , [input_nchw .output [0 ], scales .output [0 ]], attr = {"mode" : args [0 ]})
0 commit comments