From d535cfc63de03932580db2f462eaf0b79661f7bc Mon Sep 17 00:00:00 2001 From: Gaurav Jain Date: Wed, 27 Feb 2019 11:01:24 -0800 Subject: [PATCH] Annotate tests only compatible with graph mode PiperOrigin-RevId: 235952819 --- .../compiler/tensorrt/trt_convert_test.py | 4 ++ .../kernel_tests/copy_to_device_test.py | 31 +++++++---- .../kernel_tests/prefetch_to_device_test.py | 12 +++-- .../python/data/kernel_tests/iterator_test.py | 35 +++++++------ .../python/grappler/layout_optimizer_test.py | 19 ++++++- .../python/kernel_tests/conv_ops_test.py | 52 +++++++++++++------ .../sparse_tensor_dense_matmul_op_test.py | 25 +++++---- .../kernel_tests/tensor_array_ops_test.py | 41 ++++++++------- 8 files changed, 137 insertions(+), 82 deletions(-) diff --git a/tensorflow/python/compiler/tensorrt/trt_convert_test.py b/tensorflow/python/compiler/tensorrt/trt_convert_test.py index 97dea1bfc8a..a67426195ca 100644 --- a/tensorflow/python/compiler/tensorrt/trt_convert_test.py +++ b/tensorflow/python/compiler/tensorrt/trt_convert_test.py @@ -244,6 +244,7 @@ class TrtConvertTest(test_util.TensorFlowTestCase): "output:0", feed_dict={"input:0": [[[test_data]]]})) + @test_util.deprecated_graph_mode_only def testTrtGraphConverter_BasicConversion(self): """Test case for trt_convert.TrtGraphConverter().""" if not is_tensorrt_enabled(): @@ -276,6 +277,7 @@ class TrtConvertTest(test_util.TensorFlowTestCase): self.assertEqual(execute_native_segment_test_value, get_test_value("TRTEngineOp_0:ExecuteNativeSegment")) + @test_util.deprecated_graph_mode_only def testTrtGraphConverter_MinimumSegmentSize(self): if not is_tensorrt_enabled(): return @@ -290,6 +292,7 @@ class TrtConvertTest(test_util.TensorFlowTestCase): "output": "Identity" }, node_name_to_op) + @test_util.deprecated_graph_mode_only def testTrtGraphConverter_DynamicOp(self): if not is_tensorrt_enabled(): return @@ -329,6 +332,7 @@ class TrtConvertTest(test_util.TensorFlowTestCase): # the max, it should evict an old engine and create a new one. self._TestRun(sess, 3, True) + @test_util.deprecated_graph_mode_only def testTrtGraphConverter_StaticOp(self): if not is_tensorrt_enabled(): return diff --git a/tensorflow/python/data/experimental/kernel_tests/copy_to_device_test.py b/tensorflow/python/data/experimental/kernel_tests/copy_to_device_test.py index 34c34b5a335..af747bd4a0c 100644 --- a/tensorflow/python/data/experimental/kernel_tests/copy_to_device_test.py +++ b/tensorflow/python/data/experimental/kernel_tests/copy_to_device_test.py @@ -36,7 +36,7 @@ from tensorflow.python.util import compat as util_compat # TODO(b/117581999): add eager coverage when supported. class CopyToDeviceTest(test_base.DatasetTestBase): - @test_util.run_deprecated_v1 + @test_util.deprecated_graph_mode_only def testCopyToDevice(self): host_dataset = dataset_ops.Dataset.range(10) device_dataset = host_dataset.apply( @@ -61,7 +61,7 @@ class CopyToDeviceTest(test_base.DatasetTestBase): with self.assertRaises(errors.OutOfRangeError): self.evaluate(next_element) - @test_util.run_deprecated_v1 + @test_util.deprecated_graph_mode_only def testCopyToDeviceInt32(self): host_dataset = dataset_ops.Dataset.from_tensors([0, 1, 2, 3]) device_dataset = host_dataset.apply( @@ -85,7 +85,7 @@ class CopyToDeviceTest(test_base.DatasetTestBase): with self.assertRaises(errors.OutOfRangeError): self.evaluate(next_element) - @test_util.run_deprecated_v1 + @test_util.deprecated_graph_mode_only def testCopyToSameDevice(self): host_dataset = dataset_ops.Dataset.range(10) device_dataset = host_dataset.apply( @@ -110,7 +110,7 @@ class CopyToDeviceTest(test_base.DatasetTestBase): with self.assertRaises(errors.OutOfRangeError): self.evaluate(next_element) - @test_util.run_deprecated_v1 + @test_util.deprecated_graph_mode_only def testCopyToDeviceWithPrefetch(self): host_dataset = dataset_ops.Dataset.range(10) device_dataset = host_dataset.apply( @@ -135,7 +135,7 @@ class CopyToDeviceTest(test_base.DatasetTestBase): with self.assertRaises(errors.OutOfRangeError): self.evaluate(next_element) - @test_util.run_deprecated_v1 + @test_util.deprecated_graph_mode_only def testCopyDictToDevice(self): host_dataset = dataset_ops.Dataset.range(10).map(lambda x: {"a": x}) device_dataset = host_dataset.apply( @@ -160,7 +160,7 @@ class CopyToDeviceTest(test_base.DatasetTestBase): with self.assertRaises(errors.OutOfRangeError): self.evaluate(next_element) - @test_util.run_deprecated_v1 + @test_util.deprecated_graph_mode_only def testCopyDictToDeviceWithPrefetch(self): host_dataset = dataset_ops.Dataset.range(10).map(lambda x: {"a": x}) device_dataset = host_dataset.apply( @@ -185,7 +185,7 @@ class CopyToDeviceTest(test_base.DatasetTestBase): with self.assertRaises(errors.OutOfRangeError): self.evaluate(next_element) - @test_util.run_deprecated_v1 + @test_util.deprecated_graph_mode_only def testCopySparseTensorsToDevice(self): def make_tensor(i): @@ -218,7 +218,7 @@ class CopyToDeviceTest(test_base.DatasetTestBase): with self.assertRaises(errors.OutOfRangeError): self.evaluate(next_element) - @test_util.run_deprecated_v1 + @test_util.deprecated_graph_mode_only def testCopySparseTensorsToDeviceWithPrefetch(self): def make_tensor(i): @@ -251,6 +251,7 @@ class CopyToDeviceTest(test_base.DatasetTestBase): with self.assertRaises(errors.OutOfRangeError): self.evaluate(next_element) + @test_util.deprecated_graph_mode_only def testCopyToDeviceGpu(self): if not test_util.is_gpu_available(): self.skipTest("No GPU available") @@ -271,6 +272,7 @@ class CopyToDeviceTest(test_base.DatasetTestBase): with self.assertRaises(errors.OutOfRangeError): self.evaluate(next_element) + @test_util.deprecated_graph_mode_only def testCopyToDeviceGpuWithPrefetch(self): if not test_util.is_gpu_available(): self.skipTest("No GPU available") @@ -291,6 +293,7 @@ class CopyToDeviceTest(test_base.DatasetTestBase): with self.assertRaises(errors.OutOfRangeError): self.evaluate(next_element) + @test_util.deprecated_graph_mode_only def testCopyToDeviceGpuWithMap(self): if not test_util.is_gpu_available(): self.skipTest("No GPU available") @@ -328,6 +331,7 @@ class CopyToDeviceTest(test_base.DatasetTestBase): with self.assertRaises(errors.OutOfRangeError): self.evaluate(next_element) + @test_util.deprecated_graph_mode_only def testCopyToDeviceGpuInt32(self): if not test_util.is_gpu_available(): self.skipTest("No GPU available") @@ -347,6 +351,7 @@ class CopyToDeviceTest(test_base.DatasetTestBase): with self.assertRaises(errors.OutOfRangeError): self.evaluate(next_element) + @test_util.deprecated_graph_mode_only def testCopyToDeviceGpuInt32AndPrefetch(self): if not test_util.is_gpu_available(): self.skipTest("No GPU available") @@ -366,6 +371,7 @@ class CopyToDeviceTest(test_base.DatasetTestBase): with self.assertRaises(errors.OutOfRangeError): self.evaluate(next_element) + @test_util.deprecated_graph_mode_only def testCopyToDeviceGpuStrings(self): if not test_util.is_gpu_available(): self.skipTest("No GPU available") @@ -385,6 +391,7 @@ class CopyToDeviceTest(test_base.DatasetTestBase): with self.assertRaises(errors.OutOfRangeError): self.evaluate(next_element) + @test_util.deprecated_graph_mode_only def testCopyToDeviceGpuStringsAndPrefetch(self): if not test_util.is_gpu_available(): self.skipTest("No GPU available") @@ -404,6 +411,7 @@ class CopyToDeviceTest(test_base.DatasetTestBase): with self.assertRaises(errors.OutOfRangeError): self.evaluate(next_element) + @test_util.deprecated_graph_mode_only def testCopyToDevicePingPongCPUGPU(self): if not test_util.is_gpu_available(): self.skipTest("No GPU available") @@ -427,7 +435,7 @@ class CopyToDeviceTest(test_base.DatasetTestBase): with self.assertRaises(errors.OutOfRangeError): self.evaluate(next_element) - @test_util.run_deprecated_v1 + @test_util.deprecated_graph_mode_only def testCopyToDeviceWithReInit(self): host_dataset = dataset_ops.Dataset.range(10) device_dataset = host_dataset.apply( @@ -456,7 +464,7 @@ class CopyToDeviceTest(test_base.DatasetTestBase): with self.assertRaises(errors.OutOfRangeError): self.evaluate(next_element) - @test_util.run_deprecated_v1 + @test_util.deprecated_graph_mode_only def testCopyToDeviceWithReInitAndPrefetch(self): host_dataset = dataset_ops.Dataset.range(10) device_dataset = host_dataset.apply( @@ -485,6 +493,7 @@ class CopyToDeviceTest(test_base.DatasetTestBase): with self.assertRaises(errors.OutOfRangeError): self.evaluate(next_element) + @test_util.deprecated_graph_mode_only def testCopyToDeviceGpuWithReInit(self): if not test_util.is_gpu_available(): self.skipTest("No GPU available") @@ -508,6 +517,7 @@ class CopyToDeviceTest(test_base.DatasetTestBase): with self.assertRaises(errors.OutOfRangeError): self.evaluate(next_element) + @test_util.deprecated_graph_mode_only def testCopyToDeviceGpuWithReInitAndPrefetch(self): if not test_util.is_gpu_available(): self.skipTest("No GPU available") @@ -531,6 +541,7 @@ class CopyToDeviceTest(test_base.DatasetTestBase): with self.assertRaises(errors.OutOfRangeError): self.evaluate(next_element) + @test_util.deprecated_graph_mode_only def testIteratorGetNextAsOptionalOnGPU(self): if not test_util.is_gpu_available(): self.skipTest("No GPU available") diff --git a/tensorflow/python/data/experimental/kernel_tests/prefetch_to_device_test.py b/tensorflow/python/data/experimental/kernel_tests/prefetch_to_device_test.py index 9e3277b236a..8b5ddf403f4 100644 --- a/tensorflow/python/data/experimental/kernel_tests/prefetch_to_device_test.py +++ b/tensorflow/python/data/experimental/kernel_tests/prefetch_to_device_test.py @@ -32,7 +32,7 @@ from tensorflow.python.platform import test # TODO(b/117581999): add eager coverage when supported. class PrefetchToDeviceTest(test_base.DatasetTestBase): - @test_util.run_deprecated_v1 + @test_util.deprecated_graph_mode_only def testPrefetchToDevice(self): host_dataset = dataset_ops.Dataset.range(10) device_dataset = host_dataset.apply( @@ -57,7 +57,7 @@ class PrefetchToDeviceTest(test_base.DatasetTestBase): with self.assertRaises(errors.OutOfRangeError): self.evaluate(next_element) - @test_util.run_deprecated_v1 + @test_util.deprecated_graph_mode_only def testPrefetchToSameDevice(self): host_dataset = dataset_ops.Dataset.range(10) device_dataset = host_dataset.apply( @@ -82,7 +82,7 @@ class PrefetchToDeviceTest(test_base.DatasetTestBase): with self.assertRaises(errors.OutOfRangeError): self.evaluate(next_element) - @test_util.run_deprecated_v1 + @test_util.deprecated_graph_mode_only def testPrefetchDictToDevice(self): host_dataset = dataset_ops.Dataset.range(10).map(lambda x: {"a": x}) device_dataset = host_dataset.apply( @@ -107,7 +107,7 @@ class PrefetchToDeviceTest(test_base.DatasetTestBase): with self.assertRaises(errors.OutOfRangeError): self.evaluate(next_element) - @test_util.run_deprecated_v1 + @test_util.deprecated_graph_mode_only def testPrefetchSparseTensorsToDevice(self): def make_tensor(i): return sparse_tensor.SparseTensorValue( @@ -138,6 +138,7 @@ class PrefetchToDeviceTest(test_base.DatasetTestBase): with self.assertRaises(errors.OutOfRangeError): self.evaluate(next_element) + @test_util.deprecated_graph_mode_only def testPrefetchToDeviceGpu(self): if not test_util.is_gpu_available(): self.skipTest("No GPU available") @@ -157,7 +158,7 @@ class PrefetchToDeviceTest(test_base.DatasetTestBase): with self.assertRaises(errors.OutOfRangeError): self.evaluate(next_element) - @test_util.run_deprecated_v1 + @test_util.deprecated_graph_mode_only def testPrefetchToDeviceWithReInit(self): host_dataset = dataset_ops.Dataset.range(10) device_dataset = host_dataset.apply( @@ -186,6 +187,7 @@ class PrefetchToDeviceTest(test_base.DatasetTestBase): with self.assertRaises(errors.OutOfRangeError): self.evaluate(next_element) + @test_util.deprecated_graph_mode_only def testPrefetchToDeviceGpuWithReInit(self): if not test_util.is_gpu_available(): self.skipTest("No GPU available") diff --git a/tensorflow/python/data/kernel_tests/iterator_test.py b/tensorflow/python/data/kernel_tests/iterator_test.py index b33292c8059..f5a3645dd29 100644 --- a/tensorflow/python/data/kernel_tests/iterator_test.py +++ b/tensorflow/python/data/kernel_tests/iterator_test.py @@ -55,7 +55,7 @@ from tensorflow.python.util import compat class IteratorTest(test.TestCase, parameterized.TestCase): - @test_util.run_deprecated_v1 + @test_util.deprecated_graph_mode_only def testNoGradients(self): component = constant_op.constant([1.]) side = constant_op.constant(0.) @@ -66,7 +66,7 @@ class IteratorTest(test.TestCase, parameterized.TestCase): self.assertIsNone(gradients_impl.gradients(value, side)[0]) self.assertIsNone(gradients_impl.gradients(value, [component, side])[0]) - @test_util.run_deprecated_v1 + @test_util.deprecated_graph_mode_only def testCapturingStateInOneShotRaisesException(self): var = variables.Variable(37.0, name="myvar") dataset = ( @@ -77,7 +77,7 @@ class IteratorTest(test.TestCase, parameterized.TestCase): "datasets that capture stateful objects.+myvar"): dataset_ops.make_one_shot_iterator(dataset) - @test_util.run_deprecated_v1 + @test_util.deprecated_graph_mode_only def testOneShotIterator(self): components = (np.arange(7), np.array([[1, 2, 3]]) * np.arange(7)[:, np.newaxis], @@ -103,7 +103,7 @@ class IteratorTest(test.TestCase, parameterized.TestCase): with self.assertRaises(errors.OutOfRangeError): sess.run(get_next) - @test_util.run_deprecated_v1 + @test_util.deprecated_graph_mode_only def testOneShotIteratorCaptureByValue(self): components = (np.arange(7), np.array([[1, 2, 3]]) * np.arange(7)[:, np.newaxis], @@ -166,7 +166,7 @@ class IteratorTest(test.TestCase, parameterized.TestCase): with self.assertRaises(errors.OutOfRangeError): sess.run(get_next) - @test_util.run_deprecated_v1 + @test_util.deprecated_graph_mode_only def testOneShotIteratorNonBlocking(self): dataset = dataset_ops.Dataset.from_tensors([1, 2, 3]).map(lambda x: x * x) iterator = dataset_ops.make_one_shot_iterator(dataset) @@ -205,7 +205,7 @@ class IteratorTest(test.TestCase, parameterized.TestCase): len([None for r in results if r is None])) self.assertAllEqual([[1, 4, 9]], [r for r in results if r is not None]) - @test_util.run_deprecated_v1 + @test_util.deprecated_graph_mode_only def testOneShotIteratorInitializerFails(self): # Define a dataset whose initialization will always fail. dataset = dataset_ops.Dataset.from_tensors( @@ -286,7 +286,7 @@ class IteratorTest(test.TestCase, parameterized.TestCase): with self.assertRaises(errors.OutOfRangeError): sess.run(get_next) - @test_util.run_deprecated_v1 + @test_util.deprecated_graph_mode_only def testNotInitializedError(self): components = (np.array(1), np.array([1, 2, 3]), np.array(37.0)) iterator = dataset_ops.make_initializable_iterator( @@ -298,7 +298,7 @@ class IteratorTest(test.TestCase, parameterized.TestCase): "iterator has not been initialized"): sess.run(get_next) - @test_util.run_deprecated_v1 + @test_util.deprecated_graph_mode_only def testReinitializableIterator(self): dataset_3 = dataset_ops.Dataset.from_tensors( constant_op.constant([1, 2, 3])) @@ -339,7 +339,7 @@ class IteratorTest(test.TestCase, parameterized.TestCase): with self.assertRaises(errors.OutOfRangeError): sess.run(get_next) - @test_util.run_deprecated_v1 + @test_util.deprecated_graph_mode_only def testReinitializableIteratorWithFunctions(self): def g(): @@ -399,7 +399,7 @@ class IteratorTest(test.TestCase, parameterized.TestCase): (constant_op.constant([1, 2, 3], dtype=dtypes.int64), constant_op.constant([4., 5., 6., 7.], dtype=dtypes.float64)))) - @test_util.run_deprecated_v1 + @test_util.deprecated_graph_mode_only def testIteratorStringHandle(self): dataset_3 = dataset_ops.Dataset.from_tensor_slices([1, 2, 3]) dataset_4 = dataset_ops.Dataset.from_tensor_slices([10, 20, 30, 40]) @@ -457,7 +457,7 @@ class IteratorTest(test.TestCase, parameterized.TestCase): sess.run( next_element, feed_dict={handle_placeholder: iterator_4_handle}) - @test_util.run_deprecated_v1 + @test_util.deprecated_graph_mode_only def testIteratorStringHandleFuture(self): with forward_compat.forward_compatibility_horizon(2018, 8, 4): dataset_3 = dataset_ops.Dataset.from_tensor_slices([1, 2, 3]) @@ -523,7 +523,7 @@ class IteratorTest(test.TestCase, parameterized.TestCase): sess.run( next_element, feed_dict={handle_placeholder: iterator_4_handle}) - @test_util.run_deprecated_v1 + @test_util.deprecated_graph_mode_only def testIteratorStringHandleReuseTensorObject(self): dataset = dataset_ops.Dataset.from_tensor_slices([1, 2, 3]) one_shot_iterator = dataset_ops.make_one_shot_iterator(dataset) @@ -552,7 +552,7 @@ class IteratorTest(test.TestCase, parameterized.TestCase): self.assertEqual("foo_1", handle_with_same_name.op.name) self.assertIsNot(handle_with_name, handle_with_same_name) - @test_util.run_deprecated_v1 + @test_util.deprecated_graph_mode_only def testIteratorStringHandleError(self): dataset_int_scalar = ( dataset_ops.Dataset.from_tensor_slices([1, 2, 3]).repeat()) @@ -593,7 +593,7 @@ class IteratorTest(test.TestCase, parameterized.TestCase): feedable_int_vector.get_next(), feed_dict={handle_placeholder: handle_float_vector})) - @test_util.run_deprecated_v1 + @test_util.deprecated_graph_mode_only def testRemoteIteratorUsingRemoteCallOpDirectSession(self): worker_config = config_pb2.ConfigProto() worker_config.device_count["CPU"] = 3 @@ -651,7 +651,7 @@ class IteratorTest(test.TestCase, parameterized.TestCase): target_placeholder: "/job:localhost/replica:0/task:0/cpu:1" }) - @test_util.run_deprecated_v1 + @test_util.deprecated_graph_mode_only def testRemoteIteratorUsingRemoteCallOpMultiWorkers(self): s1 = server_lib.Server.create_local_server() s2 = server_lib.Server.create_local_server() @@ -705,6 +705,7 @@ class IteratorTest(test.TestCase, parameterized.TestCase): with self.assertRaises(errors.OutOfRangeError): sess.run(n) + @test_util.deprecated_graph_mode_only def testRemoteIteratorUsingRemoteCallOpDirectSessionGPUCPU(self): if not test_util.is_gpu_available(): self.skipTest("No GPU available") @@ -761,7 +762,7 @@ class IteratorTest(test.TestCase, parameterized.TestCase): target_placeholder: "/job:localhost/replica:0/task:0/cpu:0" }) - @test_util.run_deprecated_v1 + @test_util.deprecated_graph_mode_only def testIncorrectIteratorRestore(self): def _path(): @@ -820,7 +821,7 @@ class IteratorTest(test.TestCase, parameterized.TestCase): with self.assertRaises(errors.InvalidArgumentError): sess.run(restore_op) - @test_util.run_deprecated_v1 + @test_util.deprecated_graph_mode_only def testRepeatedGetNextWarning(self): iterator = dataset_ops.make_one_shot_iterator(dataset_ops.Dataset.range(10)) warnings.simplefilter("always") diff --git a/tensorflow/python/grappler/layout_optimizer_test.py b/tensorflow/python/grappler/layout_optimizer_test.py index b6aee941b05..620689008c9 100644 --- a/tensorflow/python/grappler/layout_optimizer_test.py +++ b/tensorflow/python/grappler/layout_optimizer_test.py @@ -283,6 +283,7 @@ class LayoutOptimizerTest(test.TestCase): self.assertAllClose(output_val_ref, output_val, atol=1e-3) + @test_util.deprecated_graph_mode_only def testSplitWithNonConstAxis(self): if test.is_gpu_available(cuda_only=True): random_seed.set_random_seed(0) @@ -318,6 +319,7 @@ class LayoutOptimizerTest(test.TestCase): self._assert_map_nhwc_to_nchw('split-0', nodes) self.assertAllClose(output_val_ref, output_val, atol=1e-3) + @test_util.deprecated_graph_mode_only def testSplitVWithNonConstAxis(self): if test.is_gpu_available(cuda_only=True): random_seed.set_random_seed(0) @@ -745,6 +747,7 @@ class LayoutOptimizerTest(test.TestCase): self.assertIn('concat-2-LayoutOptimizer', nodes) self.assertAllClose(output_val_ref, output_val, atol=1e-3) + @test_util.deprecated_graph_mode_only def testFill(self): if test.is_gpu_available(cuda_only=True): random_seed.set_random_seed(0) @@ -788,6 +791,7 @@ class LayoutOptimizerTest(test.TestCase): self._assert_trans_nchw_to_nhwc('Fill-0-0', nodes) self.assertAllClose(output_val_ref, output_val, atol=1e-3) + @test_util.deprecated_graph_mode_only def testTile(self): if test.is_gpu_available(cuda_only=True): random_seed.set_random_seed(0) @@ -856,6 +860,7 @@ class LayoutOptimizerTest(test.TestCase): self.assertIn('ReverseV2-1-LayoutOptimizer', nodes) self.assertAllClose(output_val_ref, output_val, atol=1e-3) + @test_util.deprecated_graph_mode_only def testReverseWithNonConstDims(self): if test.is_gpu_available(cuda_only=True): random_seed.set_random_seed(0) @@ -923,6 +928,7 @@ class LayoutOptimizerTest(test.TestCase): self._assert_trans_nchw_to_nhwc('Select-0-0', nodes) self.assertAllClose(output_val_ref, output_val, atol=1e-3) + @test_util.deprecated_graph_mode_only def testSelectOpConditionUnknownShape(self): if test.is_gpu_available(cuda_only=True): random_seed.set_random_seed(0) @@ -984,6 +990,7 @@ class LayoutOptimizerTest(test.TestCase): self._assert_trans_nchw_to_nhwc('Select-0-0', nodes) self.assertAllClose(output_val_ref, output_val, atol=1e-3) + @test_util.deprecated_graph_mode_only def testPadWithNonConstPaddings(self): if test.is_gpu_available(cuda_only=True): random_seed.set_random_seed(0) @@ -1020,6 +1027,7 @@ class LayoutOptimizerTest(test.TestCase): self._assert_vec_nhwc_to_nchw('Pad-1', nodes) self.assertAllClose(output_val_ref, output_val, atol=1e-3) + @test_util.deprecated_graph_mode_only def testMaxPoolV2(self): if test.is_gpu_available(cuda_only=True): random_seed.set_random_seed(0) @@ -1056,6 +1064,7 @@ class LayoutOptimizerTest(test.TestCase): self.assertIn('MaxPoolV2-1-LayoutOptimizer', nodes) self.assertAllClose(output_val_ref, output_val, atol=1e-3) + @test_util.deprecated_graph_mode_only def testMaxPoolGradV2(self): if test.is_gpu_available(cuda_only=True): random_seed.set_random_seed(0) @@ -1093,6 +1102,7 @@ class LayoutOptimizerTest(test.TestCase): self.assertIn('MaxPoolGradV2-3-LayoutOptimizer', nodes) self.assertAllClose(output_val_ref, output_val, atol=1e-3) + @test_util.deprecated_graph_mode_only def testSliceWithNonConstAxis(self): if test.is_gpu_available(cuda_only=True): random_seed.set_random_seed(0) @@ -1129,6 +1139,7 @@ class LayoutOptimizerTest(test.TestCase): self._assert_vec_nhwc_to_nchw('Slice-2', nodes) self.assertAllClose(output_val_ref, output_val, atol=1e-3) + @test_util.deprecated_graph_mode_only def testStridedSliceWithNonConstAxis(self): if test.is_gpu_available(cuda_only=True): random_seed.set_random_seed(0) @@ -1237,6 +1248,7 @@ class LayoutOptimizerTest(test.TestCase): self.assertIn('strided_slice-3-LayoutOptimizer', nodes) self.assertAllClose(output_val_ref, output_val, atol=1e-3) + @test_util.deprecated_graph_mode_only def testStridedSliceGradWithNonConstAxis(self): if test.is_gpu_available(cuda_only=True): random_seed.set_random_seed(0) @@ -1279,6 +1291,7 @@ class LayoutOptimizerTest(test.TestCase): self.assertIn('StridedSlice-2-LayoutOptimizer', nodes) self.assertAllClose(output_val_ref, output_val, atol=1e-3) + @test_util.deprecated_graph_mode_only def testShapeN(self): if test.is_gpu_available(cuda_only=True): x = array_ops.placeholder(dtype='float32') @@ -1310,6 +1323,7 @@ class LayoutOptimizerTest(test.TestCase): self._assert_vec_nchw_to_nhwc('ShapeN-0-0', nodes) self.assertAllEqual(output_val_ref, output_val) + @test_util.deprecated_graph_mode_only def testShapeNFollowedByNotConvertibleNodeReshape(self): if test.is_gpu_available(cuda_only=True): x = array_ops.placeholder(dtype='float32') @@ -1416,6 +1430,7 @@ class LayoutOptimizerTest(test.TestCase): self._assert_trans_nchw_to_nhwc('map/while/Add_1-0-2', nodes) self.assertAllClose(output_val_ref, output_val, atol=1e-3) + @test_util.deprecated_graph_mode_only def testBinaryOpSecondPort(self): if test.is_gpu_available(cuda_only=True): output = _model_with_second_port() @@ -1440,7 +1455,7 @@ class LayoutOptimizerTest(test.TestCase): self._assert_trans_nchw_to_nhwc('Add-0-0', nodes) self.assertAllClose(output_val_ref, output_val, atol=1e-3) - @test_util.run_deprecated_v1 + @test_util.deprecated_graph_mode_only def testGradient(self): meta_graph = _simple_metagraph() config = config_pb2.ConfigProto() @@ -1458,7 +1473,7 @@ class LayoutOptimizerTest(test.TestCase): self.assertEqual(node.attr['data_format'].s, b'NCHW') self.assertEqual(found, 5) - @test_util.run_deprecated_v1 + @test_util.deprecated_graph_mode_only def testDepthwise(self): meta_graph = _simple_metagraph(depthwise=True) config = config_pb2.ConfigProto() diff --git a/tensorflow/python/kernel_tests/conv_ops_test.py b/tensorflow/python/kernel_tests/conv_ops_test.py index 6e470ac24f1..c0ad21ddef0 100644 --- a/tensorflow/python/kernel_tests/conv_ops_test.py +++ b/tensorflow/python/kernel_tests/conv_ops_test.py @@ -1161,6 +1161,7 @@ class Conv2DTest(test.TestCase): tf_logging.debug("actual = %s", value) self.assertArrayNear(value_2.flatten(), value.flatten(), err) + @test_util.deprecated_graph_mode_only def testConv2D2x2Depth3ValidBackpropFilterStride1x1Dilation2x1(self): if test.is_gpu_available(cuda_only=True) or test_util.IsMklEnabled(): for (data_format, use_gpu) in GetTestConfigs(): @@ -1175,6 +1176,7 @@ class Conv2DTest(test.TestCase): use_gpu=use_gpu, err=1e-5) + @test_util.deprecated_graph_mode_only def testConv2D2x2Depth1ValidBackpropFilterDilation1x2(self): if test.is_gpu_available(cuda_only=True) or test_util.IsMklEnabled(): for (data_format, use_gpu) in GetTestConfigs(): @@ -1203,6 +1205,7 @@ class Conv2DTest(test.TestCase): use_gpu=use_gpu, err=1e-5) + @test_util.deprecated_graph_mode_only def testConv2D2x2Depth3ValidBackpropFilterDilation2x2(self): if test.is_gpu_available(cuda_only=True) or test_util.IsMklEnabled(): for (data_format, use_gpu) in GetTestConfigs(): @@ -1231,6 +1234,7 @@ class Conv2DTest(test.TestCase): use_gpu=use_gpu, err=1e-5) + @test_util.deprecated_graph_mode_only def testConv2D2x2Depth3ValidBackpropInputStride1x1Dilation2x1(self): if test.is_gpu_available(cuda_only=True) or test_util.IsMklEnabled(): for (data_format, use_gpu) in GetTestConfigs(): @@ -1245,6 +1249,7 @@ class Conv2DTest(test.TestCase): use_gpu=use_gpu, err=1e-5) + @test_util.deprecated_graph_mode_only def testConv2D2x2Depth1ValidBackpropInputDilation1x2(self): if test.is_gpu_available(cuda_only=True) or test_util.IsMklEnabled(): for (data_format, use_gpu) in GetTestConfigs(): @@ -1273,6 +1278,7 @@ class Conv2DTest(test.TestCase): use_gpu=use_gpu, err=1e-5) + @test_util.deprecated_graph_mode_only def testConv2D2x2Depth3ValidBackpropInputDilation2x1(self): if test.is_gpu_available(cuda_only=True) or test_util.IsMklEnabled(): for (data_format, use_gpu) in GetTestConfigs(): @@ -1703,7 +1709,7 @@ class Conv2DTest(test.TestCase): tf_logging.debug("conv_2d gradient error = %s", err) self.assertLess(err, max_err) - @test_util.run_deprecated_v1 + @test_util.deprecated_graph_mode_only def testInputGradientValidPaddingStrideOne(self): for (data_format, use_gpu) in GetTestConfigs(): self.ConstructAndTestGradient( @@ -1721,7 +1727,7 @@ class Conv2DTest(test.TestCase): data_format=data_format, use_gpu=use_gpu) - @test_util.run_deprecated_v1 + @test_util.deprecated_graph_mode_only def testFilterGradientValidPaddingStrideOne(self): for (data_format, use_gpu) in GetTestConfigs(): self.ConstructAndTestGradient( @@ -1739,7 +1745,7 @@ class Conv2DTest(test.TestCase): data_format=data_format, use_gpu=use_gpu) - @test_util.run_deprecated_v1 + @test_util.deprecated_graph_mode_only def testInputGradientValidPaddingStrideTwo(self): for (data_format, use_gpu) in GetTestConfigs(): self.ConstructAndTestGradient( @@ -1757,7 +1763,7 @@ class Conv2DTest(test.TestCase): data_format=data_format, use_gpu=use_gpu) - @test_util.run_deprecated_v1 + @test_util.deprecated_graph_mode_only def testFilterGradientValidPaddingStrideTwo(self): for (data_format, use_gpu) in GetTestConfigs(): self.ConstructAndTestGradient( @@ -1775,7 +1781,7 @@ class Conv2DTest(test.TestCase): data_format=data_format, use_gpu=use_gpu) - @test_util.run_deprecated_v1 + @test_util.deprecated_graph_mode_only def testInputGradientValidPaddingStrideThree(self): for (data_format, use_gpu) in GetTestConfigs(): self.ConstructAndTestGradient( @@ -1793,7 +1799,7 @@ class Conv2DTest(test.TestCase): data_format=data_format, use_gpu=use_gpu) - @test_util.run_deprecated_v1 + @test_util.deprecated_graph_mode_only def testFilterGradientValidPaddingStrideThree(self): for (data_format, use_gpu) in GetTestConfigs(): self.ConstructAndTestGradient( @@ -1811,7 +1817,7 @@ class Conv2DTest(test.TestCase): data_format=data_format, use_gpu=use_gpu) - @test_util.run_deprecated_v1 + @test_util.deprecated_graph_mode_only def testInputGradientSamePaddingStrideOne(self): for (data_format, use_gpu) in GetTestConfigs(): self.ConstructAndTestGradient( @@ -1829,7 +1835,7 @@ class Conv2DTest(test.TestCase): data_format=data_format, use_gpu=use_gpu) - @test_util.run_deprecated_v1 + @test_util.deprecated_graph_mode_only def testFilterGradientSamePaddingStrideOne(self): for (data_format, use_gpu) in GetTestConfigs(): self.ConstructAndTestGradient( @@ -1847,7 +1853,7 @@ class Conv2DTest(test.TestCase): data_format=data_format, use_gpu=use_gpu) - @test_util.run_deprecated_v1 + @test_util.deprecated_graph_mode_only def testInputGradientSamePaddingStrideTwo(self): for (data_format, use_gpu) in GetTestConfigs(): self.ConstructAndTestGradient( @@ -1865,7 +1871,7 @@ class Conv2DTest(test.TestCase): data_format=data_format, use_gpu=use_gpu) - @test_util.run_deprecated_v1 + @test_util.deprecated_graph_mode_only def testFilterGradientSamePaddingStrideTwo(self): for (data_format, use_gpu) in GetTestConfigs(): self.ConstructAndTestGradient( @@ -1883,7 +1889,7 @@ class Conv2DTest(test.TestCase): data_format=data_format, use_gpu=use_gpu) - @test_util.run_deprecated_v1 + @test_util.deprecated_graph_mode_only def testInputGradientSamePaddingStrideThree(self): for (data_format, use_gpu) in GetTestConfigs(): self.ConstructAndTestGradient( @@ -1901,7 +1907,7 @@ class Conv2DTest(test.TestCase): data_format=data_format, use_gpu=use_gpu) - @test_util.run_deprecated_v1 + @test_util.deprecated_graph_mode_only def testFilterGradientSamePaddingStrideThree(self): for (data_format, use_gpu) in GetTestConfigs(): self.ConstructAndTestGradient( @@ -1919,7 +1925,7 @@ class Conv2DTest(test.TestCase): data_format=data_format, use_gpu=use_gpu) - @test_util.run_deprecated_v1 + @test_util.deprecated_graph_mode_only def testFilterGradientSamePaddingStride2x1(self): for (data_format, use_gpu) in GetTestConfigs(): self.ConstructAndTestGradient( @@ -1937,7 +1943,7 @@ class Conv2DTest(test.TestCase): data_format=data_format, use_gpu=use_gpu) - @test_util.run_deprecated_v1 + @test_util.deprecated_graph_mode_only def testInputGradientKernelSizeMatchesInputSize(self): for (data_format, use_gpu) in GetTestConfigs(): self.ConstructAndTestGradient( @@ -1955,7 +1961,7 @@ class Conv2DTest(test.TestCase): data_format=data_format, use_gpu=use_gpu) - @test_util.run_deprecated_v1 + @test_util.deprecated_graph_mode_only def testFilterGradientKernelSizeMatchesInputSize(self): for (data_format, use_gpu) in GetTestConfigs(): self.ConstructAndTestGradient( @@ -1973,6 +1979,7 @@ class Conv2DTest(test.TestCase): data_format=data_format, use_gpu=use_gpu) + @test_util.deprecated_graph_mode_only def testInputGradient1x1PaddingStrideOne(self): if not test.is_gpu_available(cuda_only=True): return @@ -1994,6 +2001,7 @@ class Conv2DTest(test.TestCase): use_gpu=use_gpu, max_err=0.0025) + @test_util.deprecated_graph_mode_only def testFilterGradient1x1PaddingStrideOne(self): if not test.is_gpu_available(cuda_only=True): return @@ -2014,6 +2022,7 @@ class Conv2DTest(test.TestCase): data_format=data_format, use_gpu=use_gpu) + @test_util.deprecated_graph_mode_only def testInputGradient1x1PaddingStrideTwo(self): if not test.is_gpu_available(cuda_only=True): return @@ -2034,6 +2043,7 @@ class Conv2DTest(test.TestCase): data_format=data_format, use_gpu=use_gpu) + @test_util.deprecated_graph_mode_only def testFilterGradient1x1PaddingStrideTwo(self): if not test.is_gpu_available(cuda_only=True): return @@ -2054,6 +2064,7 @@ class Conv2DTest(test.TestCase): data_format=data_format, use_gpu=use_gpu) + @test_util.deprecated_graph_mode_only def testInputGradient2x2PaddingStrideOne(self): if not test.is_gpu_available(cuda_only=True): return @@ -2074,6 +2085,7 @@ class Conv2DTest(test.TestCase): data_format=data_format, use_gpu=use_gpu) + @test_util.deprecated_graph_mode_only def testFilterGradient2x2PaddingStrideOne(self): if not test.is_gpu_available(cuda_only=True): return @@ -2095,6 +2107,7 @@ class Conv2DTest(test.TestCase): use_gpu=use_gpu, max_err=0.003) + @test_util.deprecated_graph_mode_only def testInputGradient1_2_3_4PaddingStride3x2(self): if not test.is_gpu_available(cuda_only=True): return @@ -2115,6 +2128,7 @@ class Conv2DTest(test.TestCase): data_format=data_format, use_gpu=use_gpu) + @test_util.deprecated_graph_mode_only def testFilterGradient1_2_3_4PaddingStride3x2(self): if not test.is_gpu_available(cuda_only=True): return @@ -2135,6 +2149,7 @@ class Conv2DTest(test.TestCase): data_format=data_format, use_gpu=use_gpu) + @test_util.deprecated_graph_mode_only def testInputGradient4_3_2_1PaddingStride2x1(self): if not test.is_gpu_available(cuda_only=True): return @@ -2155,6 +2170,7 @@ class Conv2DTest(test.TestCase): data_format=data_format, use_gpu=use_gpu) + @test_util.deprecated_graph_mode_only def testFilterGradient4_3_2_1PaddingStride2x1(self): if not test.is_gpu_available(cuda_only=True): return @@ -2175,6 +2191,7 @@ class Conv2DTest(test.TestCase): data_format=data_format, use_gpu=use_gpu) + @test_util.deprecated_graph_mode_only def testInputGradient0_0_0_5PaddingStride1x2(self): if not test.is_gpu_available(cuda_only=True): return @@ -2195,6 +2212,7 @@ class Conv2DTest(test.TestCase): data_format=data_format, use_gpu=use_gpu) + @test_util.deprecated_graph_mode_only def testFilterGradient0_0_0_5PaddingStride1x2(self): if not test.is_gpu_available(cuda_only=True): return @@ -2215,7 +2233,7 @@ class Conv2DTest(test.TestCase): data_format=data_format, use_gpu=use_gpu) - @test_util.run_deprecated_v1 + @test_util.deprecated_graph_mode_only def testShapeFunctionEdgeCases(self): # All shapes unknown. c1 = nn_ops.conv2d( @@ -2302,7 +2320,7 @@ class Conv2DTest(test.TestCase): strides=[1, 1, 1, 1], padding=[0, 0, 0, 0]) - @test_util.run_deprecated_v1 + @test_util.deprecated_graph_mode_only @test_util.disable_xla("b/123337890") # Error messages differ def testOpEdgeCases(self): with self.cached_session() as sess: diff --git a/tensorflow/python/kernel_tests/sparse_tensor_dense_matmul_op_test.py b/tensorflow/python/kernel_tests/sparse_tensor_dense_matmul_op_test.py index 637cfaec990..c8dc99c8ec0 100644 --- a/tensorflow/python/kernel_tests/sparse_tensor_dense_matmul_op_test.py +++ b/tensorflow/python/kernel_tests/sparse_tensor_dense_matmul_op_test.py @@ -81,7 +81,7 @@ class SparseTensorDenseMatMulTest(test.TestCase): self.assertEqual(tf_value_ans.get_shape()[1], np_ans.shape[1]) self.assertEqual(tf_tensor_ans.get_shape()[1], np_ans.shape[1]) - for out in (tf_value_ans.eval(), self.evaluate(tf_tensor_ans)): + for out in (self.evaluate(tf_value_ans), self.evaluate(tf_tensor_ans)): if x.dtype == np.float32: self.assertAllClose(np_ans, out, rtol=1e-4, atol=1e-4) elif x.dtype == np.float64: @@ -134,6 +134,7 @@ class SparseTensorDenseMatMulTest(test.TestCase): with self.assertRaisesRegexp(ValueError, "Dimensions must be equal"): sparse_ops.sparse_tensor_dense_matmul(x_st_shape_inconsistent, y) + @test_util.deprecated_graph_mode_only def testInvalidIndicesForSparseTensorDenseMatmul(self): # Note: use_gpu=False because nice errors are only returned from CPU kernel. with self.session(use_gpu=False): @@ -147,23 +148,25 @@ class SparseTensorDenseMatMulTest(test.TestCase): dense_t = np.matrix([[1] * 5, [2] * 5], dtype=np.float32) with self.assertRaisesOpError( "k .10. from index.0,1. out of bounds .>=2."): - sparse_ops.sparse_tensor_dense_matmul(sparse_t, dense_t).eval() + self.evaluate(sparse_ops.sparse_tensor_dense_matmul(sparse_t, dense_t)) dense_t = np.matrix([[1] * 500, [2] * 500], dtype=np.float32) with self.assertRaisesOpError( "k .10. from index.0,1. out of bounds .>=2."): - sparse_ops.sparse_tensor_dense_matmul(sparse_t, dense_t).eval() + self.evaluate(sparse_ops.sparse_tensor_dense_matmul(sparse_t, dense_t)) # Repeat with adjoint_a, to get a different error. dense_t = np.matrix([[1] * 5, [2] * 5, [3] * 5], dtype=np.float32) with self.assertRaisesOpError( "m .10. from index.0,1. out of bounds .>=2."): - sparse_ops.sparse_tensor_dense_matmul( - sparse_t, dense_t, adjoint_a=True).eval() + self.evaluate( + sparse_ops.sparse_tensor_dense_matmul( + sparse_t, dense_t, adjoint_a=True)) dense_t = np.matrix([[1] * 500, [2] * 500, [3] * 500], dtype=np.float32) with self.assertRaisesOpError( "m .10. from index.0,1. out of bounds .>=2."): - sparse_ops.sparse_tensor_dense_matmul( - sparse_t, dense_t, adjoint_a=True).eval() + self.evaluate( + sparse_ops.sparse_tensor_dense_matmul( + sparse_t, dense_t, adjoint_a=True)) def testInvalidIndicesForSparseTensorDenseMatmulOnGPU(self): # Note: use_gpu=False because nice errors are only returned from CPU kerne @@ -181,13 +184,13 @@ class SparseTensorDenseMatMulTest(test.TestCase): expected_t = np.array([[0] * 5, [np.nan] * 5, [0] * 5], dtype=np.float32) self.assertAllClose(expected_t, sparse_ops.sparse_tensor_dense_matmul( - sparse_t, dense_t).eval()) + sparse_t, dense_t)) dense_t = np.matrix([[1] * 500, [2] * 500], dtype=np.float32) expected_t = np.array( [[0] * 500, [np.nan] * 500, [0] * 500], dtype=np.float32) self.assertAllClose(expected_t, sparse_ops.sparse_tensor_dense_matmul( - sparse_t, dense_t).eval()) + sparse_t, dense_t)) # Repeat with adjoint_a, now the error is that the sparse index # is OOO w.r.t. the output. The GPU kernel can't do much here, @@ -197,13 +200,13 @@ class SparseTensorDenseMatMulTest(test.TestCase): expected_t = np.array([[0] * 5, [0] * 5], dtype=np.float32) self.assertAllClose(expected_t, sparse_ops.sparse_tensor_dense_matmul( - sparse_t, dense_t, adjoint_a=True).eval()) + sparse_t, dense_t, adjoint_a=True)) dense_t = np.matrix([[1] * 500, [2] * 500, [3] * 500], dtype=np.float32) expected_t = np.array([[0] * 500, [0] * 500], dtype=np.float32) self.assertAllClose(expected_t, sparse_ops.sparse_tensor_dense_matmul( - sparse_t, dense_t, adjoint_a=True).eval()) + sparse_t, dense_t, adjoint_a=True)) # Tests setting one dimension to be a high value. def _testLarge(self, np_dtype): diff --git a/tensorflow/python/kernel_tests/tensor_array_ops_test.py b/tensorflow/python/kernel_tests/tensor_array_ops_test.py index 056e3b9ff88..4d7ae4f24ea 100644 --- a/tensorflow/python/kernel_tests/tensor_array_ops_test.py +++ b/tensorflow/python/kernel_tests/tensor_array_ops_test.py @@ -162,7 +162,7 @@ class TensorArrayTest(test.TestCase): convert([[4.0, 5.0], [104.0, 105.0], [204.0, 205.0], [6.0, 7.0], [106.0, 107.0], [8.0, 9.0]]), c0) - @test_util.run_deprecated_v1 + @test_util.deprecated_graph_mode_only def testTensorArrayWriteConcat(self): self._testTensorArrayWriteConcat(dtypes.float32) self._testTensorArrayWriteConcat(dtypes.float64) @@ -308,7 +308,7 @@ class TensorArrayTest(test.TestCase): self.assertAllEqual(convert([]).reshape(0, 2), d1) self.assertAllEqual(convert([[3.0, 301.0]]), d2) - @test_util.run_deprecated_v1 + @test_util.deprecated_graph_mode_only def testTensorArraySplitRead(self): self._testTensorArraySplitRead(dtypes.float32) self._testTensorArraySplitRead(dtypes.float64) @@ -353,7 +353,7 @@ class TensorArrayTest(test.TestCase): self.assertAllEqual([[2.0]], g_d1) self.assertAllEqual(-2.0, g_d2) - @test_util.run_deprecated_v1 + @test_util.deprecated_graph_mode_only def testSkipEagerTensorArrayGradGrad(self): if not control_flow_util.ENABLE_CONTROL_FLOW_V2: self.skipTest("Legacy TensorArray does not support double derivatives.") @@ -745,7 +745,7 @@ class TensorArrayTest(test.TestCase): self.assertAllEqual(c([[3.0, 2.0]]), grad_vals[0]) self.assertAllEqual(c(-2.0), grad_vals[1]) - @test_util.run_deprecated_v1 + @test_util.deprecated_graph_mode_only def testSkipEagerTensorArrayGradientWriteRead(self): for dtype in (np.float32, np.float64, np.complex64, np.complex128): self._testTensorArrayGradientWriteReadType(dtype) @@ -782,7 +782,7 @@ class TensorArrayTest(test.TestCase): self.assertAllClose([2.0 - 0.5 + 20.0, 3.0 + 1.5 + 30.0], grad_vals[0]) self.assertAllEqual([4.0 + 40.0, 5.0 + 50.0], grad_vals[1]) - @test_util.run_deprecated_v1 + @test_util.deprecated_graph_mode_only def testSkipEagerTensorArrayGradientWritePackConcatAndRead(self): self._testTensorArrayGradientWritePackConcatAndRead() @@ -841,11 +841,11 @@ class TensorArrayTest(test.TestCase): self.assertEqual(len(grad_vals), 1) self.assertAllEqual([[2.0 - 1.5, 3.0 + 1.5], [4.0, 5.0]], grad_vals[0]) - @test_util.run_deprecated_v1 + @test_util.deprecated_graph_mode_only def testSkipEagerTensorArrayGradientUnpackRead(self): self._testTensorArrayGradientUnpackRead() - @test_util.run_deprecated_v1 + @test_util.deprecated_graph_mode_only def testSkipEagerTensorArrayGradientSplitConcat(self): with self.session(use_gpu=True) as session: ta = tensor_array_ops.TensorArray( @@ -891,7 +891,7 @@ class TensorArrayTest(test.TestCase): self.assertEqual(len(grad_vals), 1) self.assertAllEqual([[2.0, 3.0], [4.0, 5.0]], grad_vals[0]) - @test_util.run_deprecated_v1 + @test_util.deprecated_graph_mode_only def testSkipEagerTensorArrayGradientDynamicUnpackRead(self): self._testTensorArrayGradientDynamicUnpackRead() @@ -1056,7 +1056,7 @@ class TensorArrayTest(test.TestCase): grad = gradients_impl.gradients(loop(x), [x])[0] self.assertAllClose(31.0, self.evaluate(grad)) - @test_util.run_deprecated_v1 + @test_util.deprecated_graph_mode_only def testSkipEagerSumOfTwoReadVariablesWithoutRepeatGrad(self): with self.session(use_gpu=True) as session: a = array_ops.identity( @@ -1092,7 +1092,7 @@ class TensorArrayTest(test.TestCase): def _grad_source_for_name(self, name): return tensor_array_grad._GetGradSource(constant_op.constant(0, name=name)) - @test_util.run_deprecated_v1 + @test_util.deprecated_graph_mode_only def testSkipEagerGetGradSource_Invalid(self): with self.assertRaises(ValueError): self._grad_source_for_name("") @@ -1101,7 +1101,7 @@ class TensorArrayTest(test.TestCase): with self.assertRaises(ValueError): self._grad_source_for_name("foo/bar") - @test_util.run_deprecated_v1 + @test_util.deprecated_graph_mode_only def testSkipEagerGetGradSource_NoEnclosingScope(self): self.assertEqual("gradients:0", self._grad_source_for_name("gradients")) self.assertEqual("gradients_0:0", self._grad_source_for_name("gradients_0")) @@ -1113,7 +1113,7 @@ class TensorArrayTest(test.TestCase): self.assertEqual("gradients_0", self._grad_source_for_name("gradients_0/foo/bar")) - @test_util.run_deprecated_v1 + @test_util.deprecated_graph_mode_only def testSkipEagerGetGradSource_EnclosingScope(self): self.assertEqual("foo/gradients:0", self._grad_source_for_name("foo/gradients")) @@ -1128,13 +1128,13 @@ class TensorArrayTest(test.TestCase): self.assertEqual("foo/bar/gradients_0", self._grad_source_for_name("foo/bar/gradients_0/baz")) - @test_util.run_deprecated_v1 + @test_util.deprecated_graph_mode_only def testSkipEagerGetGradSource_NestedUsesInnermost(self): self.assertEqual( "foo/gradients/bar/gradients_0", self._grad_source_for_name("foo/gradients/bar/gradients_0/baz")) - @test_util.run_deprecated_v1 + @test_util.deprecated_graph_mode_only def testSkipEagerWriteShape(self): with self.session(use_gpu=True): ta = tensor_array_ops.TensorArray( @@ -1159,7 +1159,7 @@ class TensorArrayTest(test.TestCase): with self.assertRaises(ValueError): w0.write(0, c2) - @test_util.run_deprecated_v1 + @test_util.deprecated_graph_mode_only def testSkipEagerPartlyUnknownShape(self): with self.session(use_gpu=True): ta = tensor_array_ops.TensorArray( @@ -1237,7 +1237,7 @@ class TensorArrayTest(test.TestCase): def testUnpackShape(self): self._testUnpackShape() - @test_util.run_deprecated_v1 + @test_util.deprecated_graph_mode_only def testSplitShape(self): with self.session(use_gpu=True): ta = tensor_array_ops.TensorArray( @@ -1269,7 +1269,7 @@ class TensorArrayTest(test.TestCase): tensor_shape.TensorShape( ta1.handle.op.get_attr("element_shape")).ndims, None) - @test_util.run_deprecated_v1 + @test_util.deprecated_graph_mode_only def testSkipEagerWriteUnknownShape(self): with self.session(use_gpu=True): ta = tensor_array_ops.TensorArray( @@ -1293,11 +1293,11 @@ class TensorArrayTest(test.TestCase): grad_r0_vals = session.run(grad_r0)[0] self.assertAllEqual(grad_r0_vals, [1.0, 0.0]) - @test_util.run_deprecated_v1 + @test_util.deprecated_graph_mode_only def testSkipEagerGradientWhenNotAllComponentsRead(self): self._testGradientWhenNotAllComponentsRead() - @test_util.run_deprecated_v1 + @test_util.deprecated_graph_mode_only def testSkipEagerWriteButNotAllComponentsReadGrad(self): with self.cached_session(use_gpu=True) as session: x0 = constant_op.constant(5.0) @@ -1645,7 +1645,7 @@ class TensorArrayTest(test.TestCase): self.assertEqual(size0_v, 2) self.assertEqual(size1_v, 4) - @test_util.run_deprecated_v1 + @test_util.deprecated_graph_mode_only def testSkipEagerTensorArrayGradYsInCorrectScope(self): n_time = 1 n_dim = 1 @@ -1664,6 +1664,7 @@ class TensorArrayTest(test.TestCase): vdx, vdy = self.evaluate([dx, dy]) self.assertAllClose(vdx, vdy) + @test_util.deprecated_graph_mode_only def testSkipEagerTensorArrayInt64GPU(self): if not test.is_gpu_available(): return