diff options
Diffstat (limited to 'tensorflow/python/ops/control_flow_ops.py')
-rw-r--r-- | tensorflow/python/ops/control_flow_ops.py | 41 |
1 files changed, 1 insertions, 40 deletions
diff --git a/tensorflow/python/ops/control_flow_ops.py b/tensorflow/python/ops/control_flow_ops.py index 8afb079d20..10d8e01304 100644 --- a/tensorflow/python/ops/control_flow_ops.py +++ b/tensorflow/python/ops/control_flow_ops.py @@ -60,7 +60,6 @@ from tensorflow.core.protobuf import control_flow_pb2 from tensorflow.python.eager import context from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes -from tensorflow.python.framework import errors from tensorflow.python.framework import ops from tensorflow.python.framework import sparse_tensor from tensorflow.python.framework import tensor_shape @@ -87,29 +86,6 @@ from tensorflow.python.util import tf_should_use _basetuple = tuple -def _summarize_eager(tensor, summarize=None): - """Returns a summarized string representation of eager `tensor`. - - Args: - tensor: EagerTensor to summarize - summarize: Include these many first elements of `array` - """ - # reshape((-1,)) is the fastest way to get a flat array view - if tensor._rank(): # pylint: disable=protected-access - flat = tensor.numpy().reshape((-1,)) - lst = [str(x) for x in flat[:summarize]] - if len(lst) < flat.size: - lst.append("...") - else: - # tensor.numpy() returns a scalar for zero dimensional arrays - if summarize != 0: - lst = [str(tensor.numpy())] - else: - lst = [] - - return ", ".join(lst) - - # pylint: disable=protected-access @@ -122,8 +98,7 @@ def Assert(condition, data, summarize=None, name=None): If `condition` evaluates to false, print the list of tensors in `data`. `summarize` determines how many entries of the tensors to print. - NOTE: In graph mode, to ensure that Assert executes, one usually attaches - a dependency: + NOTE: To ensure that Assert executes, one usually attaches a dependency: ```python # Ensure maximum element of x is smaller or equal to 1 @@ -142,21 +117,7 @@ def Assert(condition, data, summarize=None, name=None): assert_op: An `Operation` that, when executed, raises a `tf.errors.InvalidArgumentError` if `condition` is not true. @compatibility{eager} returns None. - - Raises: - @compatibility{eager} `tf.errors.InvalidArgumentError` if `condition` - is not true """ - if context.in_eager_mode(): - if not condition: - xs = ops.convert_n_to_tensor(data) - data_str = [_summarize_eager(x, summarize) for x in xs] - raise errors.InvalidArgumentError( - node_def=None, op=None, - message="Expected '%s' to be true. Summarized data: %s" % ( - condition, "\n".join(data_str))) - return - with ops.name_scope(name, "Assert", [condition, data]) as name: xs = ops.convert_n_to_tensor(data) if all([x.dtype in {dtypes.string, dtypes.int32} for x in xs]): |