tvm_ffi.structural_hash

tvm_ffi.structural_hash#

tvm_ffi.structural_hash(value, map_free_vars=False, skip_tensor_content=False)[source]#

Compute structural hash of a value.

This hash is designed to be consistent with structural_equal() under the same options. If two values are structurally equal, they should have the same structural hash.

Parameters:
  • value (Any) – Input value to hash.

  • map_free_vars (bool, default: False) – Whether free variables mapped to each other during hashing.

  • skip_tensor_content (bool, default: False) – Whether tensor data content is ignored when hashing tensors.

Return type:

int

Returns:

hash_value – Structural hash value.

Examples

import tvm_ffi

h0 = tvm_ffi.structural_hash([1, 2, 3])
h1 = tvm_ffi.structural_hash([1, 2, 3])
assert h0 == h1

Notes

Structural hash is intended for hash-table bucketing and fast pre-checks. Always use structural equality to confirm semantic equivalence.