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

Function is_same_structure

tensorflow/python/eager/function.py:242–257  ·  view source on GitHub ↗

Check two structures for equality, optionally of types and of values.

(structure1,
                      structure2,
                      check_values=False)

Source from the content-addressed store, hash-verified

240
241
242def is_same_structure(structure1,
243 structure2,
244 check_values=False):
245 """Check two structures for equality, optionally of types and of values."""
246 try:
247 nest.assert_same_structure(structure1, structure2, expand_composites=True)
248 except (ValueError, TypeError):
249 return False
250 if check_values:
251 flattened1 = nest.flatten(structure1, expand_composites=True)
252 flattened2 = nest.flatten(structure2, expand_composites=True)
253 # First check the types to avoid AttributeErrors.
254 if any(type(f1) != type(f2) for f1, f2 in zip(flattened1, flattened2)):
255 return False
256 return flattened1 == flattened2
257 return True
258
259
260def _parse_func_attrs(attributes):

Callers 1

get_concrete_functionMethod · 0.85

Calls 3

anyFunction · 0.85
typeFunction · 0.85
flattenMethod · 0.45

Tested by

no test coverage detected