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

Function test_recursive_eq_mutual_cycle

tests/python/test_structural.py:138–160  ·  view source on GitHub ↗

RecursiveEq should return True for two distinct but structurally equivalent cyclic graphs.

()

Source from the content-addressed store, hash-verified

136
137
138def test_recursive_eq_mutual_cycle() -> None:
139 """RecursiveEq should return True for two distinct but structurally equivalent cyclic graphs."""
140 v_map = tvm_ffi.Map({})
141
142 def make_cyclic(v_i64: int) -> object:
143 o = tvm_ffi.testing.create_object(
144 "testing.TestObjectDerived",
145 v_i64=v_i64,
146 v_f64=0.0,
147 v_str="x",
148 v_map=v_map,
149 v_array=tvm_ffi.Array([]),
150 )
151 o.v_array = tvm_ffi.Array([o]) # type: ignore[unresolved-attribute]
152 return o
153
154 a = make_cyclic(42)
155 b = make_cyclic(42)
156 # Two distinct objects with identical structure and self-referencing cycles.
157 assert _recursive_eq(a, b)
158 # Different content should not be equal.
159 c = make_cyclic(99)
160 assert not _recursive_eq(a, c)

Callers

nothing calls this directly

Calls 2

make_cyclicFunction · 0.85
MapMethod · 0.45

Tested by

no test coverage detected