From 0c33e1ff58e121a0cf6acdb6aeb8de53cb3abf25 Mon Sep 17 00:00:00 2001 From: Skye Wanderman-Milne Date: Wed, 16 May 2018 18:03:01 -0700 Subject: [PATCH] Remove _USE_C_API staging in tests now that the C API is enabled by default. This is in preparation for removing the _USE_C_API toggle altogether. PiperOrigin-RevId: 196920481 --- tensorflow/compiler/tests/function_test.py | 2 - tensorflow/contrib/compiler/jit_test.py | 2 - .../python/kernel_tests/bijectors/reshape_test.py | 19 ++------- .../framework/python/framework/tensor_util_test.py | 16 ++------ .../contrib/losses/python/losses/loss_ops_test.py | 9 +---- .../tensorrt/test/tf_trt_integration_test.py | 1 - .../training/batch_sequences_with_states_test.py | 14 ------- .../python/client/session_clusterspec_prop_test.py | 4 +- .../python/client/session_list_devices_test.py | 31 +-------------- .../python/client/session_partial_run_test.py | 29 +------------- tensorflow/python/client/session_test.py | 21 +--------- tensorflow/python/client/virtual_gpu_test.py | 1 - .../python/feature_column/feature_column_test.py | 45 ++++++---------------- .../python/grappler/memory_optimizer_test.py | 3 -- .../python/kernel_tests/distributions/util_test.py | 16 -------- tensorflow/python/layers/convolutional_test.py | 6 --- tensorflow/python/ops/control_flow_ops_test.py | 11 ------ tensorflow/python/ops/gradients_test.py | 12 ------ tensorflow/python/ops/math_ops_test.py | 10 ----- tensorflow/python/ops/nn_batchnorm_test.py | 5 --- tensorflow/python/saved_model/saved_model_test.py | 11 +----- .../python/tools/optimize_for_inference_test.py | 1 - tensorflow/python/training/saver_test.py | 15 -------- tensorflow/python/training/slot_creator_test.py | 2 - 24 files changed, 26 insertions(+), 260 deletions(-) diff --git a/tensorflow/compiler/tests/function_test.py b/tensorflow/compiler/tests/function_test.py index fbc3c99..8a3f4b0 100644 --- a/tensorflow/compiler/tests/function_test.py +++ b/tensorflow/compiler/tests/function_test.py @@ -24,12 +24,10 @@ from tensorflow.compiler.tests.xla_test import XLATestCase from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes from tensorflow.python.framework import function -from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.platform import googletest -@test_util.with_c_api class FunctionTest(XLATestCase): def testFunction(self): diff --git a/tensorflow/contrib/compiler/jit_test.py b/tensorflow/contrib/compiler/jit_test.py index b2f678f..a56a01b 100644 --- a/tensorflow/contrib/compiler/jit_test.py +++ b/tensorflow/contrib/compiler/jit_test.py @@ -24,7 +24,6 @@ from tensorflow.python.framework import function from tensorflow.python.framework import op_def_registry from tensorflow.python.framework import ops from tensorflow.python.framework import random_seed -from tensorflow.python.framework import test_util from tensorflow.python.ops import gradients from tensorflow.python.ops import init_ops from tensorflow.python.ops import math_ops @@ -170,7 +169,6 @@ class JITTest(test.TestCase): self.assertEqual(b"jit_scope_0", func_attrs["_XlaScope"].s) -@test_util.with_c_api class CompilationEnabledInGradientTest(test.TestCase): def testCompilationInGradient(self): diff --git a/tensorflow/contrib/distributions/python/kernel_tests/bijectors/reshape_test.py b/tensorflow/contrib/distributions/python/kernel_tests/bijectors/reshape_test.py index 46f2c63..d44e49b 100644 --- a/tensorflow/contrib/distributions/python/kernel_tests/bijectors/reshape_test.py +++ b/tensorflow/contrib/distributions/python/kernel_tests/bijectors/reshape_test.py @@ -22,15 +22,12 @@ import numpy as np from tensorflow.contrib.distributions.python.ops.bijectors.reshape import Reshape from tensorflow.python.framework import dtypes -from tensorflow.python.framework import ops from tensorflow.python.framework import tensor_shape -from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops.distributions.bijector_test_util import assert_bijective_and_finite from tensorflow.python.platform import test -@test_util.with_c_api class _ReshapeBijectorTest(object): """Base class for testing the reshape transformation. @@ -265,7 +262,6 @@ class _ReshapeBijectorTest(object): raise NotImplementedError("Subclass failed to implement `build_shapes`.") -@test_util.with_c_api class ReshapeBijectorTestStatic(test.TestCase, _ReshapeBijectorTest): def build_shapes(self, shape_in, shape_out): @@ -305,21 +301,13 @@ class ReshapeBijectorTestStatic(test.TestCase, _ReshapeBijectorTest): bijector, x, y, event_ndims=2, rtol=1e-6, atol=0) def testInvalidDimensionsOpError(self): - if ops._USE_C_API: - error_message = "Invalid value in tensor used for shape: -2" - else: - error_message = "elements must be either positive integers or `-1`." - self._testInvalidDimensionsOpError(error_message) + self._testInvalidDimensionsOpError( + "Invalid value in tensor used for shape: -2") def testInputOutputMismatchOpError(self): - if ops._USE_C_API: - error_message = "Cannot reshape a tensor with" - else: - error_message = "Input to reshape is a tensor with" - self._testInputOutputMismatchOpError(error_message) + self._testInputOutputMismatchOpError("Cannot reshape a tensor with") -@test_util.with_c_api class ReshapeBijectorTestDynamic(test.TestCase, _ReshapeBijectorTest): def build_shapes(self, shape_in, shape_out): @@ -341,7 +329,6 @@ class ReshapeBijectorTestDynamic(test.TestCase, _ReshapeBijectorTest): self._testInputOutputMismatchOpError("Input to reshape is a tensor with") -@test_util.with_c_api class ReshapeBijectorTestDynamicNdims(test.TestCase, _ReshapeBijectorTest): def build_shapes(self, shape_in, shape_out): diff --git a/tensorflow/contrib/framework/python/framework/tensor_util_test.py b/tensorflow/contrib/framework/python/framework/tensor_util_test.py index 8fc4f60..af1b404 100644 --- a/tensorflow/contrib/framework/python/framework/tensor_util_test.py +++ b/tensorflow/contrib/framework/python/framework/tensor_util_test.py @@ -78,7 +78,6 @@ class AssertScalarIntTest(test.TestCase): [3, 4], dtype=dtypes.int32)) -@test_util.with_c_api class WithShapeTest(test.TestCase): def _assert_with_shape(self, tensor, expected_value, expected_shape, @@ -216,25 +215,18 @@ class WithShapeTest(test.TestCase): tensor_partial_shape.set_shape([None, 2]) for incompatible_shape in [[0], [1]]: - if ops._USE_C_API: - error_message = "Shapes must be equal rank, but are 2 and 1" - else: - error_message = r"Shapes \(\?, 2\) and \([01],\) are not compatible" self.assertRaisesRegexp( - ValueError, error_message, + ValueError, "Shapes must be equal rank, but are 2 and 1", tensor_util.with_shape, incompatible_shape, tensor_partial_shape) for incompatible_shape in [[1, 2, 1]]: self.assertRaisesRegexp(ValueError, "Dimensions must be equal", tensor_util.with_shape, incompatible_shape, tensor_partial_shape) for incompatible_shape in [[2, 1]]: - if ops._USE_C_API: - error_message = (r"Dimension 1 in both shapes must be equal, but are " - r"2 and 1. Shapes are \[\?,2\] and \[2,1\].") - else: - error_message = r"Shapes \(\?, 2\) and \(2, 1\) are not compatible" self.assertRaisesRegexp( - ValueError, error_message, + ValueError, + r"Dimension 1 in both shapes must be equal, but are 2 and 1. " + r"Shapes are \[\?,2\] and \[2,1\].", tensor_util.with_shape, incompatible_shape, tensor_partial_shape) compatible_shape = [2, 2] diff --git a/tensorflow/contrib/losses/python/losses/loss_ops_test.py b/tensorflow/contrib/losses/python/losses/loss_ops_test.py index 1417772..2a442a8 100644 --- a/tensorflow/contrib/losses/python/losses/loss_ops_test.py +++ b/tensorflow/contrib/losses/python/losses/loss_ops_test.py @@ -24,10 +24,8 @@ from tensorflow.contrib.framework.python.ops import arg_scope from tensorflow.contrib.losses.python.losses import loss_ops from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes -from tensorflow.python.framework import errors_impl from tensorflow.python.framework import ops from tensorflow.python.framework import random_seed -from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import init_ops from tensorflow.python.ops import math_ops @@ -275,7 +273,6 @@ class SoftmaxCrossEntropyLossTest(test.TestCase): self.assertAlmostEqual(np.average(weights) * 10.0, loss, 3) -@test_util.with_c_api class SparseSoftmaxCrossEntropyLossTest(test.TestCase): def testNoneWeightRaisesValueError(self): @@ -473,11 +470,7 @@ class SparseSoftmaxCrossEntropyLossTest(test.TestCase): labels = constant_op.constant([[0, 1], [2, 3]]) weights = constant_op.constant([1.2, 3.4, 5.6, 7.8]) - if ops._USE_C_API: - error_type = ValueError - else: - error_type = errors_impl.InvalidArgumentError - with self.assertRaises(error_type): + with self.assertRaises(ValueError): loss_ops.sparse_softmax_cross_entropy( logits, labels, weights=weights).eval() diff --git a/tensorflow/contrib/tensorrt/test/tf_trt_integration_test.py b/tensorflow/contrib/tensorrt/test/tf_trt_integration_test.py index 7a47328..d426e9f 100644 --- a/tensorflow/contrib/tensorrt/test/tf_trt_integration_test.py +++ b/tensorflow/contrib/tensorrt/test/tf_trt_integration_test.py @@ -34,7 +34,6 @@ from tensorflow.python.ops import nn_ops as nn_ops from tensorflow.python.platform import googletest -@test_util.with_c_api class IntegrationTest(test_util.TensorFlowTestCase): """Class to test Tensorflow-TensorRT integration.""" diff --git a/tensorflow/contrib/training/python/training/batch_sequences_with_states_test.py b/tensorflow/contrib/training/python/training/batch_sequences_with_states_test.py index f305197..df07ff4 100644 --- a/tensorflow/contrib/training/python/training/batch_sequences_with_states_test.py +++ b/tensorflow/contrib/training/python/training/batch_sequences_with_states_test.py @@ -27,7 +27,6 @@ from tensorflow.python.framework import dtypes from tensorflow.python.framework import errors_impl from tensorflow.python.framework import ops from tensorflow.python.framework import sparse_tensor -from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import math_ops from tensorflow.python.ops import random_ops @@ -506,19 +505,6 @@ class BatchSequencesWithStatesTest(test.TestCase): expected_seq4_batch2=expected_seq4_batch2) -class BatchSequencesWithStatesTestWithCApi(BatchSequencesWithStatesTest): - - def setUp(self): - self._prev_value = ops._USE_C_API - ops._USE_C_API = True - super(BatchSequencesWithStatesTestWithCApi, self).setUp() - - def tearDown(self): - super(BatchSequencesWithStatesTestWithCApi, self).tearDown() - ops._USE_C_API = self._prev_value - - -@test_util.with_c_api class PaddingTest(test.TestCase): def testPaddingInvalidLengths(self): diff --git a/tensorflow/python/client/session_clusterspec_prop_test.py b/tensorflow/python/client/session_clusterspec_prop_test.py index f193424..df020f8 100644 --- a/tensorflow/python/client/session_clusterspec_prop_test.py +++ b/tensorflow/python/client/session_clusterspec_prop_test.py @@ -42,7 +42,6 @@ from tensorflow.python.platform import googletest from tensorflow.python.platform import test from tensorflow.python.training import server_lib -ops._USE_C_API = True # NOTE(mrry): Dummy shape registration for ops used in the tests, since they # don't have C++ op registrations on which to attach C++ shape fns. @@ -77,7 +76,7 @@ class SessionClusterSpecPropagationTest(test_util.TensorFlowTestCase): config = config_pb2.ConfigProto(cluster_def=cluster_def) with ops.Graph().as_default() as g, ops.device('/job:worker/task:1'): - with ops.device('/cpu:0'): + with ops.device('/cpu:0'): const = constant_op.constant(17) sess = session.Session(server1.target, config=config, graph=g) run_options = config_pb2.RunOptions( @@ -459,7 +458,6 @@ class SessionClusterSpecPropagationTest(test_util.TensorFlowTestCase): with self.assertRaises(errors.FailedPreconditionError): sess3.run(v) - @test_util.disable_c_api # Partial runs don't work with C API def testClusterSpecPropagationPartialRun(self): """Test successful partial run with ClusterSpec propagation.""" server1 = server_lib.Server.create_local_server() diff --git a/tensorflow/python/client/session_list_devices_test.py b/tensorflow/python/client/session_list_devices_test.py index 38a3acb..c5d82c2 100644 --- a/tensorflow/python/client/session_list_devices_test.py +++ b/tensorflow/python/client/session_list_devices_test.py @@ -30,8 +30,7 @@ from tensorflow.python.platform import googletest from tensorflow.python.training import server_lib -class SessionListDevicesTestMethods(object): - """Mixin with test methods.""" +class SessionListDevicesTest(test_util.TensorFlowTestCase): def testListDevices(self): with session.Session() as sess: @@ -75,33 +74,5 @@ class SessionListDevicesTestMethods(object): '/job:worker/replica:0/task:1/device:CPU:0' in device_names) -class SessionListDevicesTest(SessionListDevicesTestMethods, - test_util.TensorFlowTestCase): - """Test case that invokes test methods with _USE_C_API=False.""" - - def setUp(self): - self.prev_use_c_api = ops._USE_C_API - ops._USE_C_API = False - super(SessionListDevicesTest, self).setUp() - - def tearDown(self): - ops._USE_C_API = self.prev_use_c_api - super(SessionListDevicesTest, self).tearDown() - - -class SessionListDevicesWithCApiTest(SessionListDevicesTestMethods, - test_util.TensorFlowTestCase): - """Test case that invokes test methods with _USE_C_API=True.""" - - def setUp(self): - self.prev_use_c_api = ops._USE_C_API - ops._USE_C_API = True - super(SessionListDevicesWithCApiTest, self).setUp() - - def tearDown(self): - ops._USE_C_API = self.prev_use_c_api - super(SessionListDevicesWithCApiTest, self).tearDown() - - if __name__ == '__main__': googletest.main() diff --git a/tensorflow/python/client/session_partial_run_test.py b/tensorflow/python/client/session_partial_run_test.py index 6a389b0..92ca47e 100644 --- a/tensorflow/python/client/session_partial_run_test.py +++ b/tensorflow/python/client/session_partial_run_test.py @@ -39,7 +39,7 @@ from tensorflow.python.training import server_lib ops.RegisterShape('ConstructionFails')(common_shapes.unknown_shape) -class PartialRunTestMethods(object): +class PartialRunTest(test_util.TensorFlowTestCase): def RunTestPartialRun(self, sess): a = array_ops.placeholder(dtypes.float32, shape=[]) @@ -283,32 +283,5 @@ class PartialRunTestMethods(object): self.RunTestPartialRunEmptyFetches(session.Session(server.target)) -class PartialRunTest(PartialRunTestMethods, test_util.TensorFlowTestCase): - """Test case that invokes test methods with _USE_C_API=False.""" - - def setUp(self): - self.prev_use_c_api = ops._USE_C_API - ops._USE_C_API = False - super(PartialRunTest, self).setUp() - - def tearDown(self): - ops._USE_C_API = self.prev_use_c_api - super(PartialRunTest, self).tearDown() - - -class PartialRunWithCApiTest(PartialRunTestMethods, - test_util.TensorFlowTestCase): - """Test case that invokes test methods with _USE_C_API=True.""" - - def setUp(self): - self.prev_use_c_api = ops._USE_C_API - ops._USE_C_API = True - super(PartialRunWithCApiTest, self).setUp() - - def tearDown(self): - ops._USE_C_API = self.prev_use_c_api - super(PartialRunWithCApiTest, self).tearDown() - - if __name__ == '__main__': googletest.main() diff --git a/tensorflow/python/client/session_test.py b/tensorflow/python/client/session_test.py index 9249727..e9a7d9a 100644 --- a/tensorflow/python/client/session_test.py +++ b/tensorflow/python/client/session_test.py @@ -62,7 +62,6 @@ from tensorflow.python.util import compat ops.RegisterShape('ConstructionFails')(common_shapes.unknown_shape) -@test_util.with_c_api class SessionTest(test_util.TensorFlowTestCase): def setUp(self): @@ -173,21 +172,6 @@ class SessionTest(test_util.TensorFlowTestCase): # Run with a bogus handle. s.partial_run('foo', r1, feed_dict={a: 1, b: 2}) - def testOpConstructionErrorPayload(self): - if ops._USE_C_API: - return # No shape registration for 'ConstructionFails' - - with session.Session(): - failing_op = ops.get_default_graph().create_op( - 'ConstructionFails', [], [], name='f') - - def exc_predicate(e): - return (e.op == failing_op and - e.error_code == error_codes_pb2.INVALID_ARGUMENT) - - with self.assertRaisesOpError(exc_predicate): - failing_op.run() - def testErrorBasedOn(self): with session.Session() as sess: a = constant_op.constant(0.0, shape=[2, 3]) @@ -1084,10 +1068,7 @@ class SessionTest(test_util.TensorFlowTestCase): if gdef is None: gdef = graph.as_graph_def() else: - # NOTE(skyewm): import_graph_def breaks the running threads without - # the C API enabled. This is not a regression so I didn't fix it. - if ops._USE_C_API: - importer.import_graph_def(gdef, name='import') + importer.import_graph_def(gdef, name='import') stop.set() for t in threads: diff --git a/tensorflow/python/client/virtual_gpu_test.py b/tensorflow/python/client/virtual_gpu_test.py index ae653e0..52e1b56 100644 --- a/tensorflow/python/client/virtual_gpu_test.py +++ b/tensorflow/python/client/virtual_gpu_test.py @@ -192,7 +192,6 @@ class VirtualGpuTestUtil(object): return True -@test_util.with_c_api class VirtualGpuTest(test_util.TensorFlowTestCase): def __init__(self, method_name): diff --git a/tensorflow/python/feature_column/feature_column_test.py b/tensorflow/python/feature_column/feature_column_test.py index 03c47ee..f9206f4 100644 --- a/tensorflow/python/feature_column/feature_column_test.py +++ b/tensorflow/python/feature_column/feature_column_test.py @@ -1284,7 +1284,6 @@ def get_keras_linear_model_predictions(features, return retval -@test_util.with_c_api class LinearModelTest(test.TestCase): def test_raises_if_empty_feature_columns(self): @@ -1560,16 +1559,10 @@ class LinearModelTest(test.TestCase): price = fc.numeric_column('price', shape=2) with ops.Graph().as_default(): features = {'price': [[1.], [5.]]} - if ops._USE_C_API: - with self.assertRaisesRegexp( - Exception, - r'Cannot reshape a tensor with 2 elements to shape \[2,2\]'): - predictions = fc.linear_model(features, [price]) - else: - predictions = fc.linear_model(features, [price]) - with _initialized_session(): - with self.assertRaisesRegexp(Exception, 'requested shape has 4'): - predictions.eval() + with self.assertRaisesRegexp( + Exception, + r'Cannot reshape a tensor with 2 elements to shape \[2,2\]'): + fc.linear_model(features, [price]) def test_dense_reshaping(self): price = fc.numeric_column('price', shape=[1, 2]) @@ -1933,7 +1926,6 @@ class LinearModelTest(test.TestCase): sess.run(net, feed_dict={features['price']: np.array(1)}) -@test_util.with_c_api class _LinearModelTest(test.TestCase): def test_raises_if_empty_feature_columns(self): @@ -2198,16 +2190,10 @@ class _LinearModelTest(test.TestCase): price = fc.numeric_column('price', shape=2) with ops.Graph().as_default(): features = {'price': [[1.], [5.]]} - if ops._USE_C_API: - with self.assertRaisesRegexp( - Exception, - r'Cannot reshape a tensor with 2 elements to shape \[2,2\]'): - predictions = get_keras_linear_model_predictions(features, [price]) - else: - predictions = get_keras_linear_model_predictions(features, [price]) - with _initialized_session(): - with self.assertRaisesRegexp(Exception, 'requested shape has 4'): - predictions.eval() + with self.assertRaisesRegexp( + Exception, + r'Cannot reshape a tensor with 2 elements to shape \[2,2\]'): + get_keras_linear_model_predictions(features, [price]) def test_dense_reshaping(self): price = fc.numeric_column('price', shape=[1, 2]) @@ -2694,7 +2680,6 @@ class InputLayerTest(test.TestCase): self.assertAllEqual([[2, 2], [2, 2], [2, 2]], gradient) -@test_util.with_c_api class FunctionalInputLayerTest(test.TestCase): def test_raises_if_empty_feature_columns(self): @@ -2759,16 +2744,10 @@ class FunctionalInputLayerTest(test.TestCase): price = fc.numeric_column('price', shape=2) with ops.Graph().as_default(): features = {'price': [[1.], [5.]]} - if ops._USE_C_API: - with self.assertRaisesRegexp( - Exception, - r'Cannot reshape a tensor with 2 elements to shape \[2,2\]'): - net = fc.input_layer(features, [price]) - else: - net = fc.input_layer(features, [price]) - with _initialized_session(): - with self.assertRaisesRegexp(Exception, 'requested shape has 4'): - net.eval() + with self.assertRaisesRegexp( + Exception, + r'Cannot reshape a tensor with 2 elements to shape \[2,2\]'): + fc.input_layer(features, [price]) def test_reshaping(self): price = fc.numeric_column('price', shape=[1, 2]) diff --git a/tensorflow/python/grappler/memory_optimizer_test.py b/tensorflow/python/grappler/memory_optimizer_test.py index 3f9d886..7ed4b12 100644 --- a/tensorflow/python/grappler/memory_optimizer_test.py +++ b/tensorflow/python/grappler/memory_optimizer_test.py @@ -25,7 +25,6 @@ from tensorflow.python.client import session from tensorflow.python.framework import meta_graph from tensorflow.python.framework import ops from tensorflow.python.framework import random_seed -from tensorflow.python.framework import test_util from tensorflow.python.grappler import tf_optimizer from tensorflow.python.ops import math_ops from tensorflow.python.ops import nn @@ -35,7 +34,6 @@ from tensorflow.python.platform import test from tensorflow.python.training import training as train -@test_util.with_c_api class MemoryOptimizerSwapTest(test.TestCase): """Tests the Grappler memory optimizer.""" @@ -96,7 +94,6 @@ class MemoryOptimizerSwapTest(test.TestCase): self.assertEqual('c', node.input[1]) -@test_util.with_c_api class MemoryOptimizerRecomputeTest(test.TestCase): """Tests the Python interface to recomputation rewrites. diff --git a/tensorflow/python/kernel_tests/distributions/util_test.py b/tensorflow/python/kernel_tests/distributions/util_test.py index 8569b36..87966a6 100644 --- a/tensorflow/python/kernel_tests/distributions/util_test.py +++ b/tensorflow/python/kernel_tests/distributions/util_test.py @@ -25,7 +25,6 @@ import numpy as np from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes from tensorflow.python.framework import ops -from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import gradient_checker from tensorflow.python.ops import gradients_impl @@ -56,7 +55,6 @@ def _logit(x): return np.log(x) - np.log1p(-x) -@test_util.with_c_api class AssertCloseTest(test.TestCase): def testAssertCloseIntegerDtype(self): @@ -173,7 +171,6 @@ class MaybeGetStaticTest(test.TestCase): self.assertEqual(None, du.maybe_get_static_value(x, dtype=np.float64)) -@test_util.with_c_api class GetLogitsAndProbsTest(test.TestCase): def testImproperArguments(self): @@ -327,7 +324,6 @@ class GetLogitsAndProbsTest(test.TestCase): logit.eval(feed_dict={l: np.ones([int(2**11+1)])}) -@test_util.with_c_api class EmbedCheckCategoricalEventShapeTest(test.TestCase): def testTooSmall(self): @@ -365,7 +361,6 @@ class EmbedCheckCategoricalEventShapeTest(test.TestCase): du.embed_check_categorical_event_shape(param) -@test_util.with_c_api class EmbedCheckIntegerCastingClosedTest(test.TestCase): def testCorrectlyAssertsNonnegative(self): @@ -401,7 +396,6 @@ class EmbedCheckIntegerCastingClosedTest(test.TestCase): x_checked.eval(feed_dict={x: np.array([1, -1], dtype=np.int32)}) -@test_util.with_c_api class LogCombinationsTest(test.TestCase): def testLogCombinationsBinomial(self): @@ -432,7 +426,6 @@ class LogCombinationsTest(test.TestCase): self.assertEqual([2, 2], log_binom.get_shape()) -@test_util.with_c_api class DynamicShapeTest(test.TestCase): def testSameDynamicShape(self): @@ -537,7 +530,6 @@ class DynamicShapeTest(test.TestCase): })) -@test_util.with_c_api class RotateTransposeTest(test.TestCase): def _np_rotate_transpose(self, x, shift): @@ -571,7 +563,6 @@ class RotateTransposeTest(test.TestCase): shift: shift_value})) -@test_util.with_c_api class PickVectorTest(test.TestCase): def testCorrectlyPicksVector(self): @@ -592,7 +583,6 @@ class PickVectorTest(test.TestCase): constant_op.constant(False), x, y)) # No eval. -@test_util.with_c_api class PreferStaticRankTest(test.TestCase): def testNonEmptyConstantTensor(self): @@ -632,7 +622,6 @@ class PreferStaticRankTest(test.TestCase): self.assertAllEqual(0, rank.eval(feed_dict={x: 1})) -@test_util.with_c_api class PreferStaticShapeTest(test.TestCase): def testNonEmptyConstantTensor(self): @@ -672,7 +661,6 @@ class PreferStaticShapeTest(test.TestCase): self.assertAllEqual(np.array([]), shape.eval(feed_dict={x: 1})) -@test_util.with_c_api class PreferStaticValueTest(test.TestCase): def testNonEmptyConstantTensor(self): @@ -713,7 +701,6 @@ class PreferStaticValueTest(test.TestCase): self.assertAllEqual(np.array(1), value.eval(feed_dict={x: 1})) -@test_util.with_c_api class FillTriangularTest(test.TestCase): def setUp(self): @@ -808,7 +795,6 @@ class FillTriangularTest(test.TestCase): self._run_test(self._rng.randn(2, 3, int(7*8/2)), upper=True) -@test_util.with_c_api class ReduceWeightedLogSumExp(test.TestCase): def _reduce_weighted_logsumexp(self, logx, w, axis, keep_dims=False): @@ -905,7 +891,6 @@ class ReduceWeightedLogSumExp(test.TestCase): du.reduce_weighted_logsumexp(x, w, axis=[0, 1]).eval()) -@test_util.with_c_api class GenNewSeedTest(test.TestCase): def testOnlyNoneReturnsNone(self): @@ -916,7 +901,6 @@ class GenNewSeedTest(test.TestCase): # TODO(jvdillon): Merge this test back into: # tensorflow/python/kernel_tests/softplus_op_test.py # once TF core is accepting new ops. -@test_util.with_c_api class SoftplusTest(test.TestCase): def _npSoftplus(self, np_features): diff --git a/tensorflow/python/layers/convolutional_test.py b/tensorflow/python/layers/convolutional_test.py index cdb42f5..625320b 100644 --- a/tensorflow/python/layers/convolutional_test.py +++ b/tensorflow/python/layers/convolutional_test.py @@ -22,7 +22,6 @@ import numpy as np from tensorflow.python.framework import dtypes from tensorflow.python.framework import ops -from tensorflow.python.framework import test_util from tensorflow.python.layers import convolutional as conv_layers from tensorflow.python.ops import array_ops from tensorflow.python.ops import init_ops @@ -34,7 +33,6 @@ from tensorflow.python.ops import variables from tensorflow.python.platform import test -@test_util.with_c_api class ConvTest(test.TestCase): def testInvalidDataFormat(self): @@ -332,7 +330,6 @@ class ConvTest(test.TestCase): conv_layers.conv3d(images, 32, 9, data_format='channels_first') -@test_util.with_c_api class SeparableConv1DTest(test.TestCase): def testInvalidDataFormat(self): @@ -494,7 +491,6 @@ class SeparableConv1DTest(test.TestCase): self.assertEqual(layer.bias_constraint, b_constraint) -@test_util.with_c_api class SeparableConv2DTest(test.TestCase): def testInvalidDataFormat(self): @@ -738,7 +734,6 @@ class SeparableConv2DTest(test.TestCase): self.assertEqual(layer.bias_constraint, b_constraint) -@test_util.with_c_api class Conv2DTransposeTest(test.TestCase): def testInvalidDataFormat(self): @@ -924,7 +919,6 @@ class Conv2DTransposeTest(test.TestCase): self.assertEqual(layer.bias_constraint, b_constraint) -@test_util.with_c_api class Conv3DTransposeTest(test.TestCase): def testInvalidDataFormat(self): diff --git a/tensorflow/python/ops/control_flow_ops_test.py b/tensorflow/python/ops/control_flow_ops_test.py index 289df6f..59bb925 100644 --- a/tensorflow/python/ops/control_flow_ops_test.py +++ b/tensorflow/python/ops/control_flow_ops_test.py @@ -51,7 +51,6 @@ TestTuple = collections.namedtuple("TestTuple", "a b") SingletonTestTuple = collections.namedtuple("SingletonTestTuple", "a") -@test_util.with_c_api class GroupTestCase(test_util.TensorFlowTestCase): def _StripNode(self, nd): @@ -133,7 +132,6 @@ class GroupTestCase(test_util.TensorFlowTestCase): control_flow_ops.group(1, 2) -@test_util.with_c_api class ShapeTestCase(test_util.TensorFlowTestCase): def testShape(self): @@ -145,7 +143,6 @@ class ShapeTestCase(test_util.TensorFlowTestCase): [constant_op.constant(1.0)], tensor).get_shape()) -@test_util.with_c_api class WithDependenciesTestCase(test_util.TensorFlowTestCase): def testTupleDependencies(self): @@ -177,7 +174,6 @@ class WithDependenciesTestCase(test_util.TensorFlowTestCase): self.assertEquals(1, counter.eval()) -@test_util.with_c_api class SwitchTestCase(test_util.TensorFlowTestCase): def testIndexedSlicesWithDenseShape(self): @@ -349,12 +345,9 @@ class SwitchTestCase(test_util.TensorFlowTestCase): self.assertEquals(grad_x_false.eval(), 0.) -@test_util.with_c_api class CondTest(test_util.TensorFlowTestCase): def testCondTrue(self): - # Create new Graph and Session for each test so we pick up _USE_C_API - # correctly. with ops.Graph().as_default(): with session.Session(): x = constant_op.constant(2) @@ -438,7 +431,6 @@ class CondTest(test_util.TensorFlowTestCase): control_flow_ops.cond(True, lambda: x, lambda: x, fn2=lambda: x) -@test_util.with_c_api class ContextTest(test_util.TensorFlowTestCase): def testCondContext(self): @@ -535,7 +527,6 @@ def _raw_nested_shape(nested_shape): # TODO(yori): Add tests for indexed slices. -@test_util.with_c_api class DataTypesTest(test_util.TensorFlowTestCase): def assertAllEqualNested(self, a, b): @@ -885,7 +876,6 @@ class DataTypesTest(test_util.TensorFlowTestCase): self.assertEqual(matrix.get_shape(), tensor_shape.TensorShape([2, 2])) -@test_util.with_c_api class CaseTest(test_util.TensorFlowTestCase): def testCase_withDefault(self): @@ -947,7 +937,6 @@ class CaseTest(test_util.TensorFlowTestCase): sess.run(output, feed_dict={x: 4}) -@test_util.with_c_api class WhileLoopTestCase(test_util.TensorFlowTestCase): @test_util.run_in_graph_and_eager_modes() diff --git a/tensorflow/python/ops/gradients_test.py b/tensorflow/python/ops/gradients_test.py index e729950..096d0ce 100644 --- a/tensorflow/python/ops/gradients_test.py +++ b/tensorflow/python/ops/gradients_test.py @@ -289,10 +289,6 @@ class GradientsTest(test_util.TensorFlowTestCase): self.assertEqual(10.0, grads[1].eval()) def testNoGradientForStringOutputs(self): - # This test can't be run twice because the TestStringOutput gradient can - # only be registered once. Just run with the C API enabled. - if not ops._USE_C_API: return - with ops.Graph().as_default(): def _TestOpGrad(_, float_grad, string_grad): @@ -438,7 +434,6 @@ class GradientsTest(test_util.TensorFlowTestCase): np.testing.assert_allclose(a, b) -@test_util.with_c_api class FunctionGradientsTest(test_util.TensorFlowTestCase): @classmethod @@ -528,7 +523,6 @@ class FunctionGradientsTest(test_util.TensorFlowTestCase): f.add_to_graph(ops.Graph()) -@test_util.with_c_api class StopGradientTest(test_util.TensorFlowTestCase): def testStopGradient(self): @@ -539,7 +533,6 @@ class StopGradientTest(test_util.TensorFlowTestCase): assert igrad is None -@test_util.with_c_api class PreventGradientTest(test_util.TensorFlowTestCase): def testPreventGradient(self): @@ -550,7 +543,6 @@ class PreventGradientTest(test_util.TensorFlowTestCase): _ = gradients.gradients(out, inp) -@test_util.with_c_api class HessianVectorProductTest(test_util.TensorFlowTestCase): def testHessianVectorProduct(self): @@ -579,7 +571,6 @@ class HessianVectorProductTest(test_util.TensorFlowTestCase): self.assertAllClose(hess_v_value, hess_v_actual) -@test_util.with_c_api class HessianTest(test_util.TensorFlowTestCase): def testHessian1D(self): @@ -668,7 +659,6 @@ class HessianTest(test_util.TensorFlowTestCase): self.assertAllClose(hess_value, hess_actual.reshape((m * n, m * n))) -@test_util.with_c_api class IndexedSlicesToTensorTest(test_util.TensorFlowTestCase): def testIndexedSlicesToTensor(self): @@ -749,7 +739,6 @@ class IndexedSlicesToTensorTest(test_util.TensorFlowTestCase): str(w[0].message)) -@test_util.with_c_api class OnlyRealGradientsTest(test_util.TensorFlowTestCase): def testRealOnly(self): @@ -786,7 +775,6 @@ class ResourceCondTest(test_util.TensorFlowTestCase): self.assertTrue(None not in grads) -@test_util.with_c_api class CustomGradientTest(test_util.TensorFlowTestCase): def testCustomGradientTrivial(self): diff --git a/tensorflow/python/ops/math_ops_test.py b/tensorflow/python/ops/math_ops_test.py index 05bcee8..980c92b 100644 --- a/tensorflow/python/ops/math_ops_test.py +++ b/tensorflow/python/ops/math_ops_test.py @@ -35,7 +35,6 @@ exp = np.exp log = np.log -@test_util.with_c_api class ReduceTest(test_util.TensorFlowTestCase): @test_util.run_in_graph_and_eager_modes() @@ -70,7 +69,6 @@ class ReduceTest(test_util.TensorFlowTestCase): math_ops.reduce_sum(x, axis) -@test_util.with_c_api class LogSumExpTest(test_util.TensorFlowTestCase): def testReduceLogSumExp(self): @@ -150,7 +148,6 @@ class LogSumExpTest(test_util.TensorFlowTestCase): self.assertEqual(-np.inf, res) -@test_util.with_c_api class RoundTest(test_util.TensorFlowTestCase): @test_util.run_in_graph_and_eager_modes() @@ -166,7 +163,6 @@ class RoundTest(test_util.TensorFlowTestCase): self.assertAllClose(y_tf_np, y_np, atol=1e-2) -@test_util.with_c_api class ModTest(test_util.TensorFlowTestCase): def testFloat(self): @@ -196,7 +192,6 @@ class ModTest(test_util.TensorFlowTestCase): self.assertAllClose(y_tf_np, y_np) -@test_util.with_c_api class SquaredDifferenceTest(test_util.TensorFlowTestCase): @test_util.run_in_graph_and_eager_modes() @@ -210,7 +205,6 @@ class SquaredDifferenceTest(test_util.TensorFlowTestCase): self.assertAllClose(z, z_tf) -@test_util.with_c_api class ApproximateEqualTest(test_util.TensorFlowTestCase): @test_util.run_in_graph_and_eager_modes() @@ -242,7 +236,6 @@ class ApproximateEqualTest(test_util.TensorFlowTestCase): self.assertAllEqual(z, z_tf) -@test_util.with_c_api class ScalarMulTest(test_util.TensorFlowTestCase): @test_util.run_in_graph_and_eager_modes() @@ -284,7 +277,6 @@ class ScalarMulTest(test_util.TensorFlowTestCase): self.assertAllEqual(self.evaluate(x.indices), [0, 2, 5]) -@test_util.with_c_api class AccumulateNTest(test_util.TensorFlowTestCase): def testFloat(self): @@ -304,7 +296,6 @@ class AccumulateNTest(test_util.TensorFlowTestCase): self.assertAllEqual(x[0] * 6, math_ops.accumulate_n([tf_x[0]] * 6).eval()) -@test_util.with_c_api class AddNTest(test_util.TensorFlowTestCase): def testPartials(self): @@ -358,7 +349,6 @@ class AddNTest(test_util.TensorFlowTestCase): [g.eval() for g in add_n_grad]) -@test_util.with_c_api class DivAndModTest(test_util.TensorFlowTestCase): # TODO(aselle): Test more types before exposing new division operators. diff --git a/tensorflow/python/ops/nn_batchnorm_test.py b/tensorflow/python/ops/nn_batchnorm_test.py index 1508ff4..7d6dd3f 100644 --- a/tensorflow/python/ops/nn_batchnorm_test.py +++ b/tensorflow/python/ops/nn_batchnorm_test.py @@ -35,7 +35,6 @@ import tensorflow.python.ops.nn_grad # pylint: disable=unused-import from tensorflow.python.platform import test -@test_util.with_c_api class BatchNormalizationTest(test.TestCase): def _npBatchNorm(self, x, m, v, beta, gamma, epsilon, @@ -341,7 +340,6 @@ class BatchNormalizationTest(test.TestCase): param_dtype=dtypes.float32, atol=0.001) -@test_util.with_c_api class SufficientStatisticsTest(test.TestCase): def _npSuffStats(self, x, axes, shift, keep_dims): @@ -401,7 +399,6 @@ class SufficientStatisticsTest(test.TestCase): self._testSuffStats([1, 2, 3], [0, 2], shift, keep_dims, has_shape) -@test_util.with_c_api class NormalizeMomentsTest(test.TestCase): def _npNormalizeMoments(self, counts, mean_ss, variance_ss, shift): @@ -445,7 +442,6 @@ class NormalizeMomentsTest(test.TestCase): self._testNormalizeMoments([2, 3], shift) -@test_util.with_c_api class MomentsTest(test.TestCase): def _unweighted_moments(self, x, axes, keep_dims=False, extra_out_grads=None): @@ -583,7 +579,6 @@ class MomentsTest(test.TestCase): self._testGlobalGradient(from_y="var") -@test_util.with_c_api class WeightedMomentsTest(MomentsTest): """Tests for nn.weighted_moments. diff --git a/tensorflow/python/saved_model/saved_model_test.py b/tensorflow/python/saved_model/saved_model_test.py index a4d994f..1b83d60 100644 --- a/tensorflow/python/saved_model/saved_model_test.py +++ b/tensorflow/python/saved_model/saved_model_test.py @@ -53,12 +53,9 @@ def tearDownModule(): file_io.delete_recursively(test.get_temp_dir()) -@test_util.with_c_api class SavedModelTest(test.TestCase): def _get_export_dir(self, label): - if ops._USE_C_API: - label += "_c_api" return os.path.join(test.get_temp_dir(), label) def _init_and_validate_variable(self, sess, variable_name, variable_value): @@ -1118,12 +1115,8 @@ class SavedModelTest(test.TestCase): # does not have any attr values for the "TestAttr" node, and there is no # default specified in the TestAttr OpDef. sess = session.Session(graph=ops.Graph()) - if ops._USE_C_API: - error_message = "NodeDef missing attr 'T' from Op= mtimes[0]) -@test_util.with_c_api class ScopedGraphTest(test.TestCase): def _get_test_dir(self, dirname): @@ -2976,7 +2962,6 @@ class MyModel(training.Model): return ret -@test_util.with_c_api class CheckpointableCompatibilityTests(test.TestCase): # TODO(allenl): Track down python3 reference cycles in these tests. diff --git a/tensorflow/python/training/slot_creator_test.py b/tensorflow/python/training/slot_creator_test.py index b0f48e4..08a3c8d 100644 --- a/tensorflow/python/training/slot_creator_test.py +++ b/tensorflow/python/training/slot_creator_test.py @@ -21,7 +21,6 @@ from __future__ import print_function from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes from tensorflow.python.framework import ops -from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import random_ops from tensorflow.python.ops import variable_scope @@ -30,7 +29,6 @@ from tensorflow.python.platform import test from tensorflow.python.training import slot_creator -@test_util.with_c_api class SlotCreatorTest(test.TestCase): def testCreateSlotFromVariable(self): -- 2.7.4