MCPcopy Create free account
hub / github.com/apache/tvm-ffi / structural_equal

Function structural_equal

python/tvm_ffi/structural.py:39–85  ·  view source on GitHub ↗

Check structural equality between two values. Structural equality compares the *shape/content structure* of two values instead of Python object identity. For container-like values, this means recursive comparison of elements/fields. For object types that provide structural equal hoo

(
    lhs: Any, rhs: Any, map_free_vars: bool = False, skip_tensor_content: bool = False
)

Source from the content-addressed store, hash-verified

37
38
39def structural_equal(
40 lhs: Any, rhs: Any, map_free_vars: bool = False, skip_tensor_content: bool = False
41) -> bool:
42 """Check structural equality between two values.
43
44 Structural equality compares the *shape/content structure* of two values
45 instead of Python object identity. For container-like values, this means
46 recursive comparison of elements/fields. For object types that provide
47 structural equal hooks, those hooks are used.
48
49 Parameters
50 ----------
51 lhs
52 Left-hand side value.
53 rhs
54 Right-hand side value.
55
56 map_free_vars
57 Whether free variables (variables without a definition site) can be
58 mapped to each other during comparison.
59
60 skip_tensor_content
61 Whether to skip tensor data content when comparing tensors.
62
63 Returns
64 -------
65 result
66 Whether the two values are structurally equal.
67
68 Examples
69 --------
70 .. code-block:: python
71
72 import tvm_ffi
73
74 assert tvm_ffi.structural_equal([1, 2, 3], [1, 2, 3])
75 assert not tvm_ffi.structural_equal([1, 2, 3], [1, 2, 4])
76
77 See Also
78 --------
79 :py:func:`tvm_ffi.structural_hash`
80 Hash function compatible with structural equality.
81 :py:func:`tvm_ffi.get_first_structural_mismatch`
82 Mismatch diagnostics with access paths.
83
84 """
85 return _ffi_api.StructuralEqual(lhs, rhs, map_free_vars, skip_tensor_content)
86
87
88def structural_hash(

Calls

no outgoing calls