Exemplo n.º 1
0
 def _testSameNameStacks(self, use_gpu):
   with self.test_session(use_gpu=use_gpu):
     h1 = gen_data_flow_ops._stack(dtypes.float32, stack_name="foo")
     c1 = gen_data_flow_ops._stack_push(h1, 4.0)
     h2 = gen_data_flow_ops._stack(dtypes.float32, stack_name="foo")
     c2 = gen_data_flow_ops._stack_push(h2, 5.0)
     r = c1 + c2
     self.assertNotEqual(h1.eval()[1], h2.eval()[1])
Exemplo n.º 2
0
 def _testDuplicateStack(self, use_gpu):
     with self.test_session(use_gpu=use_gpu):
         h1 = gen_data_flow_ops._stack(tf.float32, stack_name="foo")
         c1 = gen_data_flow_ops._stack_push(h1, 4.0)
         h2 = gen_data_flow_ops._stack(tf.float32, stack_name="foo")
         c2 = gen_data_flow_ops._stack_push(h2, 5.0)
         r = c1 + c2
         with self.assertRaises(errors.AlreadyExistsError):
             r.eval()
Exemplo n.º 3
0
 def _testDuplicateStack(self, use_gpu):
   with self.test_session(use_gpu=use_gpu):
     h1 = gen_data_flow_ops._stack(tf.float32, stack_name="foo")
     c1 = gen_data_flow_ops._stack_push(h1, 4.0)
     h2 = gen_data_flow_ops._stack(tf.float32, stack_name="foo")
     c2 = gen_data_flow_ops._stack_push(h2, 5.0)
     r = c1 + c2
     with self.assertRaises(errors.AlreadyExistsError):
       r.eval()
Exemplo n.º 4
0
 def _testMultiStack(self, use_gpu):
   with self.test_session(use_gpu=use_gpu):
     h1 = gen_data_flow_ops._stack(dtypes.float32, stack_name="foo")
     c1 = gen_data_flow_ops._stack_push(h1, 4.0)
     with ops.control_dependencies([c1]):
       c1 = gen_data_flow_ops._stack_pop(h1, dtypes.float32)
     h2 = gen_data_flow_ops._stack(dtypes.float32, stack_name="bar")
     c2 = gen_data_flow_ops._stack_push(h2, 5.0)
     with ops.control_dependencies([c2]):
       c2 = gen_data_flow_ops._stack_pop(h2, dtypes.float32)
     r = c1 + c2
     self.assertAllClose(9.0, r.eval())
Exemplo n.º 5
0
 def _testStackPushPop(self, use_gpu):
   with self.test_session(use_gpu=use_gpu):
     h = gen_data_flow_ops._stack(dtypes.float32, stack_name="foo")
     c = gen_data_flow_ops._stack_push(h, [[4.0, 5.0]])
     with ops.control_dependencies([c]):
       c1 = gen_data_flow_ops._stack_pop(h, dtypes.float32)
     self.assertAllClose([[4.0, 5.0]], c1.eval())
Exemplo n.º 6
0
 def _testPushCloseStack(self, use_gpu):
   with self.test_session(use_gpu=use_gpu) as sess:
     h = gen_data_flow_ops._stack(dtypes.float32, stack_name="foo")
     c = gen_data_flow_ops._stack_push(h, [[4.0, 5.0]])
     with ops.control_dependencies([c]):
       c1 = gen_data_flow_ops._stack_close(h)
     sess.run(c1)
Exemplo n.º 7
0
 def b(x):
     with ops.control_dependencies([x]):
         a = constant_op.constant(np.ones(2000),
                                  dtype=dtypes.float32)
         v = gen_data_flow_ops._stack_push(h, a, swap_memory=True)
     with ops.control_dependencies([v]):
         return math_ops.add(x, 1)
Exemplo n.º 8
0
 def _testStackPushPopSwap(self, use_gpu):
   with self.test_session(use_gpu=use_gpu):
     a = np.arange(2000)
     x = constant_op.constant(a, dtype=dtypes.float32)
     h = gen_data_flow_ops._stack(dtypes.float32, stack_name="foo")
     c = gen_data_flow_ops._stack_push(h, x, swap_memory=True)
     with ops.control_dependencies([c]):
       c1 = gen_data_flow_ops._stack_pop(h, dtypes.float32)
     self.assertAllClose(a, c1.eval())
Exemplo n.º 9
0
 def b(x):
   with ops.control_dependencies([x]):
     a = constant_op.constant(np.ones(2000), dtype=dtypes.float32)
     v = gen_data_flow_ops._stack_push(h, a, swap_memory=True)
   with ops.control_dependencies([v]):
     return math_ops.add(x, 1)
Exemplo n.º 10
0
 def b(i):
   ni = tf.add(i, 1)
   ni = control_flow_ops.with_dependencies(
       [gen_data_flow_ops._stack_push(s, i)], ni)
   return ni
 def b(i):
   ni = tf.add(i, 1)
   ni = control_flow_ops.with_dependencies(
       [gen_data_flow_ops._stack_push(s, i)], ni)
   return ni