diff --git a/tensorflow/core/kernels/pooling_ops_common.cc b/tensorflow/core/kernels/pooling_ops_common.cc index 51d459e45e7..ca2f0ecfe21 100644 --- a/tensorflow/core/kernels/pooling_ops_common.cc +++ b/tensorflow/core/kernels/pooling_ops_common.cc @@ -128,18 +128,6 @@ PoolParameters::PoolParameters(OpKernelContext* context, errors::InvalidArgument( "tensor_in_shape must have 2 spatial dimensions. ", tensor_in_shape.dims(), " ", data_format)); - OP_REQUIRES(context, stride.size() == tensor_in_shape.dims(), - errors::InvalidArgument("Number of strides (", stride.size(), - ") != tensor rank (", - tensor_in_shape.dims(), ")")); - if (tensor_in_shape.num_elements() > 0) { - for (int i = 0; i < stride.size(); i++) { - OP_REQUIRES( - context, stride[i] != 0, - errors::InvalidArgument( - "Pooling stride must be non-zero, got stride[", i, "] == 0")); - } - } this->data_format = data_format; depth = GetTensorDim(tensor_in_shape, data_format, 'C') * diff --git a/tensorflow/python/kernel_tests/pooling_ops_3d_test.py b/tensorflow/python/kernel_tests/pooling_ops_3d_test.py index d50a6b7f54a..051f7e1168a 100644 --- a/tensorflow/python/kernel_tests/pooling_ops_3d_test.py +++ b/tensorflow/python/kernel_tests/pooling_ops_3d_test.py @@ -21,7 +21,6 @@ from __future__ import print_function import numpy as np from tensorflow.python.framework import constant_op -from tensorflow.python.framework import errors_impl from tensorflow.python.framework import test_util from tensorflow.python.ops import gradient_checker from tensorflow.python.ops import gradients_impl @@ -153,14 +152,6 @@ class PoolingTest(test.TestCase): padding="SAME", expected=expected_output) - def testInvalidStrides(self): - for op in (nn_ops.avg_pool3d, nn_ops.max_pool3d): - with self.cached_session(use_gpu=True): - t = constant_op.constant([[[[[1e+40]]]]], dtype=np.float32) - with self.assertRaises((ValueError, errors_impl.InvalidArgumentError, - errors_impl.UnimplementedError)): - self.evaluate(op(t, ksize=1, strides=0, padding="SAME")) - # Test pooling on a larger input, with different stride and kernel # size for the 'z' dimension. diff --git a/tensorflow/python/kernel_tests/pooling_ops_test.py b/tensorflow/python/kernel_tests/pooling_ops_test.py index 0225ce63d96..20699f5de49 100644 --- a/tensorflow/python/kernel_tests/pooling_ops_test.py +++ b/tensorflow/python/kernel_tests/pooling_ops_test.py @@ -70,7 +70,7 @@ def GetTestConfigs(include_nchw_vect_c=False, one_dimensional=False): tf_logging.info("NCHW and NCHW_VECT_C tests skipped because not run with " "--config=cuda or no GPUs available.") return test_configs -# "NCHW" format is currently supported exclusively on CUDA GPUs. + # "NCHW" format is currently supported exclusively on CUDA GPUs. test_configs += [("NCHW", True)] if include_nchw_vect_c: if test.is_gpu_available( @@ -285,6 +285,17 @@ class PoolingTest(test.TestCase): expected=expected_output, use_gpu=use_gpu) + def _testAvgPoolEmpty(self, use_gpu): + expected_output = [7.0, 8.0, 9.0] + self._VerifyValues( + nn_ops.avg_pool, + input_sizes=[1, 3, 3, 0], + ksize=[1, 2, 2, 1], + strides=[1, 2, 2, 1], + padding="VALID", + expected=expected_output, + use_gpu=use_gpu) + def _testAvgPoolSamePadding(self, use_gpu): expected_output = [8.5, 9.5, 10.5, 14.5, 15.5, 16.5] self._VerifyValues( @@ -431,18 +442,6 @@ class PoolingTest(test.TestCase): expected=[], use_gpu=use_gpu) - def testInvalidStrides(self): - strides = [1, 1, 1, 1] - for op in (nn_ops.avg_pool, nn_ops.max_pool): - for zero_dim in range(4): - bad_strides = strides - bad_strides[zero_dim] = 0 - with self.cached_session(use_gpu=True): - t = constant_op.constant(1.0, shape=[3, 3, 3, 3]) - with self.assertRaises((ValueError, errors_impl.UnimplementedError)): - self.evaluate( - op(t, ksize=[2, 2, 2, 2], strides=bad_strides, padding="SAME")) - @test_util.run_deprecated_v1 def testAvgPooling(self): for use_gpu in True, False: