MCPcopy Create free account
hub / github.com/google-research/language / assert_same

Function assert_same

language/common/utils/nest_utils.py:137–151  ·  view source on GitHub ↗

Assert that both structures are equivalent. This function is more strict than tf.nest.assert_same_structure since it also requires that Tensors have the same dtype and shape. Args: nest1: A nested structure. nest2: A nested structure.

(nest1, nest2)

Source from the content-addressed store, hash-verified

135
136
137def assert_same(nest1, nest2):
138 """Assert that both structures are equivalent.
139
140 This function is more strict than tf.nest.assert_same_structure since it also
141 requires that Tensors have the same dtype and shape.
142
143 Args:
144 nest1: A nested structure.
145 nest2: A nested structure.
146 """
147 tf.nest.assert_same_structure(nest1, nest2)
148 for t1, t2 in zip(tf.nest.flatten(nest1), tf.nest.flatten(nest2)):
149 assert t1.dtype == t2.dtype
150 if isinstance(t1, tf.Tensor) and isinstance(t2, tf.Tensor):
151 assert t1.shape == t2.shape

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…