diff --git a/nnvm/tests/python/frontend/tensorflow/test_forward.py b/nnvm/tests/python/frontend/tensorflow/test_forward.py index de0ef9e42cd6e..435815463fbd3 100644 --- a/nnvm/tests/python/frontend/tensorflow/test_forward.py +++ b/nnvm/tests/python/frontend/tensorflow/test_forward.py @@ -225,8 +225,12 @@ def _test_convolution(tensor_in_sizes, filter_in_sizes, with tf.Graph().as_default(): in_data = array_ops.placeholder(shape=tensor_in_sizes, dtype='float32') in_filter = constant_op.constant(filter_array, shape=filter_in_sizes, dtype='float32') - strides = [1] + strides + [1] - dilations = [1] + dilations + [1] + if data_format == 'NHWC': + strides = [1] + strides + [1] + dilations = [1] + dilations + [1] + else: + strides = [1, 1] + strides + dilations = [1, 1] + dilations nn_ops.conv2d(in_data, in_filter, @@ -240,7 +244,9 @@ def _test_convolution(tensor_in_sizes, filter_in_sizes, def test_forward_convolution(): if is_gpu_available(): _test_convolution([4, 176, 8, 8], [1, 1, 176, 32], [1, 1], [1, 1], 'SAME', 'NCHW') + _test_convolution([4, 19, 17, 17], [3, 3, 19, 19], [1, 1], [2, 2], 'VALID', 'NCHW') _test_convolution([4, 124, 17, 17], [1, 1, 124, 19], [1, 1], [1, 1], 'SAME', 'NCHW') + _test_convolution([4, 12, 17, 17], [3, 3, 12, 32], [1, 1], [2, 2], 'VALID', 'NCHW') _test_convolution([4, 8, 8, 176], [1, 1, 176, 32], [1, 1], [1, 1], 'SAME', 'NHWC') _test_convolution([4, 17, 17, 19], [3, 3, 19, 19], [1, 1], [2, 2], 'VALID', 'NHWC') diff --git a/python/tvm/relay/frontend/tensorflow.py b/python/tvm/relay/frontend/tensorflow.py index c2166792da7bf..0efebe3cfec90 100644 --- a/python/tvm/relay/frontend/tensorflow.py +++ b/python/tvm/relay/frontend/tensorflow.py @@ -778,7 +778,7 @@ def _transform_mask(stride_dim, ellipsis_mask): pass else: final_output.append(out_shape[gather_index]) - # Prevent 0-dim tensors which are not accepted by nnvm + # Prevent 0-dim tensors which are not accepted by Relay if not final_output: final_output.append(1) return _op.reshape(out, newshape=tuple(final_output)) @@ -1444,7 +1444,7 @@ def from_tensorflow(self, graph, layout="NHWC", shape=None, outputs=None): input_shape = self._output_shapes[node_name][0] inputs.append(in_sym[0]) input_shapes[in_sym[0]] = input_shape - # This means the node is 1d in NNVM and 0d in TF. + # This means the node is 1d in Relay and 0d in TF. # See `_expand_dims_0d_aware`. if self._outputs_are_0d[node_name][tensor_slot] and input_shape: input_0d_mismatch.add(in_sym) diff --git a/tests/python/frontend/tensorflow/test_forward.py b/tests/python/frontend/tensorflow/test_forward.py index 7a003a2655446..10368ea3d9aba 100644 --- a/tests/python/frontend/tensorflow/test_forward.py +++ b/tests/python/frontend/tensorflow/test_forward.py @@ -228,8 +228,12 @@ def _test_convolution(tensor_in_sizes, filter_in_sizes, with tf.Graph().as_default(): in_data = array_ops.placeholder(shape=tensor_in_sizes, dtype='float32') in_filter = constant_op.constant(filter_array, shape=filter_in_sizes, dtype='float32') - strides = [1] + strides + [1] - dilations = [1] + dilations + [1] + if data_format == 'NHWC': + strides = [1] + strides + [1] + dilations = [1] + dilations + [1] + else: + strides = [1, 1] + strides + dilations = [1, 1] + dilations nn_ops.conv2d(in_data, in_filter, @@ -243,7 +247,9 @@ def _test_convolution(tensor_in_sizes, filter_in_sizes, def test_forward_convolution(): if is_gpu_available(): _test_convolution([4, 176, 8, 8], [1, 1, 176, 32], [1, 1], [1, 1], 'SAME', 'NCHW') + _test_convolution([4, 19, 17, 17], [3, 3, 19, 19], [1, 1], [2, 2], 'VALID', 'NCHW') _test_convolution([4, 124, 17, 17], [1, 1, 124, 19], [1, 1], [1, 1], 'SAME', 'NCHW') + _test_convolution([4, 12, 17, 17], [3, 3, 12, 32], [1, 1], [2, 2], 'VALID', 'NCHW') _test_convolution([4, 8, 8, 176], [1, 1, 176, 32], [1, 1], [1, 1], 'SAME', 'NHWC') _test_convolution([4, 17, 17, 19], [3, 3, 19, 19], [1, 1], [2, 2], 'VALID', 'NHWC')