Skip to content

vector.encode

vector dialect

Encode logical numeric vector lanes into a physical encoded payload using an explicit encoding witness. This is the inverse boundary to vector.decode for runtime-created encoded data such as KV-cache pages, online quantization records, and target prepack buffers. Rounding, saturation, affine terms, table lookup policy, and sparse/codebook structure are described by schema facts; the actual scale/table/metadata/state values are ordinary auxiliary SSA operands.

Operation contract

Property Value
Semantic phase executable
Traits Pure, RefinableResultTypeRefs

Signature

Kind Name Type Cardinality Description
Operand source vector required Logical numeric lanes to encode.
Operand schema encoding<schema> required Schema witness for producing the payload.
Operand auxiliary vector variadic Explicit scale, table, metadata, or online state operands.
Result result vector required Physical encoded payload lanes.
Attribute auxiliary_names dict optional Sorted auxiliary operand keys mapped to auxiliary operand ordinals.

Examples

%payload = vector.encode %values using %schema {amax = %amax : vector<1xf32>, scale = %scale : vector<1xf16>} : vector<32xf32>, encoding<schema> -> vector<4xi32>
%payload = vector.encode %values using %schema : vector<32xf32>, encoding<schema> -> vector<4xi32>