@@ -403,7 +403,7 @@ def func(x):
403
403
return tf .identity (conv , name = _TFOUTPUT )
404
404
self ._run_test_case (func , [_OUTPUT ], {_INPUT : x_val }, rtol = 1e-5 )
405
405
406
- def test_conv2d_with_pad (self ):
406
+ def test_conv2d_with_pad_valid (self ):
407
407
x_val = make_xval ((1 , 1 , 5 , 5 )).transpose (NCHW_TO_NHWC )
408
408
w = np .random .random_sample ([3 , 3 , 1 , 2 ]).astype (np .float32 )
409
409
strides = [1 , 1 , 1 , 1 ]
@@ -414,6 +414,17 @@ def func(x):
414
414
return tf .identity (conv , name = _TFOUTPUT )
415
415
self ._run_test_case (func , [_OUTPUT ], {_INPUT : x_val }, rtol = 1e-5 )
416
416
417
+ def test_conv2d_with_pad_same (self ):
418
+ x_val = make_xval ((1 , 1 , 5 , 5 )).transpose (NCHW_TO_NHWC )
419
+ w = np .random .random_sample ([3 , 3 , 1 , 2 ]).astype (np .float32 )
420
+ strides = [1 , 1 , 1 , 1 ]
421
+ def func (x ):
422
+ kernel = tf .constant (w , dtype = tf .float32 , name = 'k' )
423
+ x_pad = tf .pad (x , paddings = [[0 , 0 ], [2 , 2 ], [2 , 2 ], [0 , 0 ]])
424
+ conv = tf .nn .conv2d (x_pad , kernel , strides = strides , padding = "SAME" )
425
+ return tf .identity (conv , name = _TFOUTPUT )
426
+ self ._run_test_case (func , [_OUTPUT ], {_INPUT : x_val }, rtol = 1e-5 )
427
+
417
428
def test_conv2d_transpose (self ):
418
429
x_shape = [2 , 6 , 4 , 3 ]
419
430
output_shape = [2 , 13 , 9 , 2 ]
0 commit comments