def testFold_1(self):
     with self.test_session():
         elems = tf.constant([1, 2, 3, 4, 5, 6], name="data")
         r = control_flow_ops.fold(lambda a, x: tf.mul(tf.add(a, x), 2), elems, [1])
         result = r.eval()
     self.assertTrue(check_op_order(elems.graph))
     self.assertAllEqual(np.array([208]), result)
 def testFold_1(self):
   with self.test_session():
     elems = tf.constant([1, 2, 3, 4, 5, 6], name="data")
     r = control_flow_ops.fold(
         lambda a, x: tf.mul(tf.add(a, x), 2), elems, [1])
     result = r.eval()
   self.assertTrue(check_op_order(elems.graph))
   self.assertAllEqual(np.array([208]), result)
  def testFold_2(self):
    with self.test_session():
      elems = tf.constant([1, 2, 3, 4, 5, 6], name="data")
      ten = tf.convert_to_tensor(10)

      def compute(a, x):
        r = tf.mul(x, ten)
        return tf.add(a, r)

      r = control_flow_ops.fold(compute, elems, [1])
      result = r.eval()
    self.assertTrue(check_op_order(elems.graph))
    self.assertAllEqual([201], result)
  def testFold_2(self):
    with self.test_session():
      elems = tf.constant([1, 2, 3, 4, 5, 6], name="data")
      ten = tf.convert_to_tensor(10)

      def compute(a, x):
        r = tf.mul(x, ten)
        return tf.add(a, r)

      r = control_flow_ops.fold(compute, elems, [1])
      result = r.eval()
    self.assertTrue(check_op_order(elems.graph))
    self.assertAllEqual([201], result)