Beispiel #1
0
 def testTwoTemporaryVariablesNoLeaks(self):
   with self.test_session(use_gpu=True):
     var1 = gen_state_ops.temporary_variable(
         [1, 2], dtypes.float32, var_name="var1")
     var2 = gen_state_ops.temporary_variable(
         [1, 2], dtypes.float32, var_name="var2")
     final = var1 + var2
     final.eval()
 def testTwoTemporaryVariablesNoLeaks(self):
   with test_util.use_gpu():
     var1 = gen_state_ops.temporary_variable(
         [1, 2], dtypes.float32, var_name="var1")
     var2 = gen_state_ops.temporary_variable(
         [1, 2], dtypes.float32, var_name="var2")
     final = var1 + var2
     self.evaluate(final)
Beispiel #3
0
 def testTwoTemporaryVariablesNoLeaks(self):
   with self.test_session(use_gpu=True):
     var1 = gen_state_ops.temporary_variable(
         [1, 2], dtypes.float32, var_name="var1")
     var2 = gen_state_ops.temporary_variable(
         [1, 2], dtypes.float32, var_name="var2")
     final = var1 + var2
     final.eval()
 def testTwoTemporaryVariablesNoLeaks(self):
   with test_util.use_gpu():
     var1 = gen_state_ops.temporary_variable(
         [1, 2], dtypes.float32, var_name="var1")
     var2 = gen_state_ops.temporary_variable(
         [1, 2], dtypes.float32, var_name="var2")
     final = var1 + var2
     self.evaluate(final)
 def testDuplicateTemporaryVariable(self):
   with test_util.use_gpu():
     var1 = gen_state_ops.temporary_variable(
         [1, 2], dtypes.float32, var_name="dup")
     var1 = state_ops.assign(var1, [[1.0, 2.0]])
     var2 = gen_state_ops.temporary_variable(
         [1, 2], dtypes.float32, var_name="dup")
     var2 = state_ops.assign(var2, [[3.0, 4.0]])
     final = var1 + var2
     with self.assertRaises(errors.AlreadyExistsError):
       self.evaluate(final)
 def testDuplicateTemporaryVariable(self):
   with test_util.use_gpu():
     var1 = gen_state_ops.temporary_variable(
         [1, 2], dtypes.float32, var_name="dup")
     var1 = state_ops.assign(var1, [[1.0, 2.0]])
     var2 = gen_state_ops.temporary_variable(
         [1, 2], dtypes.float32, var_name="dup")
     var2 = state_ops.assign(var2, [[3.0, 4.0]])
     final = var1 + var2
     with self.assertRaises(errors.AlreadyExistsError):
       self.evaluate(final)
Beispiel #7
0
 def testDestroyNonexistentTemporaryVariable(self):
     with test_util.use_gpu():
         var = gen_state_ops.temporary_variable([1, 2], dtypes.float32)
         final = gen_state_ops.destroy_temporary_variable(var,
                                                          var_name="bad")
         with self.assertRaises(errors.NotFoundError):
             self.evaluate(final)
 def testTemporaryVariableNoLeak(self):
     with self.test_session(use_gpu=True):
         var = gen_state_ops.temporary_variable([1, 2],
                                                dtypes.float32,
                                                var_name="bar")
         final = array_ops.identity(var)
         final.eval()
 def testDestroyNonexistentTemporaryVariable(self):
     with self.test_session(use_gpu=True):
         var = gen_state_ops.temporary_variable([1, 2], dtypes.float32)
         final = gen_state_ops.destroy_temporary_variable(var,
                                                          var_name="bad")
         with self.assertRaises(errors.NotFoundError):
             final.eval()
Beispiel #10
0
 def testTemporaryVariableNoLeak(self):
     with test_util.use_gpu():
         var = gen_state_ops.temporary_variable([1, 2],
                                                dtypes.float32,
                                                var_name="bar")
         final = array_ops.identity(var)
         self.evaluate(final)
Beispiel #11
0
 def testTemporaryVariable(self):
   with self.test_session(use_gpu=True):
     var = gen_state_ops.temporary_variable(
         [1, 2], dtypes.float32, var_name="foo")
     var = state_ops.assign(var, [[4.0, 5.0]])
     var = state_ops.assign_add(var, [[6.0, 7.0]])
     final = gen_state_ops.destroy_temporary_variable(var, var_name="foo")
     self.assertAllClose([[10.0, 12.0]], final.eval())
 def testDestroyTemporaryVariableTwice(self):
   with test_util.use_gpu():
     var = gen_state_ops.temporary_variable([1, 2], dtypes.float32)
     val1 = gen_state_ops.destroy_temporary_variable(var, var_name="dup")
     val2 = gen_state_ops.destroy_temporary_variable(var, var_name="dup")
     final = val1 + val2
     with self.assertRaises(errors.NotFoundError):
       self.evaluate(final)
 def testTemporaryVariable(self):
   with test_util.use_gpu():
     var = gen_state_ops.temporary_variable(
         [1, 2], dtypes.float32, var_name="foo")
     var = state_ops.assign(var, [[4.0, 5.0]])
     var = state_ops.assign_add(var, [[6.0, 7.0]])
     final = gen_state_ops.destroy_temporary_variable(var, var_name="foo")
     self.assertAllClose([[10.0, 12.0]], self.evaluate(final))
Beispiel #14
0
 def testTemporaryVariable(self):
   with self.test_session(use_gpu=True):
     var = gen_state_ops.temporary_variable(
         [1, 2], dtypes.float32, var_name="foo")
     var = state_ops.assign(var, [[4.0, 5.0]])
     var = state_ops.assign_add(var, [[6.0, 7.0]])
     final = gen_state_ops.destroy_temporary_variable(var, var_name="foo")
     self.assertAllClose([[10.0, 12.0]], final.eval())
Beispiel #15
0
 def testDestroyTemporaryVariableTwice(self):
   with test_util.use_gpu():
     var = gen_state_ops.temporary_variable([1, 2], dtypes.float32)
     val1 = gen_state_ops.destroy_temporary_variable(var, var_name="dup")
     val2 = gen_state_ops.destroy_temporary_variable(var, var_name="dup")
     final = val1 + val2
     with self.assertRaises(errors.NotFoundError):
       self.evaluate(final)
Beispiel #16
0
 def testTemporaryVariable(self):
   with test_util.use_gpu():
     var = gen_state_ops.temporary_variable(
         [1, 2], dtypes.float32, var_name="foo")
     var = state_ops.assign(var, [[4.0, 5.0]])
     var = state_ops.assign_add(var, [[6.0, 7.0]])
     final = gen_state_ops.destroy_temporary_variable(var, var_name="foo")
     self.assertAllClose([[10.0, 12.0]], self.evaluate(final))
Beispiel #17
0
 def _AccumulateNTemplate(self, inputs, init, shape, validate_shape):
   var = gen_state_ops.temporary_variable(
       shape=shape, dtype=inputs[0].dtype.base_dtype)
   ref = state_ops.assign(var, init, validate_shape=validate_shape)
   update_ops = [
       state_ops.assign_add(
           ref, tensor, use_locking=True).op for tensor in inputs
   ]
   with ops.control_dependencies(update_ops):
     return gen_state_ops.destroy_temporary_variable(ref, var_name=var.op.name)
 def _AccumulateNTemplate(self, inputs, init, shape, validate_shape):
   var = gen_state_ops.temporary_variable(
       shape=shape, dtype=inputs[0].dtype.base_dtype)
   ref = state_ops.assign(var, init, validate_shape=validate_shape)
   update_ops = [
       state_ops.assign_add(
           ref, tensor, use_locking=True).op for tensor in inputs
   ]
   with ops.control_dependencies(update_ops):
     return gen_state_ops.destroy_temporary_variable(ref, var_name=var.op.name)
Beispiel #19
0
 def testDestroyNonexistentTemporaryVariable(self):
   with self.test_session(use_gpu=True):
     var = gen_state_ops.temporary_variable([1, 2], dtypes.float32)
     final = gen_state_ops.destroy_temporary_variable(var, var_name="bad")
     with self.assertRaises(errors.NotFoundError):
       final.eval()
Beispiel #20
0
 def testTemporaryVariableNoLeak(self):
   with test_util.use_gpu():
     var = gen_state_ops.temporary_variable(
         [1, 2], dtypes.float32, var_name="bar")
     final = array_ops.identity(var)
     self.evaluate(final)
Beispiel #21
0
 def testDestroyNonexistentTemporaryVariable(self):
   with test_util.use_gpu():
     var = gen_state_ops.temporary_variable([1, 2], dtypes.float32)
     final = gen_state_ops.destroy_temporary_variable(var, var_name="bad")
     with self.assertRaises(errors.NotFoundError):
       self.evaluate(final)
Beispiel #22
0
 def testTemporaryVariableNoLeak(self):
   with self.test_session(use_gpu=True):
     var = gen_state_ops.temporary_variable(
         [1, 2], dtypes.float32, var_name="bar")
     final = array_ops.identity(var)
     final.eval()