Exemplo n.º 1
0
    def testLoweringDisabledWithSingleThreadedExecutorContext(self):
        with self.session(graph=ops.Graph()) as sess:

            @function.defun
            def _add_cond(x):
                return cond_v2.cond_v2(constant_op.constant(True, name="pred"),
                                       lambda: x, lambda: x + 1)

            x = array_ops.placeholder(shape=None, dtype=dtypes.float32)
            with context.function_executor_type("SINGLE_THREADED_EXECUTOR"):
                out_cond = _add_cond(x)

            # The fact that sess.run() succeeds means lowering is disabled, because
            # the single threaded executor does not support cond v1 ops.
            sess.run(out_cond, feed_dict={x: 1.0})
Exemplo n.º 2
0
  def testLoweringDisabledWithSingleThreadedExecutorContext(self):
    with self.session(graph=ops.Graph()) as sess:
      @function.defun
      def _add_cond(x):
        return cond_v2.cond_v2(
            constant_op.constant(True, name="pred"),
            lambda: x,
            lambda: x + 1)

      x = array_ops.placeholder(shape=None, dtype=dtypes.float32)
      with context.function_executor_type("SINGLE_THREADED_EXECUTOR"):
        out_cond = _add_cond(x)

      # The fact that sess.run() succeeds means lowering is disabled, because
      # the single threaded executor does not support cond v1 ops.
      sess.run(out_cond, feed_dict={x: 1.0})