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

Function _check_ts_compatibility

tensorflow/contrib/graph_editor/reroute.py:41–66  ·  view source on GitHub ↗

Make sure the shape and dtype of the two tensor's lists are compatible. Args: ts0: an object convertible to a list of `tf.Tensor`. ts1: an object convertible to a list of `tf.Tensor`. Raises: ValueError: if any pair of tensors (same index in ts0 and ts1) have a dtype or a shap

(ts0, ts1)

Source from the content-addressed store, hash-verified

39
40
41def _check_ts_compatibility(ts0, ts1):
42 """Make sure the shape and dtype of the two tensor's lists are compatible.
43
44 Args:
45 ts0: an object convertible to a list of `tf.Tensor`.
46 ts1: an object convertible to a list of `tf.Tensor`.
47 Raises:
48 ValueError: if any pair of tensors (same index in ts0 and ts1) have
49 a dtype or a shape which is not compatible.
50 """
51 ts0 = _util.make_list_of_t(ts0)
52 ts1 = _util.make_list_of_t(ts1)
53 if len(ts0) != len(ts1):
54 raise ValueError("ts0 and ts1 have different sizes: {} != {}".format(
55 len(ts0), len(ts1)))
56 for t0, t1 in zip(ts0, ts1):
57 # check dtype
58 dtype0, dtype1 = t0.dtype, t1.dtype
59 if not dtype0.is_compatible_with(dtype1):
60 raise ValueError("Dtypes {} and {} are not compatible.".format(dtype0,
61 dtype1))
62 # check shape
63 shape0, shape1 = t0.get_shape(), t1.get_shape()
64 if not shape0.is_compatible_with(shape1):
65 raise ValueError("Shapes {} and {} are not compatible.".format(shape0,
66 shape1))
67
68
69class _RerouteMode(object):

Callers 1

_reroute_tsFunction · 0.85

Calls 3

formatMethod · 0.45
is_compatible_withMethod · 0.45
get_shapeMethod · 0.45

Tested by

no test coverage detected