|
54 | 54 |
|
55 | 55 | if is_tf2():
|
56 | 56 | conv2d_backprop_input = tf.compat.v1.nn.conv2d_backprop_input
|
| 57 | + conv3d_transpose = tf.compat.v1.nn.conv3d_transpose |
57 | 58 | multinomial = tf.compat.v1.random.multinomial
|
58 | 59 | space_to_batch_nd = tf.compat.v1.space_to_batch_nd
|
59 | 60 | batch_to_space_nd = tf.compat.v1.batch_to_space_nd
|
|
73 | 74 | fake_quant_with_min_max_args = tf.quantization.fake_quant_with_min_max_args
|
74 | 75 | elif LooseVersion(tf.__version__) >= "1.13":
|
75 | 76 | conv2d_backprop_input = tf.compat.v1.nn.conv2d_backprop_input
|
| 77 | + conv3d_transpose = tf.compat.v1.nn.conv3d_transpose |
76 | 78 | multinomial = tf.compat.v1.random.multinomial
|
77 | 79 | space_to_batch_nd = tf.compat.v1.space_to_batch_nd
|
78 | 80 | batch_to_space_nd = tf.compat.v1.batch_to_space_nd
|
|
93 | 95 | fake_quant_with_min_max_args = tf.compat.v1.quantization.fake_quant_with_min_max_args
|
94 | 96 | else:
|
95 | 97 | conv2d_backprop_input = tf.nn.conv2d_backprop_input
|
| 98 | + conv3d_transpose = tf.nn.conv3d_transpose |
96 | 99 | multinomial = tf.multinomial
|
97 | 100 | space_to_batch_nd = tf.space_to_batch_nd
|
98 | 101 | batch_to_space_nd = tf.batch_to_space_nd
|
@@ -3136,45 +3139,38 @@ def func(x):
|
3136 | 3139 | @check_opset_min_version(10, "Conv2DBackpropInput")
|
3137 | 3140 | def test_Conv2DBackpropInput_const(self):
|
3138 | 3141 | input_sizes_val_ = np.array([1, 10, 10, 3], dtype=np.int32)
|
3139 |
| - filter_val_ = np.random.randint(low=0, high=256, size=[3, 3, 3, 5]) |
3140 |
| - out_backprop_val_ = np.random.randint(low=0, high=256, size=[1, 10, 10, 5]) |
3141 |
| - def func(): |
| 3142 | + def func(filter_val, out_backprop_val): |
3142 | 3143 | input_sizes_val = tf.constant(input_sizes_val_, dtype=tf.int32)
|
3143 |
| - filter_val = tf.constant(filter_val_, dtype=tf.float32) |
3144 |
| - out_backprop_val = tf.constant(out_backprop_val_, dtype=tf.float32) |
3145 | 3144 | return conv2d_backprop_input(input_sizes=input_sizes_val, filter=filter_val,
|
3146 | 3145 | out_backprop=out_backprop_val, strides=[1, 1, 1, 1],
|
3147 | 3146 | padding='SAME', name=_TFOUTPUT)
|
3148 |
| - self._run_test_case(func, [_OUTPUT], {}) |
| 3147 | + filters_val = np.random.randint(low=0, high=256, size=[3, 3, 3, 5]).astype(np.float32) |
| 3148 | + out_backprop_val = np.random.randint(low=0, high=256, size=[1, 10, 10, 5]).astype(np.float32) |
| 3149 | + self._run_test_case(func, [_OUTPUT], {_INPUT: filters_val, _INPUT1: out_backprop_val}) |
3149 | 3150 |
|
3150 | 3151 | @check_opset_min_version(10, "Conv2DBackpropInput")
|
3151 | 3152 | def test_Conv2DBackpropInput_const_strided(self):
|
3152 | 3153 | input_sizes_val_ = np.array([1, 10, 10, 3], dtype=np.int32)
|
3153 |
| - filter_val_ = np.random.randint(low=0, high=256, size=[3, 3, 3, 5]) |
3154 |
| - out_backprop_val_ = np.random.randint(low=0, high=256, size=[1, 5, 5, 5]) |
3155 |
| - |
3156 |
| - def func(): |
| 3154 | + def func(filter_val, out_backprop_val): |
3157 | 3155 | input_sizes_val = tf.constant(input_sizes_val_, dtype=tf.int32)
|
3158 |
| - filter_val = tf.constant(filter_val_, dtype=tf.float32) |
3159 |
| - out_backprop_val = tf.constant(out_backprop_val_, dtype=tf.float32) |
3160 | 3156 | return conv2d_backprop_input(input_sizes=input_sizes_val, filter=filter_val,
|
3161 | 3157 | out_backprop=out_backprop_val, strides=[1, 2, 2, 1],
|
3162 | 3158 | padding='SAME', name=_TFOUTPUT)
|
3163 |
| - self._run_test_case(func, [_OUTPUT], {}) |
| 3159 | + filters_val = np.random.randint(low=0, high=256, size=[3, 3, 3, 5]).astype(np.float32) |
| 3160 | + out_backprop_val = np.random.randint(low=0, high=256, size=[1, 5, 5, 5]).astype(np.float32) |
| 3161 | + self._run_test_case(func, [_OUTPUT], {_INPUT: filters_val, _INPUT1: out_backprop_val}) |
3164 | 3162 |
|
3165 | 3163 | @check_opset_min_version(10, "Conv2DBackpropInput")
|
3166 | 3164 | def test_Conv2DBackpropInput_const_valid(self):
|
3167 | 3165 | input_sizes_val_ = np.array([1, 12, 12, 3], dtype=np.int32)
|
3168 |
| - filter_val_ = np.random.randint(low=0, high=256, size=[3, 3, 3, 5]) |
3169 |
| - out_backprop_val_ = np.random.randint(low=0, high=256, size=[1, 10, 10, 5]) |
3170 |
| - def func(): |
| 3166 | + def func(filter_val, out_backprop_val): |
3171 | 3167 | input_sizes_val = tf.constant(input_sizes_val_, dtype=tf.int32)
|
3172 |
| - filter_val = tf.constant(filter_val_, dtype=tf.float32) |
3173 |
| - out_backprop_val = tf.constant(out_backprop_val_, dtype=tf.float32) |
3174 | 3168 | return conv2d_backprop_input(input_sizes=input_sizes_val, filter=filter_val,
|
3175 | 3169 | out_backprop=out_backprop_val, strides=[1, 1, 1, 1],
|
3176 | 3170 | padding='VALID', name=_TFOUTPUT)
|
3177 |
| - self._run_test_case(func, [_OUTPUT], {}) |
| 3171 | + filters_val = np.random.randint(low=0, high=256, size=[3, 3, 3, 5]).astype(np.float32) |
| 3172 | + out_backprop_val = np.random.randint(low=0, high=256, size=[1, 10, 10, 5]).astype(np.float32) |
| 3173 | + self._run_test_case(func, [_OUTPUT], {_INPUT: filters_val, _INPUT1: out_backprop_val}) |
3178 | 3174 |
|
3179 | 3175 | @check_opset_min_version(10, "Conv2DBackpropInput")
|
3180 | 3176 | def test_Conv2DBackpropInput(self):
|
@@ -3206,6 +3202,72 @@ def func(input_sizes, filters, out_backprop):
|
3206 | 3202 | out_backprop_val = np.random.randint(low=0, high=256, size=[1, 10, 10, 5]).astype(np.float32)
|
3207 | 3203 | self._run_test_case(func, [_OUTPUT], {_INPUT: input_sizes_val, _INPUT1: filters_val, _INPUT2: out_backprop_val})
|
3208 | 3204 |
|
| 3205 | + @check_opset_min_version(10, "Conv3DBackpropInputV2") |
| 3206 | + def test_Conv3DBackpropInputV2_const(self): |
| 3207 | + output_shape_val_ = np.array([1, 10, 10, 10, 3], dtype=np.int32) |
| 3208 | + def func(value, filters): |
| 3209 | + output_shape_val = tf.constant(output_shape_val_, dtype=tf.int32) |
| 3210 | + return conv3d_transpose(value, filters, output_shape_val, strides=[1, 1, 1, 1, 1], |
| 3211 | + padding='SAME', data_format="NDHWC", name=_TFOUTPUT) |
| 3212 | + filters_val = np.random.randint(low=0, high=256, size=[3, 3, 3, 3, 5]).astype(np.float32) |
| 3213 | + value_val = np.random.randint(low=0, high=256, size=[1, 10, 10, 10, 5]).astype(np.float32) |
| 3214 | + self._run_test_case(func, [_OUTPUT], {_INPUT: value_val, _INPUT1: filters_val}, rtol=1e-6) |
| 3215 | + |
| 3216 | + @check_opset_min_version(10, "Conv3DBackpropInputV2") |
| 3217 | + def test_Conv3DBackpropInputV2_const_strided(self): |
| 3218 | + output_shape_val_ = np.array([1, 10, 10, 10, 3], dtype=np.int32) |
| 3219 | + def func(value, filters): |
| 3220 | + output_shape_val = tf.constant(output_shape_val_, dtype=tf.int32) |
| 3221 | + return conv3d_transpose(value, filters, output_shape_val, strides=[1, 2, 2, 2, 1], |
| 3222 | + padding='SAME', data_format="NDHWC", name=_TFOUTPUT) |
| 3223 | + filters_val = np.random.randint(low=0, high=256, size=[3, 3, 3, 3, 5]).astype(np.float32) |
| 3224 | + value_val = np.random.randint(low=0, high=256, size=[1, 5, 5, 5, 5]).astype(np.float32) |
| 3225 | + self._run_test_case(func, [_OUTPUT], {_INPUT: value_val, _INPUT1: filters_val}, rtol=1e-6) |
| 3226 | + |
| 3227 | + @check_opset_min_version(10, "Conv3DBackpropInputV2") |
| 3228 | + def test_Conv3DBackpropInputV2_const_valid(self): |
| 3229 | + output_shape_val_ = np.array([1, 12, 12, 12, 3], dtype=np.int32) |
| 3230 | + def func(value, filters): |
| 3231 | + output_shape_val = tf.constant(output_shape_val_, dtype=tf.int32) |
| 3232 | + return conv3d_transpose(value, filters, output_shape_val, strides=[1, 1, 1, 1, 1], |
| 3233 | + padding='VALID', data_format="NDHWC", name=_TFOUTPUT) |
| 3234 | + filters_val = np.random.randint(low=0, high=256, size=[3, 3, 3, 3, 5]).astype(np.float32) |
| 3235 | + value_val = np.random.randint(low=0, high=256, size=[1, 10, 10, 10, 5]).astype(np.float32) |
| 3236 | + self._run_test_case(func, [_OUTPUT], {_INPUT: value_val, _INPUT1: filters_val}, rtol=1e-6) |
| 3237 | + |
| 3238 | + @check_opset_min_version(10, "Conv3DBackpropInputV2") |
| 3239 | + def test_Conv3DBackpropInputV2(self): |
| 3240 | + def func(value, filters, output_shape): |
| 3241 | + return conv3d_transpose(value, filters, output_shape, strides=[1, 1, 1, 1, 1], |
| 3242 | + padding='SAME', data_format="NDHWC", name=_TFOUTPUT) |
| 3243 | + filters_val = np.random.randint(low=0, high=256, size=[2, 3, 4, 4, 5]).astype(np.float32) |
| 3244 | + value_val = np.random.randint(low=0, high=256, size=[2, 7, 8, 9, 5]).astype(np.float32) |
| 3245 | + output_shape_val = np.array([2, 7, 8, 9, 4], dtype=np.int32) |
| 3246 | + self._run_test_case(func, [_OUTPUT], {_INPUT: value_val, _INPUT1: filters_val, _INPUT2: output_shape_val}, |
| 3247 | + rtol=1e-6) |
| 3248 | + |
| 3249 | + @check_opset_min_version(10, "Conv3DBackpropInputV2") |
| 3250 | + def test_Conv3DBackpropInputV2_strided(self): |
| 3251 | + def func(value, filters, output_shape): |
| 3252 | + return conv3d_transpose(value, filters, output_shape, strides=[1, 2, 2, 2, 1], |
| 3253 | + padding='SAME', data_format="NDHWC", name=_TFOUTPUT) |
| 3254 | + filters_val = np.random.randint(low=0, high=256, size=[3, 3, 3, 3, 5]).astype(np.float32) |
| 3255 | + value_val = np.random.randint(low=0, high=256, size=[1, 5, 5, 5, 5]).astype(np.float32) |
| 3256 | + output_shape_val = np.array([1, 10, 10, 10, 3], dtype=np.int32) |
| 3257 | + self._run_test_case(func, [_OUTPUT], {_INPUT: value_val, _INPUT1: filters_val, _INPUT2: output_shape_val}, |
| 3258 | + rtol=1e-6) |
| 3259 | + |
| 3260 | + @check_opset_min_version(10, "Conv3DBackpropInputV2") |
| 3261 | + def test_Conv3DBackpropInputV2_valid(self): |
| 3262 | + def func(value, filters, output_shape): |
| 3263 | + return conv3d_transpose(value, filters, output_shape, strides=[1, 1, 1, 1, 1], |
| 3264 | + padding='VALID', data_format="NDHWC", name=_TFOUTPUT) |
| 3265 | + filters_val = np.random.randint(low=0, high=256, size=[3, 3, 3, 3, 5]).astype(np.float32) |
| 3266 | + value_val = np.random.randint(low=0, high=256, size=[1, 10, 10, 10, 5]).astype(np.float32) |
| 3267 | + output_shape_val = np.array([1, 12, 12, 12, 3], dtype=np.int32) |
| 3268 | + self._run_test_case(func, [_OUTPUT], {_INPUT: value_val, _INPUT1: filters_val, _INPUT2: output_shape_val}, |
| 3269 | + rtol=1e-6) |
| 3270 | + |
3209 | 3271 | @check_opset_min_version(8, "CategoryMapper")
|
3210 | 3272 | @skip_tf2()
|
3211 | 3273 | def test_hashtable_lookup(self):
|
|
0 commit comments