aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Skye Wanderman-Milne <skyewm@google.com>2018-05-16 18:05:52 -0700
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2018-05-16 18:09:22 -0700
commitd335efbaac98bfa974eea77bbc63d56101031477 (patch)
treef17207d89b4d06137a60f6f129a29d3b514bbf92
parent0c33e1ff58e121a0cf6acdb6aeb8de53cb3abf25 (diff)
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: 196920890
-rw-r--r--tensorflow/contrib/distribute/python/mirrored_strategy_multigpu_test.py1
-rw-r--r--tensorflow/contrib/distribute/python/mirrored_strategy_test.py2
-rw-r--r--tensorflow/contrib/distribute/python/multi_worker_strategy_test.py2
-rw-r--r--tensorflow/contrib/distribute/python/one_device_strategy_test.py1
-rw-r--r--tensorflow/contrib/distribute/python/shared_variable_creator_test.py1
-rw-r--r--tensorflow/contrib/distribute/python/values_test.py6
-rw-r--r--tensorflow/python/framework/function_test.py14
-rw-r--r--tensorflow/python/framework/importer_test.py235
-rw-r--r--tensorflow/python/framework/meta_graph_test.py4
-rw-r--r--tensorflow/python/framework/op_def_library_test.py2
-rw-r--r--tensorflow/python/framework/ops_test.py248
-rw-r--r--tensorflow/python/framework/smart_cond_test.py9
-rw-r--r--tensorflow/python/framework/subscribe_test.py1
-rw-r--r--tensorflow/python/framework/test_util_test.py2
-rw-r--r--tensorflow/python/kernel_tests/array_ops_test.py16
-rw-r--r--tensorflow/python/kernel_tests/control_flow_ops_py_test.py7
-rw-r--r--tensorflow/python/kernel_tests/large_concat_op_test.py2
-rw-r--r--tensorflow/python/kernel_tests/resource_variable_ops_test.py1
-rw-r--r--tensorflow/python/kernel_tests/scalar_test.py1
-rw-r--r--tensorflow/python/kernel_tests/softmax_op_test.py2
20 files changed, 107 insertions, 450 deletions
diff --git a/tensorflow/contrib/distribute/python/mirrored_strategy_multigpu_test.py b/tensorflow/contrib/distribute/python/mirrored_strategy_multigpu_test.py
index 04d30860c4..3f9a02b249 100644
--- a/tensorflow/contrib/distribute/python/mirrored_strategy_multigpu_test.py
+++ b/tensorflow/contrib/distribute/python/mirrored_strategy_multigpu_test.py
@@ -119,7 +119,6 @@ class MirroredTwoDeviceDistributionTest(strategy_test_lib.DistributionTestBase):
self.assertEqual(expected, self.evaluate(unwrapped[0]))
-@test_util.with_c_api
class MirroredStrategyVariableCreationTest(test.TestCase):
config = config_pb2.ConfigProto()
diff --git a/tensorflow/contrib/distribute/python/mirrored_strategy_test.py b/tensorflow/contrib/distribute/python/mirrored_strategy_test.py
index a1ef0ecc77..61cbe6df81 100644
--- a/tensorflow/contrib/distribute/python/mirrored_strategy_test.py
+++ b/tensorflow/contrib/distribute/python/mirrored_strategy_test.py
@@ -27,7 +27,6 @@ from tensorflow.python.ops import variable_scope
from tensorflow.python.training import distribute as distribute_lib
-@test_util.with_c_api
class MirroredOneCPUDistributionTest(strategy_test_lib.DistributionTestBase):
def _get_distribution_strategy(self):
@@ -53,7 +52,6 @@ class MirroredOneCPUDistributionTest(strategy_test_lib.DistributionTestBase):
self._test_call_and_merge_exceptions(self._get_distribution_strategy())
-@test_util.with_c_api
class VariableCreatorStackTest(test.TestCase):
def testCreatorStacksAreThreadLocal(self):
diff --git a/tensorflow/contrib/distribute/python/multi_worker_strategy_test.py b/tensorflow/contrib/distribute/python/multi_worker_strategy_test.py
index ee7588163e..09c859b32a 100644
--- a/tensorflow/contrib/distribute/python/multi_worker_strategy_test.py
+++ b/tensorflow/contrib/distribute/python/multi_worker_strategy_test.py
@@ -25,11 +25,9 @@ from tensorflow.python.eager import context
from tensorflow.python.eager import test
from tensorflow.python.framework import constant_op
from tensorflow.python.framework import ops
-from tensorflow.python.framework import test_util
from tensorflow.python.training import server_lib
-@test_util.with_c_api
class MultiWorkerStrategyTest(multi_worker_test_base.MultiWorkerTestBase,
strategy_test_lib.DistributionTestBase):
diff --git a/tensorflow/contrib/distribute/python/one_device_strategy_test.py b/tensorflow/contrib/distribute/python/one_device_strategy_test.py
index 7101ed0756..7aad8a953c 100644
--- a/tensorflow/contrib/distribute/python/one_device_strategy_test.py
+++ b/tensorflow/contrib/distribute/python/one_device_strategy_test.py
@@ -24,7 +24,6 @@ from tensorflow.python.eager import test
from tensorflow.python.framework import test_util
-@test_util.with_c_api
class OneDeviceStrategyTest(strategy_test_lib.DistributionTestBase):
def _get_distribution_strategy(self):
diff --git a/tensorflow/contrib/distribute/python/shared_variable_creator_test.py b/tensorflow/contrib/distribute/python/shared_variable_creator_test.py
index 713494d603..a0b452fc2d 100644
--- a/tensorflow/contrib/distribute/python/shared_variable_creator_test.py
+++ b/tensorflow/contrib/distribute/python/shared_variable_creator_test.py
@@ -44,7 +44,6 @@ class CanonicalizeVariableNameTest(test.TestCase):
self.assertEquals("foo_a", self._canonicalize("foo_a"))
-@test_util.with_c_api
class SharedVariableCreatorTest(test.TestCase):
@test_util.run_in_graph_and_eager_modes()
diff --git a/tensorflow/contrib/distribute/python/values_test.py b/tensorflow/contrib/distribute/python/values_test.py
index 9aeef9fa3e..1c95758d96 100644
--- a/tensorflow/contrib/distribute/python/values_test.py
+++ b/tensorflow/contrib/distribute/python/values_test.py
@@ -42,7 +42,6 @@ from tensorflow.python.training import saver as saver_lib
from tensorflow.python.util import nest
-@test_util.with_c_api
class DistributedValuesTest(test.TestCase):
def testGetEager(self):
@@ -81,7 +80,6 @@ class DistributedValuesTest(test.TestCase):
v = values.DistributedValues({"/device:cpu:0": 42})
-@test_util.with_c_api
class DistributedDelegateTest(test.TestCase):
@test_util.run_in_graph_and_eager_modes()
@@ -164,7 +162,6 @@ def _make_mirrored():
return v, devices, mirrored
-@test_util.with_c_api
class RegroupAndSelectDeviceTest(test.TestCase):
def _is_per_device(self, result, expected, klass=values.PerDevice):
@@ -317,7 +314,6 @@ class RegroupAndSelectDeviceTest(test.TestCase):
merged_estimator_spec))
-@test_util.with_c_api
class PerDeviceDatasetTest(test.TestCase):
config = config_pb2.ConfigProto()
@@ -564,7 +560,6 @@ class MultiWorkerDatasetTest(multi_worker_test_base.MultiWorkerTestBase):
multi_worker_iterator.get_next()
-@test_util.with_c_api
class MirroredVariableTest(test.TestCase):
config = config_pb2.ConfigProto()
@@ -741,7 +736,6 @@ def _make_tower_local(method):
return v, tower_local
-@test_util.with_c_api
class TowerLocalVariableTest(test.TestCase):
config = config_pb2.ConfigProto()
diff --git a/tensorflow/python/framework/function_test.py b/tensorflow/python/framework/function_test.py
index 124b1e85f6..88f6a36676 100644
--- a/tensorflow/python/framework/function_test.py
+++ b/tensorflow/python/framework/function_test.py
@@ -813,17 +813,11 @@ class FunctionTest(test.TestCase):
def Foo(x, y, z):
return math_ops.tanh(math_ops.matmul(x, y) + z)
- # We added more randomness to function names in C API.
- # TODO(iga): Remove this if statement when we switch to C API.
- if ops._USE_C_API: # pylint: disable=protected-access
- if sys.byteorder == "big":
- self.assertEqual("Foo_kEdkAG8SJvg",
- Foo.instantiate([dtypes.float32] * 3).name)
- else:
- self.assertEqual("Foo_aCYSbwBkR5A",
- Foo.instantiate([dtypes.float32] * 3).name)
+ if sys.byteorder == "big":
+ self.assertEqual("Foo_kEdkAG8SJvg",
+ Foo.instantiate([dtypes.float32] * 3).name)
else:
- self.assertEqual("Foo_d643acf7",
+ self.assertEqual("Foo_aCYSbwBkR5A",
Foo.instantiate([dtypes.float32] * 3).name)
def testSignatureHash(self):
diff --git a/tensorflow/python/framework/importer_test.py b/tensorflow/python/framework/importer_test.py
index 2c913d1e02..c5a54470d2 100644
--- a/tensorflow/python/framework/importer_test.py
+++ b/tensorflow/python/framework/importer_test.py
@@ -31,7 +31,6 @@ from tensorflow.python.framework import function
from tensorflow.python.framework import importer
from tensorflow.python.framework import ops
from tensorflow.python.framework import test_ops # pylint: disable=unused-import
-from tensorflow.python.framework import test_util
from tensorflow.python.framework import versions
from tensorflow.python.ops import array_ops
from tensorflow.python.ops import control_flow_ops
@@ -45,7 +44,6 @@ import tensorflow.python.ops.nn_grad # pylint: disable=unused-import
from tensorflow.python.platform import test
-@test_util.with_c_api
class ImportGraphDefTest(test.TestCase):
def _MakeGraphDef(self,
@@ -231,10 +229,7 @@ class ImportGraphDefTest(test.TestCase):
return_elements=["foo"],
name="")
- if ops._USE_C_API:
- self.assertEqual(op.name, "foo")
- else:
- self.assertEqual(op.name, "foo_1")
+ self.assertEqual(op.name, "foo")
def testInputMap(self):
with ops.Graph().as_default():
@@ -425,14 +420,9 @@ class ImportGraphDefTest(test.TestCase):
self.assertEqual(sess.run(imported_r), 10)
def testTypeMismatchInGraphDef(self):
- if ops._USE_C_API:
- # TODO(skyewm): improve error message
- error_msg = ("Input 0 of node import/B was passed int32 from import/A:0 "
- "incompatible with expected float.")
- else:
- error_msg = ("Cannot convert a tensor of type int32 to an input of type "
- "float")
-
+ # TODO(skyewm): improve error message
+ error_msg = ("Input 0 of node import/B was passed int32 from import/A:0 "
+ "incompatible with expected float.")
with ops.Graph().as_default():
with self.assertRaisesRegexp(ValueError, error_msg):
importer.import_graph_def(
@@ -476,14 +466,11 @@ class ImportGraphDefTest(test.TestCase):
"Shapes () and (43,) are not compatible" in str(e.exception))
def testInvalidSignatureTooManyInputsInGraphDef(self):
- if ops._USE_C_API:
- # TODO(skyewm): improve error message
- error_msg = "NodeDef expected inputs '' do not match 1 inputs specified"
- else:
- error_msg = r"More inputs specified \('A:0'\) than the op expects"
-
with ops.Graph().as_default():
- with self.assertRaisesRegexp(ValueError, error_msg):
+ # TODO(skyewm): improve error message
+ with self.assertRaisesRegexp(
+ ValueError,
+ "NodeDef expected inputs '' do not match 1 inputs specified"):
importer.import_graph_def(
self._MakeGraphDef("""
node { name: 'A' op: 'IntOutput' }
@@ -491,16 +478,12 @@ class ImportGraphDefTest(test.TestCase):
"""))
def testInvalidSignatureNotEnoughInputsInGraphDef(self):
- if ops._USE_C_API:
- # TODO(skyewm): improve error message
- error_msg = ("NodeDef expected inputs 'int32, float' do not match 1 "
- "inputs specified")
- else:
- error_msg = (r"Input types mismatch \(expected 'int32, float32' but "
- r"got 'int32'\)")
-
with ops.Graph().as_default():
- with self.assertRaisesRegexp(ValueError, error_msg):
+ # TODO(skyewm): improve error message
+ with self.assertRaisesRegexp(
+ ValueError,
+ "NodeDef expected inputs 'int32, float' do not match 1 inputs "
+ "specified"):
importer.import_graph_def(
self._MakeGraphDef("""
node { name: 'A' op: 'IntOutput' }
@@ -508,13 +491,9 @@ class ImportGraphDefTest(test.TestCase):
"""))
def testMissingInputOpInGraphDef(self):
- if ops._USE_C_API:
- error_msg = "Node 'B': Unknown input node 'A:0'"
- else:
- error_msg = "Input tensor 'A:0' not found"
-
with ops.Graph().as_default():
- with self.assertRaisesRegexp(ValueError, error_msg):
+ with self.assertRaisesRegexp(ValueError,
+ "Node 'B': Unknown input node 'A:0'"):
importer.import_graph_def(
self._MakeGraphDef("""
node { name: 'B' op: 'FloatInput' input: 'A:0' }
@@ -532,14 +511,11 @@ class ImportGraphDefTest(test.TestCase):
self.assertEqual(b.inputs[0], feed_a_0)
def testMissingInputTensorInGraphDef(self):
- if ops._USE_C_API:
- error_msg = ("Node 'B': Connecting to invalid output 1 of source node A "
- "which has 1 outputs")
- else:
- error_msg = "Input tensor 'A:1' not found"
-
with ops.Graph().as_default():
- with self.assertRaisesRegexp(ValueError, error_msg):
+ with self.assertRaisesRegexp(
+ ValueError,
+ "Node 'B': Connecting to invalid output 1 of source node A "
+ "which has 1 outputs"):
importer.import_graph_def(
self._MakeGraphDef("""
node { name: 'A' op: 'FloatOutput' }
@@ -547,52 +523,36 @@ class ImportGraphDefTest(test.TestCase):
"""))
def testMissingControlInputInGraphDef(self):
- if ops._USE_C_API:
- error_msg = r"Node 'B': Unknown input node '\^A'"
- else:
- error_msg = r"Control input '\^A' not found"
-
with ops.Graph().as_default():
- with self.assertRaisesRegexp(ValueError, error_msg):
+ with self.assertRaisesRegexp(ValueError,
+ r"Node 'B': Unknown input node '\^A'"):
importer.import_graph_def(
self._MakeGraphDef("""
node { name: 'B' op: 'None' input: '^A' }
"""))
def testInvalidTensorNameOutputIndexInGraphDef(self):
- if ops._USE_C_API:
- error_msg = "Node 'B': Unknown input node 'A:B'"
- else:
- error_msg = "Cannot convert 'A:B' to a tensor name."
-
with ops.Graph().as_default():
- with self.assertRaisesRegexp(ValueError, error_msg):
+ with self.assertRaisesRegexp(ValueError,
+ "Node 'B': Unknown input node 'A:B'"):
importer.import_graph_def(
self._MakeGraphDef("""
node { name: 'B' op: 'None' input: 'A:B' }
"""))
def testInvalidTensorNameInGraphDef(self):
- if ops._USE_C_API:
- error_msg = "Node 'B': Unknown input node 'A:B:0'"
- else:
- error_msg = "Cannot convert 'A:B:0' to a tensor name."
-
with ops.Graph().as_default():
- with self.assertRaisesRegexp(ValueError, error_msg):
+ with self.assertRaisesRegexp(ValueError,
+ "Node 'B': Unknown input node 'A:B:0'"):
importer.import_graph_def(
self._MakeGraphDef("""
node { name: 'B' op: 'None' input: 'A:B:0' }
"""))
def testMissingReturnOperation(self):
- if ops._USE_C_API:
- error_msg = "Requested return node 'B' not found in graph def"
- else:
- error_msg = "return_element 'B' not found in graph_def."
-
with ops.Graph().as_default():
- with self.assertRaisesRegexp(ValueError, error_msg):
+ with self.assertRaisesRegexp(
+ ValueError, "Requested return node 'B' not found in graph def"):
importer.import_graph_def(
self._MakeGraphDef("""
node { name: 'A' op: 'None' }
@@ -600,38 +560,26 @@ class ImportGraphDefTest(test.TestCase):
return_elements=["B"])
def testMissingReturnTensor(self):
- if ops._USE_C_API:
- error_msg = (r"Invalid return output 1 of node 'A', which has 1 "
- r"output\(s\)")
- else:
- error_msg = "return_element 'A:1' not found in graph_def."
-
with ops.Graph().as_default():
- with self.assertRaisesRegexp(ValueError, error_msg):
+ with self.assertRaisesRegexp(
+ ValueError,
+ r"Invalid return output 1 of node 'A', which has 1 output\(s\)"):
importer.import_graph_def(
self._MakeGraphDef("""
node { name: 'A' op: 'IntOutput' }
"""),
return_elements=["A:1"])
- if ops._USE_C_API:
- error_msg = "Requested return tensor 'B:0' not found in graph def"
- else:
- error_msg = "return_element 'B:0' not found in graph_def."
-
- with self.assertRaisesRegexp(ValueError, error_msg):
+ with self.assertRaisesRegexp(
+ ValueError, "Requested return tensor 'B:0' not found in graph def"):
importer.import_graph_def(
self._MakeGraphDef("""
node { name: 'A' op: 'IntOutput' }
"""),
return_elements=["B:0"])
- if ops._USE_C_API:
- error_msg = "Cannot convert 'A:B:0' to a tensor name."
- else:
- error_msg = "return_element 'A:B:0' not found in graph_def."
-
- with self.assertRaisesRegexp(ValueError, error_msg):
+ with self.assertRaisesRegexp(ValueError,
+ "Cannot convert 'A:B:0' to a tensor name."):
importer.import_graph_def(
self._MakeGraphDef("""
node { name: 'A' op: 'IntOutput' }
@@ -669,14 +617,10 @@ class ImportGraphDefTest(test.TestCase):
input_map={"A:2": constant_op.constant(5.0)})
def testInputMapTypeMismatch(self):
- if ops._USE_C_API:
- error_msg = ("Input 0 of node import/B was passed float from Const:0 "
- "incompatible with expected int32.")
- else:
- error_msg = ("Cannot convert a tensor of type float32 to an input of "
- "type int32.")
with ops.Graph().as_default():
- with self.assertRaisesRegexp(ValueError, error_msg):
+ with self.assertRaisesRegexp(
+ ValueError, "Input 0 of node import/B was passed float from Const:0 "
+ "incompatible with expected int32."):
importer.import_graph_def(
self._MakeGraphDef("""
node { name: 'A' op: 'IntOutput' }
@@ -899,13 +843,9 @@ class ImportGraphDefTest(test.TestCase):
value { list { s: 'loc:@A' } }
} }""")
- if ops._USE_C_API:
- error_msg = "Node 'B' expects to be colocated with unknown node 'A'"
- else:
- error_msg = "does not exist during import"
-
with ops.Graph().as_default():
- with self.assertRaisesRegexp(ValueError, error_msg):
+ with self.assertRaisesRegexp(
+ ValueError, "Node 'B' expects to be colocated with unknown node 'A'"):
importer.import_graph_def(
original_graph_def, return_elements=["B"], name="imported_graph")
@@ -957,28 +897,19 @@ class ImportGraphDefTest(test.TestCase):
TypeError, "return_elements must be a list of strings."):
importer.import_graph_def(self._MakeGraphDef(""), return_elements=[7])
- if ops._USE_C_API:
- error_msg = "Cannot convert 'a:b:c' to a tensor name."
- else:
- error_msg = "Requested return_element 'a:b:c' not found in graph_def."
- with self.assertRaisesRegexp(ValueError, error_msg):
- importer.import_graph_def(self._MakeGraphDef(""),
- return_elements=["a:b:c"])
+ with self.assertRaisesRegexp(ValueError,
+ "Cannot convert 'a:b:c' to a tensor name."):
+ importer.import_graph_def(
+ self._MakeGraphDef(""), return_elements=["a:b:c"])
def testDuplicateOperationNames(self):
- if ops._USE_C_API:
- error_msg = "Node 'A' is not unique"
- else:
- error_msg = "Duplicate name 'A' in GraphDef."
-
- with ops.Graph().as_default():
- with self.assertRaisesRegexp(ValueError, error_msg):
- importer.import_graph_def(
- self._MakeGraphDef("""
- node { name: 'A' op: 'IntOutput' }
- node { name: 'B' op: 'IntOutput' }
- node { name: 'A' op: 'IntOutput' }
- """))
+ with self.assertRaisesRegexp(ValueError, "Node 'A' is not unique"):
+ importer.import_graph_def(
+ self._MakeGraphDef("""
+ node { name: 'A' op: 'IntOutput' }
+ node { name: 'B' op: 'IntOutput' }
+ node { name: 'A' op: 'IntOutput' }
+ """))
def testWithExtensionAndAttr(self):
with ops.Graph().as_default() as g:
@@ -1119,40 +1050,22 @@ class ImportGraphDefTest(test.TestCase):
min_consumer)
def testVersionLow(self):
- with ops.Graph().as_default() as g:
- pat = (r"GraphDef producer version -1 below min producer %d supported "
- r"by TensorFlow \S+\. Please regenerate your graph.$" %
- versions.GRAPH_DEF_VERSION_MIN_PRODUCER)
- # C API throws error during import, Python-only throws error during run
- if ops._USE_C_API:
- with self.assertRaisesRegexp(Exception, pat):
- importer.import_graph_def(self._MakeGraphDef("", producer=-1))
- else:
+ with ops.Graph().as_default():
+ with self.assertRaisesRegexp(
+ Exception,
+ r"GraphDef producer version -1 below min producer %d supported "
+ r"by TensorFlow \S+\. Please regenerate your graph.$" %
+ versions.GRAPH_DEF_VERSION_MIN_PRODUCER):
importer.import_graph_def(self._MakeGraphDef("", producer=-1))
- x = constant_op.constant(
- 7) # Need at least one op to get a C++ graph generated
- with self.test_session(graph=g) as sess:
- with self.assertRaisesRegexp(Exception, pat):
- sess.run(x)
def testVersionHigh(self):
- with ops.Graph().as_default() as g:
- pat = (r"GraphDef min consumer version %d above current version %d "
- r"for TensorFlow \S+\. Please upgrade TensorFlow\.$" %
- (1 << 30, versions.GRAPH_DEF_VERSION))
-
- if ops._USE_C_API:
- with self.assertRaisesRegexp(ValueError, pat):
- importer.import_graph_def(self._MakeGraphDef("",
- min_consumer=1 << 30))
- else:
- # Python API only throws when graph is run
+ with ops.Graph().as_default():
+ with self.assertRaisesRegexp(
+ ValueError,
+ r"GraphDef min consumer version %d above current version %d "
+ r"for TensorFlow \S+\. Please upgrade TensorFlow\.$" %
+ (1 << 30, versions.GRAPH_DEF_VERSION)):
importer.import_graph_def(self._MakeGraphDef("", min_consumer=1 << 30))
- x = constant_op.constant(
- 7) # Need at least one op to get a C++ graph generated
- with self.test_session(graph=g) as sess:
- with self.assertRaisesRegexp(Exception, pat):
- sess.run(x)
def testVersionAppliesToOpConstruction(self):
"""These tests rely on shape fns in test_ops.cc."""
@@ -1198,29 +1111,13 @@ class ImportGraphDefTest(test.TestCase):
"""),
return_elements=["A"],
producer_op_list=producer_op_list)
- if ops._USE_C_API:
- error_msg = "Operation 'import/A' has no attr named 'default_int'."
- else:
- error_msg = "No attr named 'default_int'"
- with self.assertRaisesRegexp(ValueError, error_msg):
+ with self.assertRaisesRegexp(
+ ValueError, "Operation 'import/A' has no attr named 'default_int'."):
a[0].get_attr("default_int")
- # Unknown attrs cannot be imported using C API. This test will eventually be
- # deleted.
- if not ops._USE_C_API:
- # Attr only in producer_op_list with non-default value is preserved.
- with ops.Graph().as_default():
- a = importer.import_graph_def(
- self._MakeGraphDef("""
- node { name: 'A' op: 'OpWithFutureDefaultAttr'
- attr { key: 'default_int' value { i: 987 } } }
- """),
- return_elements=["A"],
- producer_op_list=producer_op_list)
- self.assertEqual(987, a[0].get_attr("default_int"))
-
def testFunctions(self):
dtype = dtypes.float32
+
@function.Defun(dtype, dtype, dtype, dtype)
def Grad(x, y, dout1, dout2): # pylint: disable=unused-argument
# Return the inputs for simplicity of testing. The correct return value
@@ -1299,6 +1196,7 @@ class ImportGraphDefTest(test.TestCase):
def testImportInsideDefun(self):
g = ops.Graph()
with g.as_default():
+
@function.Defun()
def Add2(x, y):
return math_ops.add(x, y)
@@ -1322,6 +1220,7 @@ class ImportGraphDefTest(test.TestCase):
def testImportGraphWithFunctionTwice(self):
g = ops.Graph()
with g.as_default():
+
@function.Defun()
def Add2(x, y):
return math_ops.add(x, y)
diff --git a/tensorflow/python/framework/meta_graph_test.py b/tensorflow/python/framework/meta_graph_test.py
index 0532ed464c..5cf8697210 100644
--- a/tensorflow/python/framework/meta_graph_test.py
+++ b/tensorflow/python/framework/meta_graph_test.py
@@ -61,7 +61,6 @@ def _TestDir(test_name):
# pylint: enable=invalid-name
-@test_util.with_c_api
class SimpleMetaGraphTest(test.TestCase):
def testNoVariables(self):
@@ -285,7 +284,6 @@ class SimpleMetaGraphTest(test.TestCase):
self.assertIs(global_vars[0], trainable_vars[0])
-@test_util.with_c_api
class ScopedMetaGraphTest(test.TestCase):
def _testScopedExport(self, test_dir, exported_filenames):
@@ -841,7 +839,6 @@ class ScopedMetaGraphTest(test.TestCase):
self.assertEqual("", str(graph2.as_graph_element("matmul").device))
-@test_util.with_c_api
class MetaGraphWithVariableScopeTest(test.TestCase):
def testMetricsCollection(self):
@@ -899,7 +896,6 @@ class MetaGraphWithVariableScopeTest(test.TestCase):
initializer = variables.local_variables_initializer()
-@test_util.with_c_api
class ExportImportAcrossScopesTest(test.TestCase):
def testPartionedVariables(self):
diff --git a/tensorflow/python/framework/op_def_library_test.py b/tensorflow/python/framework/op_def_library_test.py
index 84ca062ade..66cfe213b3 100644
--- a/tensorflow/python/framework/op_def_library_test.py
+++ b/tensorflow/python/framework/op_def_library_test.py
@@ -36,7 +36,6 @@ def _unknown_shape(op):
return [tensor_shape.unknown_shape() for _ in op.outputs]
-@test_util.with_c_api
class OpDefLibraryTest(test_util.TensorFlowTestCase):
def setUp(self):
@@ -1330,7 +1329,6 @@ class OpDefLibraryTest(test_util.TensorFlowTestCase):
self.assertEqual(t_c, [x.dtype for x in c])
-@test_util.with_c_api
class OpDefLibraryGraphTest(test_util.TensorFlowTestCase):
def setUp(self):
diff --git a/tensorflow/python/framework/ops_test.py b/tensorflow/python/framework/ops_test.py
index c9c1a3d66b..a89660161a 100644
--- a/tensorflow/python/framework/ops_test.py
+++ b/tensorflow/python/framework/ops_test.py
@@ -23,7 +23,6 @@ import threading
import weakref
from tensorflow.core.framework import attr_value_pb2
-from tensorflow.core.framework import types_pb2
from tensorflow.core.protobuf import config_pb2
from tensorflow.python.client import session
from tensorflow.python.eager import context
@@ -43,7 +42,6 @@ from tensorflow.python.framework import test_util
from tensorflow.python.framework import versions
from tensorflow.python.ops import array_ops
from tensorflow.python.ops import control_flow_ops
-from tensorflow.python.ops import gen_array_ops
from tensorflow.python.ops import math_ops
from tensorflow.python.ops import resource_variable_ops
from tensorflow.python.ops import resources
@@ -56,7 +54,6 @@ from tensorflow.python.util import compat
ops._set_call_cpp_shape_fn(common_shapes.call_cpp_shape_fn)
-@test_util.with_c_api
class ResourceTest(test_util.TensorFlowTestCase):
def testBuildGraph(self):
@@ -82,7 +79,6 @@ class ResourceTest(test_util.TensorFlowTestCase):
resources.shared_resources()).eval()), 0)
-@test_util.with_c_api
class TensorAndShapeTest(test_util.TensorFlowTestCase):
def testShape(self):
@@ -141,7 +137,6 @@ class TensorAndShapeTest(test_util.TensorFlowTestCase):
_ = a + b
-@test_util.with_c_api
class IndexedSlicesTest(test_util.TensorFlowTestCase):
def testToTensor(self):
@@ -170,7 +165,6 @@ class IndexedSlicesTest(test_util.TensorFlowTestCase):
self.assertAllEqual(x.indices.eval(), [0, 2])
-@test_util.with_c_api
class NodeDefConstructorTest(test_util.TensorFlowTestCase):
def testNoArgs(self):
@@ -193,7 +187,6 @@ def _apply_op(g, *args, **kwargs):
return op.outputs
-@test_util.with_c_api
class OperationTest(test_util.TensorFlowTestCase):
def testNoInputs(self):
@@ -443,12 +436,8 @@ class OperationTest(test_util.TensorFlowTestCase):
attr_value_pb2.NameAttrList(name="MyFunc"))
# Try fetching missing attr
- if ops._USE_C_API:
- error_msg = "Operation 'FuncAttr' has no attr named 'FakeAttr'."
- else:
- error_msg = "No attr named 'FakeAttr' in name: \"FuncAttr\""
-
- with self.assertRaisesRegexp(ValueError, error_msg):
+ with self.assertRaisesRegexp(
+ ValueError, "Operation 'FuncAttr' has no attr named 'FakeAttr'."):
op.get_attr("FakeAttr")
# TODO(b/65162920): remove this test when users who are directly mutating the
@@ -461,23 +450,6 @@ class OperationTest(test_util.TensorFlowTestCase):
# TODO(nolivia): test all error cases
def testAddControlInput(self):
- # The C API dedups redundant control edges, pure Python does not
- if ops._USE_C_API: return
- with ops.Graph().as_default():
- x = constant_op.constant(1).op
- y = constant_op.constant(2).op
- z = constant_op.constant(3).op
- z._add_control_input(x) # pylint: disable=protected-access
- self.assertEqual(z.control_inputs, [x])
- z._add_control_input(x) # pylint: disable=protected-access
- self.assertEqual(z.control_inputs, [x, x])
- z._add_control_inputs([x, y, y]) # pylint: disable=protected-access
- self.assertEqual(z.control_inputs, [x, x, x, y, y])
- self.assertEqual(x._control_outputs, [z])
-
- def testAddControlInputC(self):
- # The C API dedups redundant control edges, pure Python does not
- if not ops._USE_C_API: return
with ops.Graph().as_default():
x = constant_op.constant(1).op
y = constant_op.constant(2).op
@@ -515,8 +487,6 @@ class OperationTest(test_util.TensorFlowTestCase):
self.assertEqual(list(f.op.inputs), [d, e])
def testControlInputCycle(self):
- # Non-C API path has a different error message
- if not ops._USE_C_API: return
graph = ops.Graph()
with graph.as_default():
z = constant_op.constant(0)
@@ -586,25 +556,6 @@ class OperationTest(test_util.TensorFlowTestCase):
sess.run(z)
def testUpdateInputShapeError(self):
- # C-API throws the error differently.
- if ops._USE_C_API:
- return
- g = ops.Graph()
- with g.as_default():
- w = constant_op.constant(2, shape=[3, 1])
- x = constant_op.constant(0, shape=[3, 1])
- y = constant_op.constant(1, shape=[2, 2])
- z = w + x
- z.op._update_input(0, y) # pylint: disable=protected-access
-
- with session.Session(graph=g) as sess:
- with self.assertRaisesRegexp(errors.InvalidArgumentError,
- r"Incompatible shapes: \[2,2\] vs. \[3,1\]"):
- sess.run(z)
-
- def testUpdateInputShapeErrorC(self):
- if not ops._USE_C_API:
- return
g = ops.Graph()
with g.as_default():
w = constant_op.constant(2, shape=[3, 1])
@@ -617,17 +568,6 @@ class OperationTest(test_util.TensorFlowTestCase):
z.op._update_input(0, y) # pylint: disable=protected-access
def testUpdateInputOutOfRange(self):
- # C-API throws the error differently.
- if ops._USE_C_API: return
- g = ops.Graph()
- with g.as_default():
- x = constant_op.constant(1)
- with self.assertRaisesRegexp(IndexError, "list index out of range"):
- x.op._update_input(1, x) # pylint: disable=protected-access
-
- def testUpdateInputOutOfRangeC(self):
- # C-API throws the error differently.
- if not ops._USE_C_API: return
g = ops.Graph()
with g.as_default():
x = constant_op.constant(1)
@@ -643,11 +583,9 @@ class OperationTest(test_util.TensorFlowTestCase):
y = constant_op.constant(1)
z = x + y
- # Pure Python mode doesn't create OpDefs for constants
- if ops._USE_C_API:
- self.assertEqual(x.op.op_def.name, "Const")
- self.assertEqual(len(x.op.op_def.input_arg), 0)
- self.assertEqual(len(x.op.op_def.output_arg), 1)
+ self.assertEqual(x.op.op_def.name, "Const")
+ self.assertEqual(len(x.op.op_def.input_arg), 0)
+ self.assertEqual(len(x.op.op_def.output_arg), 1)
self.assertEqual(z.op.op_def.name, "Add")
self.assertEqual(len(z.op.op_def.input_arg), 2)
@@ -673,7 +611,6 @@ class OperationTest(test_util.TensorFlowTestCase):
op.inputs.append(None)
-@test_util.with_c_api
class CreateOpTest(test_util.TensorFlowTestCase):
def testNodeDefArgs(self):
@@ -738,20 +675,15 @@ class CreateOpTest(test_util.TensorFlowTestCase):
# the control flow context isn't set properly, but a more complicated use case
# that might not be obvious to test will fail). Thus we instead explicitly test
# the low-level behavior.
-@test_util.with_c_api
class CreateOpFromTFOperationTest(test_util.TensorFlowTestCase):
def testBasic(self):
g = ops.Graph()
with g.as_default():
x = test_ops.int_output()
- if ops._USE_C_API:
- c_op = ops._create_c_op(
- g, ops._NodeDef("IntInputIntOutput", "myop"), [x], [])
- op = g._create_op_from_tf_operation(c_op)
- else:
- # Test pure-Python version to make sure C API has same behavior.
- op = test_ops.int_input_int_output(x, name="myop").op
+ c_op = ops._create_c_op(
+ g, ops._NodeDef("IntInputIntOutput", "myop"), [x], [])
+ op = g._create_op_from_tf_operation(c_op)
self.assertEqual(op.name, "myop")
self.assertEqual(op.type, "IntInputIntOutput")
@@ -770,12 +702,8 @@ class CreateOpFromTFOperationTest(test_util.TensorFlowTestCase):
g = ops.Graph()
with g.as_default():
x = constant_op.constant([[1, 2, 3], [4, 5, 6]])
- if ops._USE_C_API:
- c_op = ops._create_c_op(g, ops._NodeDef("Identity", "myop"), [x], [])
- op = g._create_op_from_tf_operation(c_op)
- else:
- # Test pure-Python version to make sure C API has same behavior.
- op = array_ops.identity(x, name="myop").op
+ c_op = ops._create_c_op(g, ops._NodeDef("Identity", "myop"), [x], [])
+ op = g._create_op_from_tf_operation(c_op)
self.assertEqual(op.name, "myop")
self.assertEqual(op.type, "Identity")
@@ -785,15 +713,10 @@ class CreateOpFromTFOperationTest(test_util.TensorFlowTestCase):
def testUniqueName(self):
g = ops.Graph()
with g.as_default():
- if ops._USE_C_API:
- c_op = ops._create_c_op(g, ops._NodeDef("IntOutput", "myop"), [], [])
- c_op2 = ops._create_c_op(g, ops._NodeDef("IntOutput", "myop_1"), [], [])
- op = g._create_op_from_tf_operation(c_op)
- op2 = g._create_op_from_tf_operation(c_op2)
- else:
- # Test pure-Python version to make sure C API has same behavior.
- op = test_ops.int_output(name="myop").op
- op2 = test_ops.int_output(name="myop_1").op
+ c_op = ops._create_c_op(g, ops._NodeDef("IntOutput", "myop"), [], [])
+ c_op2 = ops._create_c_op(g, ops._NodeDef("IntOutput", "myop_1"), [], [])
+ op = g._create_op_from_tf_operation(c_op)
+ op2 = g._create_op_from_tf_operation(c_op2)
# Create ops with same names as op1 and op2. We expect the new names to be
# uniquified.
@@ -811,14 +734,10 @@ class CreateOpFromTFOperationTest(test_util.TensorFlowTestCase):
x = test_ops.int_output()
def true_fn():
- if ops._USE_C_API:
- ops._create_c_op(ops.get_default_graph(),
- ops._NodeDef("IntInput", "cond/myop"), [x], [])
- new_ops = g._add_new_tf_operations()
- self.assertEqual(len(new_ops), 1)
- else:
- # Test pure-Python version to make sure C API has same behavior.
- test_ops.int_input(x, name="myop")
+ ops._create_c_op(ops.get_default_graph(),
+ ops._NodeDef("IntInput", "cond/myop"), [x], [])
+ new_ops = g._add_new_tf_operations()
+ self.assertEqual(len(new_ops), 1)
return x
control_flow_ops.cond(x < 10, true_fn, lambda: x)
@@ -844,14 +763,10 @@ class CreateOpFromTFOperationTest(test_util.TensorFlowTestCase):
x = test_ops.int_output()
def body(i):
- if ops._USE_C_API:
- ops._create_c_op(ops.get_default_graph(),
- ops._NodeDef("IntInput", "myloop/myop"), [x], [])
- new_ops = g._add_new_tf_operations()
- self.assertEqual(len(new_ops), 1)
- else:
- # Test pure-Python version to make sure C API has same behavior.
- test_ops.int_input(x, name="myop")
+ ops._create_c_op(ops.get_default_graph(),
+ ops._NodeDef("IntInput", "myloop/myop"), [x], [])
+ new_ops = g._add_new_tf_operations()
+ self.assertEqual(len(new_ops), 1)
return i
control_flow_ops.while_loop(lambda i: i < 10, body, [0], name="myloop")
@@ -878,15 +793,11 @@ class CreateOpFromTFOperationTest(test_util.TensorFlowTestCase):
def body(i):
c = constant_op.constant(1.0, name="c")
- if ops._USE_C_API:
- ops._create_c_op(ops.get_default_graph(),
- ops._NodeDef("IntInput", "myloop/myop"), [x], [])
- with ops.control_dependencies([c]):
- new_ops = g._add_new_tf_operations()
- self.assertEqual(len(new_ops), 1)
- else:
- with ops.control_dependencies([c]):
- test_ops.int_input(x, name="myop")
+ ops._create_c_op(ops.get_default_graph(),
+ ops._NodeDef("IntInput", "myloop/myop"), [x], [])
+ with ops.control_dependencies([c]):
+ new_ops = g._add_new_tf_operations()
+ self.assertEqual(len(new_ops), 1)
return i
control_flow_ops.while_loop(lambda i: i < 10, body, [0], name="myloop")
@@ -905,15 +816,11 @@ class CreateOpFromTFOperationTest(test_util.TensorFlowTestCase):
c = constant_op.constant(1.0)
def body(i):
- if ops._USE_C_API:
- ops._create_c_op(ops.get_default_graph(),
- ops._NodeDef("IntInput", "myloop/myop"), [x], [])
- with ops.control_dependencies([c]):
- new_ops = g._add_new_tf_operations()
- self.assertEqual(len(new_ops), 1)
- else:
- with ops.control_dependencies([c]):
- test_ops.int_input(x, name="myop")
+ ops._create_c_op(ops.get_default_graph(),
+ ops._NodeDef("IntInput", "myloop/myop"), [x], [])
+ with ops.control_dependencies([c]):
+ new_ops = g._add_new_tf_operations()
+ self.assertEqual(len(new_ops), 1)
return i
control_flow_ops.while_loop(lambda i: i < 10, body, [0], name="myloop")
@@ -925,7 +832,6 @@ class CreateOpFromTFOperationTest(test_util.TensorFlowTestCase):
self.assertIsNotNone(op.control_inputs[0]._get_control_flow_context())
-@test_util.with_c_api
class ApplyOpTest(test_util.TensorFlowTestCase):
def testNodeDefArgs(self):
@@ -979,7 +885,6 @@ class ApplyOpTest(test_util.TensorFlowTestCase):
out_3.op.node_def)
-@test_util.with_c_api
class NameStackTest(test_util.TensorFlowTestCase):
def testBasics(self):
@@ -1078,7 +983,6 @@ class NameStackTest(test_util.TensorFlowTestCase):
pass
-@test_util.with_c_api
class NameTest(test_util.TensorFlowTestCase):
def testGenerateName(self):
@@ -1148,7 +1052,6 @@ class NameTest(test_util.TensorFlowTestCase):
g.create_op("FloatOutput", [], [dtypes.float32]).name)
-@test_util.with_c_api
class DeviceTest(test_util.TensorFlowTestCase):
def testNoDevice(self):
@@ -1385,7 +1288,6 @@ class DeviceTest(test_util.TensorFlowTestCase):
""", gd)
-@test_util.with_c_api
class MultithreadedGraphStateTest(test_util.TensorFlowTestCase):
class TestThread(threading.Thread):
@@ -1588,7 +1490,6 @@ class MultithreadedGraphStateTest(test_util.TensorFlowTestCase):
self.assertEquals("foo" + s + "/FloatOutput_1", t.result[1].name)
-@test_util.with_c_api
class ObjectWithName(object):
def __init__(self, name):
@@ -1599,7 +1500,6 @@ class ObjectWithName(object):
return self._name
-@test_util.with_c_api
class CollectionTest(test_util.TensorFlowTestCase):
def test_get_collections(self):
@@ -1723,7 +1623,6 @@ def _CopyOverrideGrad(op, x_grad): # pylint: disable=invalid-name
return x_grad
-@test_util.with_c_api
class RegistrationTest(test_util.TensorFlowTestCase):
def testRegisterGradients(self):
@@ -1751,7 +1650,6 @@ class RegistrationTest(test_util.TensorFlowTestCase):
ops.get_gradient_function(y.op)
-@test_util.with_c_api
class ComparisonTest(test_util.TensorFlowTestCase):
def testMembershipAllowed(self):
@@ -1764,10 +1662,8 @@ class ComparisonTest(test_util.TensorFlowTestCase):
self.assertTrue(t1 not in [t2])
-@test_util.with_c_api
class ControlDependenciesTest(test_util.TensorFlowTestCase):
- @test_util.enable_c_api
def testBasic(self):
g = ops.Graph()
with g.as_default():
@@ -1971,7 +1867,6 @@ class ControlDependenciesTest(test_util.TensorFlowTestCase):
self.assertEqual(b.op.control_inputs, [])
-@test_util.with_c_api
class OpScopeTest(test_util.TensorFlowTestCase):
@test_util.run_in_graph_and_eager_modes()
@@ -2330,7 +2225,6 @@ class InitScopeTest(test_util.TensorFlowTestCase):
self.assertEqual(ops.get_name_scope(), "")
-@test_util.with_c_api
class GraphTest(test_util.TensorFlowTestCase):
def setUp(self):
@@ -2440,7 +2334,6 @@ class GraphTest(test_util.TensorFlowTestCase):
sess.run(a)
-@test_util.with_c_api
class AttrScopeTest(test_util.TensorFlowTestCase):
def _get_test_attrs(self):
@@ -2491,10 +2384,8 @@ class AttrScopeTest(test_util.TensorFlowTestCase):
ops.RegisterShape("KernelLabel")(common_shapes.scalar_shape)
-@test_util.with_c_api
class KernelLabelTest(test_util.TensorFlowTestCase):
- @test_util.enable_c_api
def testNoLabel(self):
with self.test_session():
self.assertAllEqual(b"My label is: default",
@@ -2522,7 +2413,6 @@ class KernelLabelTest(test_util.TensorFlowTestCase):
self.assertAllEqual(b"My label is: overload_2", overload_2.eval())
-@test_util.with_c_api
class AsGraphDefTest(test_util.TensorFlowTestCase):
def testGraphDefVersion(self):
@@ -2589,7 +2479,6 @@ def _calc_a_forward_flops(unused_graph, unused_node):
return ops.OpStats("flops", 20)
-@test_util.with_c_api
class StatisticsTest(test_util.TensorFlowTestCase):
def testRegisteredNode(self):
@@ -2614,7 +2503,6 @@ class StatisticsTest(test_util.TensorFlowTestCase):
self.assertEqual(3, flops_total.value)
-@test_util.with_c_api
class ColocationGroupTest(test_util.TensorFlowTestCase):
def testBasic(self):
@@ -2739,15 +2627,11 @@ class ColocationGroupTest(test_util.TensorFlowTestCase):
self.assertEqual("/device:CPU:0", b.device)
-@test_util.with_c_api
class DeprecatedTest(test_util.TensorFlowTestCase):
def testSuccess(self):
- # TODO(skyewm): make g.graph_def_versions work with the C API enabled
- if ops._USE_C_API: return
-
with ops.Graph().as_default() as g:
- g.graph_def_versions.producer = 7
+ test_util.set_producer_version(g, 7)
old = test_ops.old()
with self.test_session(graph=g):
old.run()
@@ -2762,20 +2646,7 @@ class DeprecatedTest(test_util.TensorFlowTestCase):
with self.assertRaisesRegexp(NotImplementedError, self._error()):
test_ops.old()
- def testGraphExecutionFail(self):
- # TODO(skyewm): make g.graph_def_versions work with the C API enabled
- if ops._USE_C_API: return
-
- with ops.Graph().as_default() as g:
- g.graph_def_versions.producer = 7
- old = test_ops.old()
- g.graph_def_versions.producer = versions.GRAPH_DEF_VERSION
- with self.test_session(graph=g):
- with self.assertRaisesRegexp(errors.UnimplementedError, self._error()):
- old.run()
-
-@test_util.with_c_api
class DenseTensorLikeTypeTest(test_util.TensorFlowTestCase):
def testSuccess(self):
@@ -2825,7 +2696,6 @@ class DenseTensorLikeTypeTest(test_util.TensorFlowTestCase):
DenseTensorLikeTypeTest.BadClassBadDtype)
-@test_util.with_c_api
class NameScopeTest(test_util.TensorFlowTestCase):
def testStripAndPrependScope(self):
@@ -2876,7 +2746,6 @@ class NameScopeTest(test_util.TensorFlowTestCase):
self.assertRaisesRegexp(ValueError, "'_' is not a valid scope name", f)
-@test_util.with_c_api
class TracebackTest(test_util.TensorFlowTestCase):
def testTracebackWithStartLines(self):
@@ -2898,57 +2767,6 @@ class TracebackTest(test_util.TensorFlowTestCase):
self.assertEquals(frame, frame_with_start_line[:-1])
-@test_util.with_c_api
-class OutputTypesTest(test_util.TensorFlowTestCase):
- """Tests Operation._output_types property.
-
- This test should not exist as _output_types is a private property.
- This property is used by util.copy_elements and its tests would normally
- cover Operation._output_types. However, we can't yet run these tests in C
- API mode because their use _set_device method. This test will be deleted
- once we port _set_device and run the copy tests with C API on.
- """
- # TODO(iga): Remove this test
-
- def setUp(self):
- self.prev_use_c_api = ops._USE_C_API # pylint: disable=protected-access
- ops._USE_C_API = True # pylint: disable=protected-access
-
- def tearDown(self):
- ops._USE_C_API = self.prev_use_c_api # pylint: disable=protected-access
-
- def testOneOutput(self):
- g = ops.Graph()
- with g.as_default():
- # Using a constant because creating unregistered ops
- # doesn't work with the C API.
- op = constant_op.constant(12, dtype=dtypes.uint16).op
- # pylint: disable=protected-access
- self.assertEqual([types_pb2.DT_UINT16], op._output_types)
- # pylint: enable=protected-access
-
- def testTwoDifferentOutputs(self):
- g = ops.Graph()
- with g.as_default():
- x = constant_op.constant([1, 1, 2, 4, 4, 4, 7, 8, 8],
- dtype=dtypes.double)
- y, _ = gen_array_ops.unique(x)
- self.assertEqual([types_pb2.DT_DOUBLE, types_pb2.DT_INT32],
- y.op._output_types) # pylint: disable=protected-access
-
- def testThreeOutputs(self):
- g = ops.Graph()
- with g.as_default():
- # Using a split operationt because creating unregistered ops
- # doesn't work with the C API.
- a = constant_op.constant("abc", dtype=dtypes.string, shape=[5, 30])
- split0, _, _ = array_ops.split(a, [4, 15, 11], 1)
- # pylint: disable=protected-access
- self.assertEqual([types_pb2.DT_STRING] * 3, split0.op._output_types)
- # pylint: enable=protected-access
-
-
-@test_util.with_c_api
class EnableEagerExecutionTest(test_util.TensorFlowTestCase):
def testBadArgumentsToEnableEagerExecution(self):
diff --git a/tensorflow/python/framework/smart_cond_test.py b/tensorflow/python/framework/smart_cond_test.py
index 1170a41c99..b8a9672b06 100644
--- a/tensorflow/python/framework/smart_cond_test.py
+++ b/tensorflow/python/framework/smart_cond_test.py
@@ -33,7 +33,6 @@ def raise_exception():
raise RuntimeError("did not expect to be called")
-@test_util.with_c_api
class SmartCondTest(test_util.TensorFlowTestCase):
def testTrue(self):
@@ -64,9 +63,6 @@ class SmartCondTest(test_util.TensorFlowTestCase):
self.assertEqual(y.eval(feed_dict={x: -1}), 2)
def testEval(self):
- # Constant expression evaluation only works with the C API enabled.
- if not ops._USE_C_API: return
-
with ops.Graph().as_default():
with session.Session():
x = constant_op.constant(1)
@@ -101,7 +97,6 @@ class SmartCondTest(test_util.TensorFlowTestCase):
smart_cond.smart_cond(True, lambda: x)
-@test_util.with_c_api
class SmartCaseTest(test_util.TensorFlowTestCase):
def testTrue(self):
@@ -130,9 +125,6 @@ class SmartCaseTest(test_util.TensorFlowTestCase):
self.assertEqual(sess.run(z), 1)
def testMix(self):
- # Constant expression evaluation only works with the C API enabled.
- if not ops._USE_C_API: return
-
x = array_ops.placeholder(dtype=dtypes.int32, shape=[])
y = constant_op.constant(10)
conditions = [(x > 1, lambda: constant_op.constant(1)),
@@ -145,7 +137,6 @@ class SmartCaseTest(test_util.TensorFlowTestCase):
self.assertEqual(sess.run(z, feed_dict={x: 0}), 3)
-@test_util.with_c_api
class SmartConstantValueTest(test_util.TensorFlowTestCase):
# TODO(skyewm): this is essentially a regression test for
diff --git a/tensorflow/python/framework/subscribe_test.py b/tensorflow/python/framework/subscribe_test.py
index 8b95b25e82..d6de45fdc4 100644
--- a/tensorflow/python/framework/subscribe_test.py
+++ b/tensorflow/python/framework/subscribe_test.py
@@ -36,7 +36,6 @@ from tensorflow.python.ops import variables
from tensorflow.python.platform import googletest
-@test_util.with_c_api
class SubscribeTest(test_util.TensorFlowTestCase):
def _ExpectSubscribedIdentities(self, container):
diff --git a/tensorflow/python/framework/test_util_test.py b/tensorflow/python/framework/test_util_test.py
index 8d492256aa..0f53762f6f 100644
--- a/tensorflow/python/framework/test_util_test.py
+++ b/tensorflow/python/framework/test_util_test.py
@@ -44,7 +44,6 @@ from tensorflow.python.ops import variables
from tensorflow.python.platform import googletest
-@test_util.with_c_api
class TestUtilTest(test_util.TensorFlowTestCase):
def test_assert_ops_in_graph(self):
@@ -597,7 +596,6 @@ class TestUtilTest(test_util.TensorFlowTestCase):
self.assertIsNone(test_util.get_node_def_from_graph("bar", graph_def))
-@test_util.with_c_api
class GarbageCollectionTest(test_util.TensorFlowTestCase):
def test_no_reference_cycle_decorator(self):
diff --git a/tensorflow/python/kernel_tests/array_ops_test.py b/tensorflow/python/kernel_tests/array_ops_test.py
index 7acca0a4a0..0c29714522 100644
--- a/tensorflow/python/kernel_tests/array_ops_test.py
+++ b/tensorflow/python/kernel_tests/array_ops_test.py
@@ -1042,7 +1042,6 @@ class ShapeSizeRankTest(test_util.TensorFlowTestCase):
self.evaluate(array_ops.size(tensor, out_type=dtypes.int64)).dtype)
-@test_util.with_c_api
class SequenceMaskTest(test_util.TensorFlowTestCase):
def testExceptions(self):
@@ -1065,10 +1064,7 @@ class SequenceMaskTest(test_util.TensorFlowTestCase):
# test dtype and default maxlen:
res = array_ops.sequence_mask(constant_op.constant([0, 1, 4]),
dtype=dtypes.float32)
- if ops._USE_C_API:
- self.assertAllEqual(res.get_shape().as_list(), [3, 4])
- else:
- self.assertAllEqual(res.get_shape().as_list(), [3, None])
+ self.assertAllEqual(res.get_shape().as_list(), [3, 4])
self.assertAllEqual(
res.eval(),
[[0.0, 0.0, 0.0, 0.0], [1.0, 0.0, 0.0, 0.0], [1.0, 1.0, 1.0, 1.0]])
@@ -1078,10 +1074,7 @@ class SequenceMaskTest(test_util.TensorFlowTestCase):
with self.test_session():
res = array_ops.sequence_mask(
constant_op.constant([0, 1, 4]))
- if ops._USE_C_API:
- self.assertAllEqual(res.get_shape().as_list(), [3, 4])
- else:
- self.assertAllEqual(res.get_shape().as_list(), [3, None])
+ self.assertAllEqual(res.get_shape().as_list(), [3, 4])
self.assertAllEqual(
res.eval(),
[[False, False, False, False],
@@ -1100,10 +1093,7 @@ class SequenceMaskTest(test_util.TensorFlowTestCase):
# test dtype and default maxlen:
res = array_ops.sequence_mask(
constant_op.constant([[0, 1, 4], [1, 2, 3]]), dtype=dtypes.float32)
- if ops._USE_C_API:
- self.assertAllEqual(res.get_shape().as_list(), [2, 3, 4])
- else:
- self.assertAllEqual(res.get_shape().as_list(), [2, 3, None])
+ self.assertAllEqual(res.get_shape().as_list(), [2, 3, 4])
self.assertAllEqual(
res.eval(),
[[[0.0, 0.0, 0.0, 0.0], [1.0, 0.0, 0.0, 0.0], [1.0, 1.0, 1.0, 1.0]],
diff --git a/tensorflow/python/kernel_tests/control_flow_ops_py_test.py b/tensorflow/python/kernel_tests/control_flow_ops_py_test.py
index 843759fed0..68873df97e 100644
--- a/tensorflow/python/kernel_tests/control_flow_ops_py_test.py
+++ b/tensorflow/python/kernel_tests/control_flow_ops_py_test.py
@@ -38,7 +38,6 @@ from tensorflow.python.framework import function
from tensorflow.python.framework import ops
from tensorflow.python.framework import sparse_tensor
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 import control_flow_ops
from tensorflow.python.ops import data_flow_ops
@@ -123,7 +122,6 @@ def isum(s, maximum_iterations=None):
return r_s
-@test_util.with_c_api
class ControlFlowTest(test.TestCase):
def testRefIdentity(self):
@@ -2947,7 +2945,6 @@ class ControlFlowTest(test.TestCase):
1)
-@test_util.with_c_api
class ControlFlowContextCheckTest(test.TestCase):
def _getWhileTensor(self):
@@ -3067,7 +3064,6 @@ class ControlFlowContextCheckTest(test.TestCase):
math_ops.less(1, 2), true_fn, lambda: constant_op.constant(0))
-@test_util.with_c_api
class TupleTest(test.TestCase):
def testTensors(self):
@@ -3153,7 +3149,6 @@ class TupleTest(test.TestCase):
self.assertEquals(1, var.eval())
-@test_util.with_c_api
class AssertTest(test.TestCase):
def testGuardedAssertDoesNotCopyWhenTrue(self):
@@ -3193,7 +3188,6 @@ class AssertTest(test.TestCase):
self.assertEqual([], guarded_memcpy_nodestat_names)
-@test_util.with_c_api
class WhileOpBenchmark(test.Benchmark):
"""Evaluate the performance of while_loop op."""
@@ -3308,7 +3302,6 @@ class WhileOpBenchmark(test.Benchmark):
name="unroll_same_device", iters=iters, wall_time=duration)
-@test_util.with_c_api
class EagerTest(test.TestCase):
def testCond(self):
diff --git a/tensorflow/python/kernel_tests/large_concat_op_test.py b/tensorflow/python/kernel_tests/large_concat_op_test.py
index 184d1dde2a..66afb6ec01 100644
--- a/tensorflow/python/kernel_tests/large_concat_op_test.py
+++ b/tensorflow/python/kernel_tests/large_concat_op_test.py
@@ -19,12 +19,10 @@ from __future__ import print_function
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.platform import test
-@test_util.with_c_api
class LargeConcatOpTest(test.TestCase):
"""Tests that belong in concat_op_test.py, but run over large tensors."""
diff --git a/tensorflow/python/kernel_tests/resource_variable_ops_test.py b/tensorflow/python/kernel_tests/resource_variable_ops_test.py
index 3daf07ea63..073799cc46 100644
--- a/tensorflow/python/kernel_tests/resource_variable_ops_test.py
+++ b/tensorflow/python/kernel_tests/resource_variable_ops_test.py
@@ -42,7 +42,6 @@ from tensorflow.python.training import training_util
from tensorflow.python.util import compat
-@test_util.with_c_api
class ResourceVariableOpsTest(test_util.TensorFlowTestCase):
def tearDown(self):
diff --git a/tensorflow/python/kernel_tests/scalar_test.py b/tensorflow/python/kernel_tests/scalar_test.py
index 0d8fd23294..287919bab7 100644
--- a/tensorflow/python/kernel_tests/scalar_test.py
+++ b/tensorflow/python/kernel_tests/scalar_test.py
@@ -31,7 +31,6 @@ import tensorflow.python.ops.nn_grad # pylint: disable=unused-import
from tensorflow.python.platform import test
-@test_util.with_c_api
class ScalarTest(test.TestCase):
def check(self, op, args, error, correct=None):
diff --git a/tensorflow/python/kernel_tests/softmax_op_test.py b/tensorflow/python/kernel_tests/softmax_op_test.py
index dc4d4dbeab..427c07cfb8 100644
--- a/tensorflow/python/kernel_tests/softmax_op_test.py
+++ b/tensorflow/python/kernel_tests/softmax_op_test.py
@@ -24,14 +24,12 @@ import numpy as np
from tensorflow.python.framework import dtypes
from tensorflow.python.framework import errors_impl
-from tensorflow.python.framework import test_util
from tensorflow.python.ops import array_ops
from tensorflow.python.ops import nn_ops
from tensorflow.python.platform import test
from tensorflow.python.platform import tf_logging as logging
-@test_util.with_c_api
class SoftmaxTest(test.TestCase):
def _npSoftmax(self, features, dim=-1, log=False):