tvm_ffi.StructuralKey#
- class tvm_ffi.StructuralKey(key)#
Bases:
ObjectHash-cached structural key wrapper.
This wrapper can be used to hint that a dict uses structural equality and hash for the key.
Examples
Use
StructuralKeywith Python dictionaries when you want key lookup by structural semantics:import tvm_ffi k0 = tvm_ffi.StructuralKey([1, 2, 3]) k1 = tvm_ffi.StructuralKey([1, 2, 3]) k2 = tvm_ffi.StructuralKey([1, 2, 4]) d = {k0: "value-a", k2: "value-b"} assert d[k1] == "value-a" # k1 matches k0 structurally assert d[k2] == "value-b"
It can also be used directly with
tvm_ffi.Map:m = tvm_ffi.Map({k0: 1, k1: 2}) assert len(m) == 1 assert m[k0] == 2
See also
tvm_ffi.structural_equal()Structural equality comparison.
tvm_ffi.structural_hash()Structural hash computation.
- Parameters:
key (Any)
- property key#
- property hash_i64#