a = constant_op.constant(0.0, shape=[2, 3])
# NOTE(mrry): The original_op is nonsense, but used here to test that the
# errors are reported correctly.
- # pylint: disable=protected-access
with sess.graph._original_op(a.op):
b = array_ops.identity(a, name='id')
with sess.graph._original_op(b.op):
c = array_ops.placeholder(dtypes.float32)
- # pylint: enable=protected-access
def exc_predicate(e):
return (e.op == c.op and e.op._original_op == b.op and
# Ensure that errors from building the graph get propagated.
data = array_ops.placeholder(dtypes.float32, shape=[])
# pylint: disable=protected-access
- enter_1 = gen_control_flow_ops._enter(data, 'foo_1', False)
- enter_2 = gen_control_flow_ops._enter(data, 'foo_2', False)
+ enter_1 = gen_control_flow_ops.enter(data, 'foo_1', False)
+ enter_2 = gen_control_flow_ops.enter(data, 'foo_2', False)
# pylint: enable=protected-access
res = math_ops.add(enter_1, enter_2)
with self.assertRaisesOpError('has inputs from different frames'):
enter_v = control_flow_ops._Enter(v, "foo_1", is_constant=True)
nine = constant_op.constant(9)
- enter_nine = gen_control_flow_ops._enter(nine, "foo_1")
+ enter_nine = gen_control_flow_ops.enter(nine, "foo_1")
op = state_ops.assign(enter_v, enter_nine)
v2 = control_flow_ops.with_dependencies([op], enter_v)
v3 = control_flow_ops.exit(v2)
def testEnterMulExit(self):
with self.test_session():
data = constant_op.constant([1, 2, 3, 4, 5, 6], name="data")
- enter_data = gen_control_flow_ops._enter(data, "foo_1", False)
+ enter_data = gen_control_flow_ops.enter(data, "foo_1", False)
five = constant_op.constant(5)
- enter_five = gen_control_flow_ops._enter(five, "foo_1", False)
+ enter_five = gen_control_flow_ops.enter(five, "foo_1", False)
mul_op = math_ops.multiply(enter_data, enter_five)
exit_op = control_flow_ops.exit(mul_op)
v = variables.Variable([0.0, 0.0], dtype=dtypes.float32)
# If is_constant=True, the shape information should be propagated.
- enter_v_constant = gen_control_flow_ops._enter(
+ enter_v_constant = gen_control_flow_ops.enter(
v, "frame1", is_constant=True)
self.assertEqual(enter_v_constant.shape, [2])
# Otherwise, the shape should be unknown.
- enter_v_non_constant = gen_control_flow_ops._enter(
+ enter_v_non_constant = gen_control_flow_ops.enter(
v, "frame2", is_constant=False)
self.assertEqual(enter_v_non_constant.shape, None)
false = ops.convert_to_tensor(False)
n = constant_op.constant(10)
- enter_false = gen_control_flow_ops._enter(false, "foo_1", False)
- enter_n = gen_control_flow_ops._enter(n, "foo_1", False)
+ enter_false = gen_control_flow_ops.enter(false, "foo_1", False)
+ enter_n = gen_control_flow_ops.enter(n, "foo_1", False)
merge_n = control_flow_ops.merge([enter_n, enter_n], name="merge_n")[0]
switch_n = control_flow_ops.switch(merge_n, enter_false)
one = constant_op.constant(1)
n = constant_op.constant(10)
- enter_i = gen_control_flow_ops._enter(zero, "foo", False)
- enter_one = gen_control_flow_ops._enter(one, "foo", True)
- enter_n = gen_control_flow_ops._enter(n, "foo", True)
+ enter_i = gen_control_flow_ops.enter(zero, "foo", False)
+ enter_one = gen_control_flow_ops.enter(one, "foo", True)
+ enter_n = gen_control_flow_ops.enter(n, "foo", True)
with ops.device(test.gpu_device_name()):
merge_i = control_flow_ops.merge([enter_i, enter_i])[0]
one = constant_op.constant(1)
n = constant_op.constant(10)
- enter_i = gen_control_flow_ops._enter(zero, "foo", False)
- enter_one = gen_control_flow_ops._enter(one, "foo", True)
- enter_n = gen_control_flow_ops._enter(n, "foo", True)
+ enter_i = gen_control_flow_ops.enter(zero, "foo", False)
+ enter_one = gen_control_flow_ops.enter(one, "foo", True)
+ enter_n = gen_control_flow_ops.enter(n, "foo", True)
merge_i = control_flow_ops.merge([enter_i, enter_i])[0]
def testDifferentFrame(self):
with self.test_session():
data = array_ops.placeholder(dtypes.float32, shape=[])
- enter_1 = gen_control_flow_ops._enter(data, "foo_1", False)
- enter_2 = gen_control_flow_ops._enter(data, "foo_2", False)
+ enter_1 = gen_control_flow_ops.enter(data, "foo_1", False)
+ enter_2 = gen_control_flow_ops.enter(data, "foo_2", False)
res = math_ops.add(enter_1, enter_2)
with self.assertRaisesOpError("has inputs from different frames"):
res.eval(feed_dict={data: 1.0})
data = ops.internal_convert_to_tensor_or_indexed_slices(data, as_ref=True)
if isinstance(data, ops.Tensor):
if data.dtype._is_ref_dtype and use_ref: # pylint: disable=protected-access
- result = gen_control_flow_ops._ref_enter(
+ result = gen_control_flow_ops.ref_enter(
data, frame_name, is_constant, parallel_iterations, name=name)
else:
- result = gen_control_flow_ops._enter(
+ result = gen_control_flow_ops.enter(
data, frame_name, is_constant, parallel_iterations, name=name)
if use_input_shape:
result.set_shape(data.get_shape())
parallel_iterations=parallel_iterations,
use_input_shape=use_input_shape,
name=name)
- indices = gen_control_flow_ops._enter(
+ indices = gen_control_flow_ops.enter(
data.indices,
frame_name,
is_constant,
if isinstance(data, ops.IndexedSlices):
dense_shape = data.dense_shape
if dense_shape is not None:
- dense_shape = gen_control_flow_ops._enter(
+ dense_shape = gen_control_flow_ops.enter(
dense_shape,
frame_name,
is_constant,
dense_shape.set_shape(data.dense_shape.get_shape())
return ops.IndexedSlices(values, indices, dense_shape)
else:
- dense_shape = gen_control_flow_ops._enter(
+ dense_shape = gen_control_flow_ops.enter(
data.dense_shape,
frame_name,
is_constant,