@@ -108,24 +108,17 @@ def _run_test_case(self, output_names_with_port, feed_dict, **kwargs):
108
108
kwargs ["constant_fold" ] = False
109
109
return self .run_test_case (feed_dict , [], output_names_with_port , ** kwargs )
110
110
111
- def _test_expand_dims (self , idx ):
111
+ def _test_expand_dims_known_rank (self , idx ):
112
112
tf .reset_default_graph ()
113
113
x_val = make_xval ([3 , 4 ])
114
114
x = tf .placeholder (tf .float32 , shape = x_val .shape , name = _TFINPUT )
115
115
op = tf .expand_dims (x , idx )
116
116
_ = tf .identity (op , name = _TFOUTPUT )
117
117
self ._run_test_case ([_OUTPUT ], {_INPUT : x_val })
118
118
119
- def test_expand_dims (self ):
119
+ def test_expand_dims_known_rank (self ):
120
120
for i in [- 1 , 0 , 1 , - 2 ]:
121
- self ._test_expand_dims (i )
122
-
123
- def test_expand_dims_dynamic_inputs (self ):
124
- x_val = make_xval ([3 , 4 ])
125
- x = tf .placeholder (tf .float32 , shape = [None , None ], name = _TFINPUT )
126
- op = tf .expand_dims (x , 0 )
127
- _ = tf .identity (op , name = _TFOUTPUT )
128
- self ._run_test_case ([_OUTPUT ], {_INPUT : x_val })
121
+ self ._test_expand_dims_known_rank (i )
129
122
130
123
def test_expand_dims_one_unknown_rank (self ):
131
124
tf .reset_default_graph ()
@@ -135,14 +128,18 @@ def test_expand_dims_one_unknown_rank(self):
135
128
_ = tf .identity (op , name = _TFOUTPUT )
136
129
self ._run_test_case ([_OUTPUT ], {_INPUT : x_val })
137
130
138
- def test_expand_dims_more_unknown_rank (self ):
131
+ def _test_expand_dims_more_unknown_rank (self , idx ):
139
132
tf .reset_default_graph ()
140
133
x_val = make_xval ([3 , 4 ])
141
134
x = tf .placeholder (tf .float32 , shape = [None , None ], name = _TFINPUT )
142
- op = tf .expand_dims (x , 0 )
135
+ op = tf .expand_dims (x , idx )
143
136
_ = tf .identity (op , name = _TFOUTPUT )
144
137
self ._run_test_case ([_OUTPUT ], {_INPUT : x_val })
145
138
139
+ def test_expand_dims_more_unknown_rank (self ):
140
+ for i in [- 1 , 0 , 1 , - 2 ]:
141
+ self ._test_expand_dims_more_unknown_rank (i )
142
+
146
143
@check_opset_min_version (9 , "ConstantOfShape" )
147
144
def test_eye_non_const1 (self ):
148
145
# tf.eye(num_rows), num_rows is not const here
@@ -1073,6 +1070,15 @@ def test_slice(self):
1073
1070
_ = tf .identity (x_ , name = _TFOUTPUT )
1074
1071
self ._run_test_case ([_OUTPUT ], {_INPUT : x_val })
1075
1072
1073
+ def test_slice_neg_size (self ):
1074
+ x_val = np .array ([[1 , 2 , 3 , 4 ], [5 , 6 , 7 , 8 ]], dtype = np .float32 )
1075
+ t1 = tf .constant ([0 , 1 ], dtype = tf .int32 )
1076
+ t2 = tf .constant ([- 1 , 2 ], dtype = tf .int32 )
1077
+ x0 = tf .placeholder (tf .float32 , x_val .shape , name = _TFINPUT )
1078
+ x_ = tf .slice (x0 , t1 , t2 )
1079
+ _ = tf .identity (x_ , name = _TFOUTPUT )
1080
+ self ._run_test_case ([_OUTPUT ], {_INPUT : x_val })
1081
+
1076
1082
@check_opset_min_version (10 , "Slice in opset 10 can accept dymaic 'start' and 'ends'" )
1077
1083
def test_slice_with_non_const (self ):
1078
1084
x_val = np .array ([[1 , 2 , 3 , 4 ], [5 , 6 , 7 , 8 ]], dtype = np .float32 )
@@ -2253,7 +2259,6 @@ def test_sparse_softmax_cross_entropy_with_logits_large_class(self):
2253
2259
2254
2260
self ._run_test_case ([_OUTPUT ], {_INPUT : label_val , _INPUT1 : logits_val }, rtol = 1e-6 )
2255
2261
2256
- @skip_onnxruntime_backend ("onnxruntime Slice did not supported BOOL" )
2257
2262
def test_matrix_band_part (self ):
2258
2263
input_val = np .random .randint (0 , 666 , (10 , 15 )).astype (np .int32 )
2259
2264
input_x = tf .placeholder (dtype = tf .int32 , shape = [None , None ], name = _TFINPUT )
@@ -2263,7 +2268,6 @@ def test_matrix_band_part(self):
2263
2268
_ = tf .identity (res1 , name = _TFOUTPUT1 )
2264
2269
self ._run_test_case ([_OUTPUT , _OUTPUT1 ], {_INPUT : input_val })
2265
2270
2266
- @skip_onnxruntime_backend ("onnxruntime Slice did not supported BOOL." )
2267
2271
def test_matrix_band_part_2 (self ):
2268
2272
input_val = np .random .randint (0 , 666 , (1 , 1 )).astype (np .int32 )
2269
2273
input_x = tf .placeholder (dtype = tf .int32 , shape = [None , None ], name = _TFINPUT )
@@ -2432,7 +2436,7 @@ def test_softsign(self):
2432
2436
2433
2437
def test_batch_to_spacend (self ):
2434
2438
block_size = [2 , 2 ]
2435
- crop = [[0 , 1 ], [2 , 1 ]]
2439
+ crop = [[1 , 0 ], [2 , 1 ]]
2436
2440
2437
2441
input_val = np .random .random_sample ([40 , 3 , 5 , 100 ]).astype (np .float32 )
2438
2442
input_x = tf .placeholder (dtype = tf .float32 , shape = input_val .shape , name = _TFINPUT ) # NHWC
0 commit comments