aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/contrib/autograph
diff options
context:
space:
mode:
authorGravatar A. Unique TensorFlower <gardener@tensorflow.org>2018-08-21 19:53:48 -0700
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2018-08-21 20:03:09 -0700
commitba9501e0a6c457a0bb051760bf9312d31c6211bf (patch)
tree4384fad21a1645d9c35172a8820d2f1b19e04975 /tensorflow/contrib/autograph
parent47c0bda0e7f736a9328aaf76aba7c8006e24556f (diff)
Move from deprecated self.test_session() to self.cached_session().
self.test_session() has been deprecated in 9962eb5e84b15e309410071b06c2ed2d6148ed44 as its name confuses readers of the test. Moving to cached_session() instead which is more explicit about: * the fact that the session may be reused. * the session is not closed even when doing a "with self.test_session()" statement. PiperOrigin-RevId: 209703613
Diffstat (limited to 'tensorflow/contrib/autograph')
-rw-r--r--tensorflow/contrib/autograph/converters/builtin_functions_test.py6
-rw-r--r--tensorflow/contrib/autograph/converters/call_trees_test.py6
-rw-r--r--tensorflow/contrib/autograph/converters/control_flow_test.py4
-rw-r--r--tensorflow/contrib/autograph/converters/lists_test.py6
-rw-r--r--tensorflow/contrib/autograph/converters/logical_expressions_test.py4
-rw-r--r--tensorflow/contrib/autograph/converters/side_effect_guards_test.py12
-rw-r--r--tensorflow/contrib/autograph/converters/slices_test.py2
7 files changed, 20 insertions, 20 deletions
diff --git a/tensorflow/contrib/autograph/converters/builtin_functions_test.py b/tensorflow/contrib/autograph/converters/builtin_functions_test.py
index d5c3e2c250..d0a0cbbeb6 100644
--- a/tensorflow/contrib/autograph/converters/builtin_functions_test.py
+++ b/tensorflow/contrib/autograph/converters/builtin_functions_test.py
@@ -36,7 +36,7 @@ class BuiltinFunctionsTest(converter_testing.TestCase):
with self.converted(test_fn, builtin_functions, {'len': len},
array_ops.shape) as result:
- with self.test_session() as sess:
+ with self.cached_session() as sess:
ops = result.test_fn(constant_op.constant([0, 0, 0]))
self.assertEqual(sess.run(ops), 3)
@@ -49,7 +49,7 @@ class BuiltinFunctionsTest(converter_testing.TestCase):
return print(a)
with self.converted(test_fn, builtin_functions, {'print': print}) as result:
- with self.test_session() as sess:
+ with self.cached_session() as sess:
with self.assertPrints('a\n'):
sess.run(result.test_fn('a'))
@@ -62,7 +62,7 @@ class BuiltinFunctionsTest(converter_testing.TestCase):
return print(a, b, c)
with self.converted(test_fn, builtin_functions, {'print': print}) as result:
- with self.test_session() as sess:
+ with self.cached_session() as sess:
with self.assertPrints('a 1 [2, 3]\n'):
sess.run(
result.test_fn(
diff --git a/tensorflow/contrib/autograph/converters/call_trees_test.py b/tensorflow/contrib/autograph/converters/call_trees_test.py
index 8cdba659ee..ca4d1f2932 100644
--- a/tensorflow/contrib/autograph/converters/call_trees_test.py
+++ b/tensorflow/contrib/autograph/converters/call_trees_test.py
@@ -91,7 +91,7 @@ class CallTreesTest(converter_testing.TestCase):
setattr(a, 'foo', 'bar')
with self.converted(test_fn, call_trees, {'setattr': setattr}) as result:
- with self.test_session() as sess:
+ with self.cached_session() as sess:
class Dummy(object):
pass
@@ -110,7 +110,7 @@ class CallTreesTest(converter_testing.TestCase):
with self.converted(test_fn, call_trees, {'np': np},
dtypes.int64) as result:
- with self.test_session() as sess:
+ with self.cached_session() as sess:
self.assertTrue(isinstance(result.test_fn(), ops.Tensor))
self.assertIn(sess.run(result.test_fn()), (0, 1, 2))
@@ -129,7 +129,7 @@ class CallTreesTest(converter_testing.TestCase):
node = call_trees.transform(node, ctx)
with self.compiled(node, ns) as result:
- with self.test_session() as sess:
+ with self.cached_session() as sess:
result_tensor = result.test_fn(constant_op.constant(1))
self.assertEquals(sess.run(result_tensor), 3)
diff --git a/tensorflow/contrib/autograph/converters/control_flow_test.py b/tensorflow/contrib/autograph/converters/control_flow_test.py
index ade3501426..6cb907f69a 100644
--- a/tensorflow/contrib/autograph/converters/control_flow_test.py
+++ b/tensorflow/contrib/autograph/converters/control_flow_test.py
@@ -33,7 +33,7 @@ class ControlFlowTest(converter_testing.TestCase):
inputs = (inputs,)
with self.converted(test_fn, control_flow, {},
constant_op.constant) as result:
- with self.test_session() as sess:
+ with self.cached_session() as sess:
self.assertEqual(sess.run(result.test_fn(*inputs)), expected)
def test_while_basic(self):
@@ -89,7 +89,7 @@ class ControlFlowTest(converter_testing.TestCase):
return obj
with self.converted(test_fn, control_flow, {}) as result:
- with self.test_session() as sess:
+ with self.cached_session() as sess:
res_obj = result.test_fn(constant_op.constant(1), TestClass(0, 0))
self.assertEqual(sess.run((res_obj.a, res_obj.b)), (-1, 0))
res_obj = result.test_fn(constant_op.constant(-1), TestClass(0, 0))
diff --git a/tensorflow/contrib/autograph/converters/lists_test.py b/tensorflow/contrib/autograph/converters/lists_test.py
index 996e99ee61..c5e2dcf75e 100644
--- a/tensorflow/contrib/autograph/converters/lists_test.py
+++ b/tensorflow/contrib/autograph/converters/lists_test.py
@@ -65,7 +65,7 @@ class ListTest(converter_testing.TestCase):
ns = {'special_functions': special_functions}
with self.converted(test_fn, lists, ns) as result:
- with self.test_session() as sess:
+ with self.cached_session() as sess:
tl = result.test_fn()
r = list_ops.tensor_list_stack(tl, dtypes.int32)
self.assertAllEqual(sess.run(r), [1, 2, 3])
@@ -88,7 +88,7 @@ class ListTest(converter_testing.TestCase):
node = lists.transform(node, ctx)
with self.compiled(node, ns, dtypes.int32) as result:
- with self.test_session() as sess:
+ with self.cached_session() as sess:
ts, tl = result.test_fn()
r = list_ops.tensor_list_stack(tl, dtypes.int32)
self.assertAllEqual(sess.run(r), [1, 2])
@@ -122,7 +122,7 @@ class ListTest(converter_testing.TestCase):
node = lists.transform(node, ctx)
with self.compiled(node, {}, array_ops.stack, dtypes.int32) as result:
- with self.test_session() as sess:
+ with self.cached_session() as sess:
self.assertAllEqual(sess.run(result.test_fn()), [1, 2, 3])
# TODO(mdan): Add a test with tf.stack with axis kwarg.
diff --git a/tensorflow/contrib/autograph/converters/logical_expressions_test.py b/tensorflow/contrib/autograph/converters/logical_expressions_test.py
index ca07de5e8a..8f9eee7081 100644
--- a/tensorflow/contrib/autograph/converters/logical_expressions_test.py
+++ b/tensorflow/contrib/autograph/converters/logical_expressions_test.py
@@ -33,7 +33,7 @@ class GradientsFunctionTest(converter_testing.TestCase):
with self.converted(test_fn, logical_expressions, {},
math_ops.equal) as result:
- with self.test_session() as sess:
+ with self.cached_session() as sess:
self.assertTrue(sess.run(result.test_fn(1, 1)))
self.assertFalse(sess.run(result.test_fn(1, 2)))
@@ -44,7 +44,7 @@ class GradientsFunctionTest(converter_testing.TestCase):
with self.converted(test_fn, logical_expressions, {}, math_ops.logical_or,
math_ops.logical_and) as result:
- with self.test_session() as sess:
+ with self.cached_session() as sess:
self.assertTrue(sess.run(result.test_fn(True, False, True)))
diff --git a/tensorflow/contrib/autograph/converters/side_effect_guards_test.py b/tensorflow/contrib/autograph/converters/side_effect_guards_test.py
index bee512abbc..5fe5114d4b 100644
--- a/tensorflow/contrib/autograph/converters/side_effect_guards_test.py
+++ b/tensorflow/contrib/autograph/converters/side_effect_guards_test.py
@@ -46,7 +46,7 @@ class SideEffectGuardsTest(converter_testing.TestCase):
self.assertEqual(len(node.body), 1)
with self.compiled(node, {}, state_ops.assign) as result:
- with self.test_session() as sess:
+ with self.cached_session() as sess:
v = variable_scope.get_variable('test', initializer=2)
sess.run(v.initializer)
sess.run(result.test_fn(v))
@@ -67,7 +67,7 @@ class SideEffectGuardsTest(converter_testing.TestCase):
self.assertEqual(len(node.body), 1)
with self.compiled(node, {}, state_ops.assign) as result:
- with self.test_session() as sess:
+ with self.cached_session() as sess:
v = variable_scope.get_variable('test', initializer=2)
sess.run(v.initializer)
sess.run(result.test_fn(v))
@@ -87,7 +87,7 @@ class SideEffectGuardsTest(converter_testing.TestCase):
self.assertEqual(len(node.body), 1)
with self.compiled(node, {}, control_flow_ops.Assert) as result:
- with self.test_session() as sess:
+ with self.cached_session() as sess:
with self.assertRaisesRegexp(errors_impl.InvalidArgumentError,
'expected in throw'):
sess.run(result.test_fn(constant_op.constant(-1)))
@@ -107,7 +107,7 @@ class SideEffectGuardsTest(converter_testing.TestCase):
self.assertEqual(len(node.body), 1)
with self.compiled(node, {}, state_ops.assign_add) as result:
- with self.test_session() as sess:
+ with self.cached_session() as sess:
v = variable_scope.get_variable('test', initializer=2)
sess.run(v.initializer)
sess.run(result.test_fn(v))
@@ -128,7 +128,7 @@ class SideEffectGuardsTest(converter_testing.TestCase):
self.assertEqual(len(node.body[0].body), 1)
with self.compiled(node, {}, state_ops.assign, ops.name_scope) as result:
- with self.test_session() as sess:
+ with self.cached_session() as sess:
v = variable_scope.get_variable('test', initializer=2)
sess.run(v.initializer)
sess.run(result.test_fn(v))
@@ -151,7 +151,7 @@ class SideEffectGuardsTest(converter_testing.TestCase):
with self.compiled(node, {}, state_ops.assign,
state_ops.assign_add) as result:
- with self.test_session() as sess:
+ with self.cached_session() as sess:
v = variable_scope.get_variable('test', initializer=2)
sess.run(v.initializer)
sess.run(result.test_fn(v))
diff --git a/tensorflow/contrib/autograph/converters/slices_test.py b/tensorflow/contrib/autograph/converters/slices_test.py
index c822d53a4a..d74b2e025e 100644
--- a/tensorflow/contrib/autograph/converters/slices_test.py
+++ b/tensorflow/contrib/autograph/converters/slices_test.py
@@ -45,7 +45,7 @@ class SliceTest(converter_testing.TestCase):
node = slices.transform(node, ctx)
with self.compiled(node, {}, dtypes.int32) as result:
- with self.test_session() as sess:
+ with self.cached_session() as sess:
tl = list_ops.tensor_list_from_tensor(
[1, 2], element_shape=constant_op.constant([], dtype=dtypes.int32))
y = result.test_fn(tl)