aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/contrib/autograph
diff options
context:
space:
mode:
authorGravatar A. Unique TensorFlower <gardener@tensorflow.org>2018-09-10 14:36:52 -0700
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2018-09-10 15:01:47 -0700
commitacf0ee82092727afc2067316982407cf5e496f75 (patch)
treee5df1811ab47e259a1f30c46e22c251411ad326e /tensorflow/contrib/autograph
parentf1cc58bb4144de61a693076d8ff8a26b2644ebbb (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: 212336417
Diffstat (limited to 'tensorflow/contrib/autograph')
-rw-r--r--tensorflow/contrib/autograph/utils/misc_test.py4
-rw-r--r--tensorflow/contrib/autograph/utils/py_func_test.py8
-rw-r--r--tensorflow/contrib/autograph/utils/tensor_list_test.py8
3 files changed, 10 insertions, 10 deletions
diff --git a/tensorflow/contrib/autograph/utils/misc_test.py b/tensorflow/contrib/autograph/utils/misc_test.py
index 71e358c33e..968ea03df6 100644
--- a/tensorflow/contrib/autograph/utils/misc_test.py
+++ b/tensorflow/contrib/autograph/utils/misc_test.py
@@ -31,7 +31,7 @@ class MiscTest(test.TestCase):
new_a = alias_tensors(a)
self.assertFalse(new_a is a)
- with self.test_session() as sess:
+ with self.cached_session() as sess:
self.assertEqual(1, sess.run(new_a))
def test_alias_tensors(self):
@@ -46,7 +46,7 @@ class MiscTest(test.TestCase):
self.assertTrue(new_v is v)
self.assertTrue(new_s is s)
self.assertTrue(new_l is l)
- with self.test_session() as sess:
+ with self.cached_session() as sess:
self.assertEqual(1, sess.run(new_a))
diff --git a/tensorflow/contrib/autograph/utils/py_func_test.py b/tensorflow/contrib/autograph/utils/py_func_test.py
index 2468263142..f60b57bcce 100644
--- a/tensorflow/contrib/autograph/utils/py_func_test.py
+++ b/tensorflow/contrib/autograph/utils/py_func_test.py
@@ -31,7 +31,7 @@ class PyFuncTest(test.TestCase):
def test_fn(a, b, c):
return a + b + c
- with self.test_session() as sess:
+ with self.cached_session() as sess:
result = py_func.wrap_py_func(test_fn, dtypes.int64,
(1, constant_op.constant(1), 1))
self.assertEqual(3, sess.run(result))
@@ -52,7 +52,7 @@ class PyFuncTest(test.TestCase):
def test_fn(a, b):
return a * b.foo
- with self.test_session() as sess:
+ with self.cached_session() as sess:
result = py_func.wrap_py_func(test_fn, dtypes.int64, (7, TestClass()))
self.assertEqual(35, sess.run(result))
result = py_func.wrap_py_func(test_fn, dtypes.int64,
@@ -69,7 +69,7 @@ class PyFuncTest(test.TestCase):
def test_fn(a, b, c, d):
return a * b.foo + c * d.foo
- with self.test_session() as sess:
+ with self.cached_session() as sess:
result = py_func.wrap_py_func(test_fn, dtypes.int64, (7, TestClass(5)), {
'c': 11,
'd': TestClass(13)
@@ -89,7 +89,7 @@ class PyFuncTest(test.TestCase):
def test_fn(_):
side_counter[0] += 1
- with self.test_session() as sess:
+ with self.cached_session() as sess:
result = py_func.wrap_py_func(test_fn, None, (5,), use_dummy_return=True)
self.assertEqual(1, sess.run(result))
self.assertEqual([1], side_counter)
diff --git a/tensorflow/contrib/autograph/utils/tensor_list_test.py b/tensorflow/contrib/autograph/utils/tensor_list_test.py
index d58489eb68..faaf7b7877 100644
--- a/tensorflow/contrib/autograph/utils/tensor_list_test.py
+++ b/tensorflow/contrib/autograph/utils/tensor_list_test.py
@@ -42,18 +42,18 @@ class TensorListTest(test.TestCase):
l = list_ops.empty_tensor_list(self._shape(()), dtypes.int32)
l = tl.dynamic_list_append(l, 1)
s = list_ops.tensor_list_stack(l, element_dtype=dtypes.int32)
- with self.test_session() as sess:
+ with self.cached_session() as sess:
self.assertAllEqual(sess.run(s), [1])
l = tensor_array_ops.TensorArray(dtypes.int32, size=0, dynamic_size=True)
l = tl.dynamic_list_append(l, 1)
s = l.stack()
- with self.test_session() as sess:
+ with self.cached_session() as sess:
self.assertAllEqual(sess.run(s), [1])
l = tl.TensorList(self._shape(()), dtypes.int32)
l = tl.dynamic_list_append(l, 1)
- with self.test_session() as sess:
+ with self.cached_session() as sess:
self.assertAllEqual(sess.run(l[0]), 1)
def test_list_append_python(self):
@@ -107,7 +107,7 @@ class TensorListTest(test.TestCase):
l0 = l[0]
l[0] = b
l1 = l[0]
- with self.test_session() as sess:
+ with self.cached_session() as sess:
l0, l1, a, b = sess.run([l0, l1, a, b])
self.assertEqual(l0, a)
self.assertEqual(l1, b)