@@ -1267,8 +1267,8 @@ def mknode(optype, inputs, attrs=None):
1267
1267
# const vals
1268
1268
int_max_const , one_const , minus1_const , blocklen_resize_const , \
1269
1269
blocklenplus1_const , block_shape_const = \
1270
- ctx .make_consts ([[utils .get_max_value (np .int64 )], [1 ], [- 1 ],\
1271
- [- 1 , blocklen ], [blocklen + 1 ], block_shape ])
1270
+ [ n . output [ 0 ] for n in ctx .make_consts ([[utils .get_max_value (np .int64 )], [1 ], [- 1 ],\
1271
+ [- 1 , blocklen ], [blocklen + 1 ], block_shape ])]
1272
1272
1273
1273
x_shape = ctx .insert_new_node_on_input (node , 'Shape' , node .input [0 ])
1274
1274
@@ -1299,18 +1299,18 @@ def mknode(optype, inputs, attrs=None):
1299
1299
p [i ] = p [i - 2 ] + 1
1300
1300
1301
1301
# reshape to create moving blocks, shuffle, and reshape to target_spatial
1302
- indices = ctx .make_consts ([list (g )])[0 ]
1302
+ indices = ctx .make_consts ([list (g )])[0 ]. output [ 0 ]
1303
1303
gather = mknode ('Gather' , [shape1 .output [0 ], indices ])
1304
1304
x2 = mknode ('Reshape' , [input0 , gather .output [0 ]])
1305
1305
tr2 = mknode ('Transpose' , [x2 .output [0 ]], {'perm' : np .array (p )})
1306
1306
shape2 = mknode ('Concat' , [minus1_const , target_spatial .output [0 ], depth .output [0 ]], {'axis' : 0 })
1307
1307
x3 = mknode ('Reshape' , [tr2 .output [0 ], shape2 .output [0 ]])
1308
1308
1309
1309
# crop axes
1310
- slice_starts_const1 , slice_starts_const2 , slice_ends_const1 ,\
1310
+ slice_starts_const1 , slice_starts_const2 , slice_ends_const1 , \
1311
1311
slice_ends_const2 , axes_const = \
1312
- ctx .make_consts ([[0 , 0 ], [1 , utils .get_max_value (np .int64 )], [1 , 0 ],\
1313
- [2 , utils .get_max_value (np .int64 )], range (1 , blocklen + 1 )])
1312
+ [ n . output [ 0 ] for n in ctx .make_consts ([[0 , 0 ], [1 , utils .get_max_value (np .int64 )], [1 , 0 ],\
1313
+ [2 , utils .get_max_value (np .int64 )], range (1 , blocklen + 1 )])]
1314
1314
1315
1315
crop = mknode ('Cast' , [input2 ], {'to' : TensorProto .INT64 })
1316
1316
crop_transposed = mknode ('Transpose' , [crop .output [0 ]])
@@ -1388,8 +1388,9 @@ def mknode(optype, inputs, attrs=None):
1388
1388
# const vals
1389
1389
int_max_const , zero_const , one_const , minus1_const , blocklen_resize_const , \
1390
1390
blocklenplus1_const , filltop_const , fillbottom_const , block_shape_const = \
1391
- ctx .make_consts ([[utils .get_max_value (np .int64 )], [0 ], [1 ], [- 1 ], [- 1 , blocklen ], \
1392
- [blocklen + 1 ], [1 , 0 , 0 , 0 ], [0 , 0 , 1 , 0 ], block_shape ])
1391
+ [n .output [0 ] for n in ctx .make_consts ([[utils .get_max_value (np .int64 )], [0 ], [1 ],\
1392
+ [- 1 ], [- 1 , blocklen ], [blocklen + 1 ],\
1393
+ [1 , 0 , 0 , 0 ], [0 , 0 , 1 , 0 ], block_shape ])]
1393
1394
1394
1395
x_shape = ctx .insert_new_node_on_input (node , 'Shape' , node .input [0 ])
1395
1396
x_rank = mknode ('Size' , [x_shape .output [0 ]])
@@ -1768,8 +1769,8 @@ class MatrixDiagPart:
1768
1769
def version_11 (cls , ctx , node , ** kwargs ):
1769
1770
# MatrixDiagPart by slice and gather
1770
1771
minus_two_one , minus_two , minus_one , zeo , zeo_zeo , one , two , two_one = \
1771
- ctx .make_consts ([[- 2 , - 1 ], [- 2 ], [- 1 ], [0 ], [0 , 0 ], [1 ], [2 ], [2 , 1 ]])
1772
- zeo_ , one_ = ctx .make_consts ([0 , 1 ])
1772
+ [ n . output [ 0 ] for n in ctx .make_consts ([[- 2 , - 1 ], [- 2 ], [- 1 ], [0 ], [0 , 0 ], [1 ], [2 ], [2 , 1 ]])]
1773
+ zeo_ , one_ = [ n . output [ 0 ] for n in ctx .make_consts ([0 , 1 ])]
1773
1774
1774
1775
input_shape = ctx .make_node ('Shape' , [node .input [0 ]])
1775
1776
input_shape_size = ctx .make_node ('Shape' , [input_shape .output [0 ]])
@@ -1807,7 +1808,8 @@ class MatrixDiagPartV2V3:
1807
1808
@classmethod
1808
1809
def version_11 (cls , ctx , node , ** kwargs ):
1809
1810
# assemble MatrixDiagPart V2&V3 by looping k diagonals with proper pads
1810
- minus_two , minus_one , zeo , one , two = ctx .make_consts ([[- 2 ], [- 1 ], [0 ], [1 ], [2 ]])
1811
+ minus_two , minus_one , zeo , one , two = \
1812
+ [n .output [0 ] for n in ctx .make_consts ([[- 2 ], [- 1 ], [0 ], [1 ], [2 ]])]
1811
1813
1812
1814
def normalize ():
1813
1815
raw_k = ctx .make_node ('Cast' , [node .input [1 ]], attr = {'to' : TensorProto .INT64 }).output [0 ]
@@ -2041,10 +2043,11 @@ def version_12(cls, ctx, node, **kwargs):
2041
2043
xalign , yalign = align .split ('_' )
2042
2044
2043
2045
# consts
2044
- const_zero_float , const_neg_one_float = ctx .make_consts ([0 , - 1 ], np .float32 )
2046
+ const_zero_float , const_neg_one_float = [ n . output [ 0 ] for n in ctx .make_consts ([0 , - 1 ], np .float32 )]
2045
2047
const_zero , const_one , const_neg_one , const_neg_two , const_pad_vals , const_t = \
2046
- ctx .make_consts ([[0 ], [1 ], [- 1 ], [- 2 ], pads , [- 1 , 1 ]])
2047
- const_zero_scalar , const_one_scalar , const_neg_one_scalar = ctx .make_consts ([0 , 1 , - 1 ])
2048
+ [n .output [0 ] for n in ctx .make_consts ([[0 ], [1 ], [- 1 ], [- 2 ], pads , [- 1 , 1 ]])]
2049
+ const_zero_scalar , const_one_scalar , const_neg_one_scalar = \
2050
+ [n .output [0 ] for n in ctx .make_consts ([0 , 1 , - 1 ])]
2048
2051
2049
2052
m_shape = ctx .make_node ('Shape' , [node .input [0 ]]).output [0 ]
2050
2053
xlen = ctx .make_node ('Gather' , [m_shape , const_neg_one ]).output [0 ]
@@ -2184,7 +2187,8 @@ def version_12(cls, ctx, node, **kwargs):
2184
2187
# Assemble MatrixDiagV3 by ReverseSequence
2185
2188
argc = len (node .input )
2186
2189
2187
- minus_two , minus_one , zeo , one , two = ctx .make_consts ([[- 2 ], [- 1 ], [0 ], [1 ], [2 ]])
2190
+ minus_two , minus_one , zeo , one , two = \
2191
+ [n .output [0 ] for n in ctx .make_consts ([[- 2 ], [- 1 ], [0 ], [1 ], [2 ]])]
2188
2192
2189
2193
def mknode (op , args , ** kwargs ):
2190
2194
return ctx .make_node (op , args , ** kwargs ).output [0 ]
@@ -2512,7 +2516,8 @@ class MatrixSetDiagV3:
2512
2516
def version_12 (cls , ctx , node , ** kwargs ):
2513
2517
# Assemble MatrixSetDiagV3 by MatrixDiagPartV3 and MatrixDiagV3
2514
2518
2515
- minus_two , minus_one , zeo , one = ctx .make_consts ([[- 2 ], [- 1 ], [0 ], [1 ]])
2519
+ minus_two , minus_one , zeo , one = \
2520
+ [n .output [0 ] for n in ctx .make_consts ([[- 2 ], [- 1 ], [0 ], [1 ]])]
2516
2521
2517
2522
def mknode (op , args , ** kwargs ):
2518
2523
return ctx .make_node (op , args , ** kwargs ).output [0 ]
0 commit comments