Skip to main content

Module from_tensor_op

Module from_tensor_op 

Source
Expand description

from_tensor_op — a recognized tensor op becomes a TEMPLATE spatial program (phase Template): the tensors, the four stages, three double-buffered FIFOs, and one work item per output tile. The numerics are chosen HERE from the target’s matrix engine and the recognized fills, and the exactness claim is derived, never assumed: an Int source on a float-primary engine rides as bf16 operands with an fp32 accumulator and is claimed exact only while every partial sum fits fp32’s mantissa.

Structs§

ElementwiseNames
Names of an elementwise op’s tensors (from the source).
FusedRowFills
FusedRowNames
MatmulNames
The source-level names of a matmul’s tensors.
SwiGluNames
Template
A template under construction: tensors, stages, buffers and local hand-off edges, in id order.

Functions§

choose_matmul_numerics
The chosen numerics of a matmul on a target, from each operand’s largest magnitude: (operand, accumulator, output, claim). An operand bounded by b lies in [−b, b] (choose_matmul_numerics_ranged).
choose_matmul_numerics_ranged
The chosen numerics of a matmul on a target, from each operand’s range [lo, hi]: (operand, accumulator, output, claim). An integer operand is the narrowest two’s-complement width that holds both ranges — an int8 activation clamped to [−128, 127] is int8 — and the claim is exact while k products of the operands’ extremes fit the accumulator.
const_map
A map constant in both axes — a scalar tile, which is what Tensix’s reduce_tile wants as its scaler operand.
elementwise_float
The float precision the target’s ELEMENTWISE datapath offers, widest first — the one a composition carries its activations in (bf16 on the RDU’s witnessed envelope).
elementwise_int
The integer precision the target’s ELEMENTWISE datapath offers, widest first — the one an integer model’s tensors are carried in: an Int is the VM’s 64-bit integer, so the widest the part has is the closest to it.
from_elementwise
C[p] = A[p] ⊕ B[p] over a flat length: integer datapath where the target has one, fp32 otherwise.
from_elementwise_with
The same, told whether the operands are float even when neither carries a recognized fill — which is every activation inside a composition. Without it a target that offers an integer elementwise datapath would take it for a pair of tensors that hold bf16 model activations.
from_fused_block
A fused transformer block (matmul → requant → bias → relu) as ONE fused compute chain inside the scalar datapath’s fusion window, intermediates streaming through local hand-offs.
from_fused_row
from_matmul
Lift a recognized matmul to a template spatial program on target.
from_pipe
★ A RECOGNIZED PRODUCER/CONSUMER PIPE, AS SPATIAL IR — the template that retires codegen_tt::concurrency_mesh’s hand-written two-core program.
from_scalar_body
A decision fabric (an if-converted scalar body) as a Scalar stage applied element-wise over an n-element input vector: y[i] = f(x[i]).
from_swiglu
from_swiglu_shaped
from_swiglu over the program’s (rows, cols) — SwiGLU is pointwise, so a matrix is mapped tile by tile in the tiling the matmuls on either side of it use.
from_systolic
A weight-stationary systolic tile as a spatial program: O(m×n) = A(m×k)·W(k×n), the weights baked into a Param tensor, the compute stage carrying the weight-stationary policy.
ident_map
The identity map over a page width elements wide: the operand is walked along both axes, [(row, width), (col, 1)] — a row step is a page width because the offset is FLAT.
init_of
local_handshake
The same-site hand-off primitive a target offers: a FIFO where it has one, else valid/ready. The handshake a target provides for a same-site bounded hand-off. A template always says Fifo (the abstract bounded buffer between a producer and its consumer); synthesize_handshakes retypes those edges to this kind, so the template is the same value on every target and the target enters only through passes.
operand_bits
Operand bit width for the integer reference (None for float operands).
page_width
The page WIDTH in elements a stage’s operand is read through — the row stride of every flat map over that buffer. A Generic page is a strip of page_tiles tiles, so the width is fixed the moment the buffer is; the passes that re-page (apply_plan) touch matmul chains only.
per_col_map
A map that OMITS the row axis — one value per column, constant down the rows (a weight, a bias).
per_row_map
A map that OMITS the column axis — one scalar per row, constant along the row. This is a broadcast, and it is spelled as a missing term rather than as an operator.