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

Function check_mutation

tensorflow/python/framework/func_graph.py:988–1002  ·  view source on GitHub ↗

Check if two list of arguments are exactly the same.

(n1, n2)

Source from the content-addressed store, hash-verified

986
987
988def check_mutation(n1, n2):
989 """Check if two list of arguments are exactly the same."""
990 errmsg = ("Function to be traced should not modify structure of input "
991 "arguments. Check if your function has list and dictionary "
992 "operations that alter input arguments, "
993 "such as `list.pop`, `list.append`")
994 try:
995 nest.assert_same_structure(n1, n2, expand_composites=True)
996 except ValueError:
997 raise ValueError(errmsg)
998
999 for arg1, arg2 in zip(nest.flatten(n1, expand_composites=True),
1000 nest.flatten(n2, expand_composites=True)):
1001 if arg1 is not arg2:
1002 raise ValueError(errmsg)
1003
1004
1005# TODO(edloper): If TensorArray becomes a CompositeTensor, then delete this.

Callers 1

func_graph_from_py_funcFunction · 0.85

Calls 1

flattenMethod · 0.45

Tested by

no test coverage detected