Skip to content
fn

schema_hash

→std::uint64_t
int schema_hash(const OpSchema & s)

Computes a 64-bit FNV-1a fingerprint of an op's behavioural schema.

The hash mixes the schema's name, version, the op's autocast policy on each device (its row in the policy table, Metal then CPU), and the deterministic flag — what together defines how the op behaves. stable_input_indices, internal, and arity counts are excluded because they describe shape rather than semantics.

Used for change-detection: cached graph compilations, profiler entries, and checkpoint metadata embed this hash so a schema bump (or any behaviour-relevant change) invalidates the cache automatically.

Math

h_{i+1} = (h_i \oplus b_i) \cdot \text{0x100000001b3} \pmod{2^{64}}, $$ where $b_i$ ranges over the bytes of `name`, a null separator, the little-endian bytes of `version`, the Metal and CPU policy bytes, and finally the `deterministic` flag (0 or 1).

Parameters

sconst OpSchema&
The schema to hash.

Returns

std::uint64_t

A 64-bit FNV-1a digest. Stable across processes for the same schema fields; not cryptographic.

Notes

The null byte between name and version prevents length- extension collisions of the form "ab" vs "a" + 'b'.