tvm_ffi.structural_equal

tvm_ffi.structural_equal#

tvm_ffi.structural_equal(lhs, rhs, map_free_vars=False, skip_tensor_content=False)[source]#

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 hooks, those hooks are used.

Parameters:
  • lhs (Any) – Left-hand side value.

  • rhs (Any) – Right-hand side value.

  • map_free_vars (bool, default: False) – Whether free variables (variables without a definition site) can be mapped to each other during comparison.

  • skip_tensor_content (bool, default: False) – Whether to skip tensor data content when comparing tensors.

Return type:

bool

Returns:

result – Whether the two values are structurally equal.

Examples

import tvm_ffi

assert tvm_ffi.structural_equal([1, 2, 3], [1, 2, 3])
assert not tvm_ffi.structural_equal([1, 2, 3], [1, 2, 4])

See also

tvm_ffi.structural_hash()

Hash function compatible with structural equality.

tvm_ffi.get_first_structural_mismatch()

Mismatch diagnostics with access paths.