MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / _assert

Function _assert

tensorflow/python/ops/image_ops_impl.py:63–84  ·  view source on GitHub ↗

A polymorphic assert, works with tensors and boolean expressions. If `cond` is not a tensor, behave like an ordinary assert statement, except that a empty list is returned. If `cond` is a tensor, return a list containing a single TensorFlow assert op. Args: cond: Something evaluates to

(cond, ex_type, msg)

Source from the content-addressed store, hash-verified

61
62# pylint: disable=invalid-name
63def _assert(cond, ex_type, msg):
64 """A polymorphic assert, works with tensors and boolean expressions.
65
66 If `cond` is not a tensor, behave like an ordinary assert statement, except
67 that a empty list is returned. If `cond` is a tensor, return a list
68 containing a single TensorFlow assert op.
69
70 Args:
71 cond: Something evaluates to a boolean value. May be a tensor.
72 ex_type: The exception class to use.
73 msg: The error message.
74
75 Returns:
76 A list, containing at most one assert op.
77 """
78 if _is_tensor(cond):
79 return [control_flow_ops.Assert(cond, [msg])]
80 else:
81 if not cond:
82 raise ex_type(msg)
83 else:
84 return []
85
86
87def _is_tensor(x):

Callers 5

pad_to_bounding_boxFunction · 0.85
crop_to_bounding_boxFunction · 0.85
adjust_gammaFunction · 0.85

Calls 1

_is_tensorFunction · 0.70

Tested by

no test coverage detected