Remove compatibility check for if and while

PiperOrigin-RevId: 265757988
This commit is contained in:
Yanhua Sun 2019-08-27 13:49:06 -07:00 committed by TensorFlower Gardener
parent e9c7e5357a
commit c7f4fe381a
4 changed files with 113 additions and 132 deletions

View File

@ -20,7 +20,6 @@ from __future__ import division
from __future__ import print_function
from tensorflow.core.protobuf import config_pb2
from tensorflow.python.compat import compat as forward_compat
from tensorflow.python.eager import backprop
from tensorflow.python.eager import context
from tensorflow.python.eager import def_function
@ -1425,6 +1424,4 @@ def _has_node_with_op(run_metadata, op_type):
if __name__ == "__main__":
# Forward compat date for StatelessIf.
with forward_compat.forward_compatibility_horizon(2019, 7, 23):
test.main()

View File

@ -22,7 +22,6 @@ from absl.testing import parameterized
from tensorflow.core.protobuf import config_pb2
from tensorflow.core.protobuf import rewriter_config_pb2
from tensorflow.python.compat import compat
from tensorflow.python.eager import backprop
from tensorflow.python.eager import context
from tensorflow.python.eager import def_function
@ -241,7 +240,6 @@ class WhileV2Test(test.TestCase, parameterized.TestCase):
self.assertSequenceEqual(self.evaluate(grad_grad), [48.])
def testMultipleWhileLoopsWithFunc(self):
if compat.forward_compatible(2019, 8, 23):
x = constant_op.constant(2.)
@def_function.function
@ -267,7 +265,6 @@ class WhileV2Test(test.TestCase, parameterized.TestCase):
self.assertEmpty(while_2.control_inputs)
def testMultipleWhileLoopsWithDeps(self):
if compat.forward_compatible(2019, 8, 23):
x = variables.Variable(2.)
c = constant_op.constant(2.)
@ -295,7 +292,6 @@ class WhileV2Test(test.TestCase, parameterized.TestCase):
self.assertIs(while_2.control_inputs[0], while_1)
def testMultipleWhileLoopsWithVarsDeps(self):
if compat.forward_compatible(2019, 8, 23):
x1 = variables.Variable(2.)
x2 = variables.Variable(3.)
c = constant_op.constant(2.)
@ -804,7 +800,6 @@ class WhileV2Test(test.TestCase, parameterized.TestCase):
lambda i: i + 1, [constant_op.constant(0)],
return_same_structure=False)
while_op = output.op.inputs[0].op
if compat.forward_compatible(2019, 8, 23):
self.assertEqual(while_op.type, "StatelessWhile")
return while_op
@ -886,7 +881,6 @@ class WhileV2Test(test.TestCase, parameterized.TestCase):
@test_util.run_deprecated_v1
def testForwardPassRewrite(self):
if compat.forward_compatible(2019, 8, 23):
x = constant_op.constant(1.0, name="x")
output = while_v2.while_loop(lambda x: x < 10.0,
lambda x: x * 2.0,

View File

@ -25,7 +25,6 @@ from __future__ import print_function
import collections
from tensorflow.python.compat import compat
from tensorflow.python.framework import dtypes
from tensorflow.python.framework import func_graph as func_graph_module
from tensorflow.python.framework import function_def_to_graph
@ -256,11 +255,7 @@ def _build_cond(pred,
false_stateful_ops = [
op for op in false_graph.get_operations() if op._is_stateful
]
# TODO(srbs): Remove this after July 22, 2019. This is required to abide by
# 3-week forward compat window of new TF python op generating code with
# stale runtime binaries.
if (true_stateful_ops or false_stateful_ops or
not compat.forward_compatible(2019, 7, 22)):
if (true_stateful_ops or false_stateful_ops):
op_fn = gen_functional_ops._if
else:
op_fn = gen_functional_ops.stateless_if

View File

@ -24,7 +24,6 @@ from __future__ import division
from __future__ import print_function
from tensorflow.core.framework import attr_value_pb2
from tensorflow.python.compat import compat
from tensorflow.python.framework import constant_op
from tensorflow.python.framework import dtypes
from tensorflow.python.framework import func_graph as func_graph_module
@ -277,11 +276,7 @@ def while_loop(cond,
body_stateful_ops = [
op for op in body_graph.get_operations() if op._is_stateful
]
# TODO(yanhuasun): Remove this after Aug 23, 2019. This is required to
# abide by 3-week forward compat window of new TF python op generating
# code with stale runtime binaries.
if (cond_stateful_ops or body_stateful_ops or
not compat.forward_compatible(2019, 8, 23)):
if (cond_stateful_ops or body_stateful_ops):
op_fn = gen_functional_ops._while
else:
op_fn = gen_functional_ops.stateless_while