~/bend-docscommunity

kernel_gemm.bend checks

raw source on the hub · import stelliferous@0.0.4.0/kernel_gemm.bend as Kernel_gemm

One GEMM kernel: a block of up to eight rows at eight lanes. Each cell folds k in order from +0, then finishes once. Which tiles each step reads, how the rows are written and which blocks run are the caller's parameters.

5 imports
import Base
import ./kernel_tile.bend as Tile
import ./math_choice.bend as Choice
import ./traversal_loop.bend as Iteration
import ./traversal_array.bend as Traversal

Types

type Accumulators source · line 11 · raw

Data

Eight row accumulators of eight lanes, one flat record.

type Store source · line 17 · raw

Data

Rows r < rows of a block are stored from base + r * row_stride: cell (r, l) at l * lane_stride further for l < lanes (lane writer), or the row as one tile whose lanes at or above lanes are +0 (tile writer).

type Job source · line 23 · raw

@-Cursor:Data -> Data

One block: depth steps, each reading the lane and row tiles its cursor points to. Row r (lane writer) or lane l (tile writer) takes the bias at bias_start + r or bias_start + l.

type Operands source · line 29 · raw

@-E:Data -> @-Bias:Type -> Type

Row tiles hold one value for each of the eight rows of a block, lane tiles one for each of its eight lanes. The output holds elements of the writer: F32 cells or Tile8 rows.

type Loop source · line 51 · raw

@-Cursor:Data -> @-E:Data -> @-Bias:Type -> Type

The k loop state: every owner, the cursor, the job fields and the accumulators are fields of one record; a nested owner record or a longer helper chain makes every k step a real call.

type Step source · line 93 · raw

@-Cursor:Data -> Data

A step reads the lane tile and the row tile at these addresses; the cursor is the next step's.

type Entries source · line 104 · raw

Data

A grid of entries: +1 along a row, row_jump after the last column of a row, output_jump after the last row.

type Both source · line 120 · raw

@-Lane:Data -> @-Row:Data -> Data

One reader for each operand.

type Written source · line 193 · raw

@-E:Data -> @-Bias:Type -> Type

A writer stores the finished rows of a block and gives both owners back.

type TileMatrix source · line 283 · raw

Data

A product the tile writer stores: positions x channels cells, positions a multiple of eight. Row r of a block is a position, its tile the channels 8g to 8g + 7, stored at (start + position) * groups + g, the groups of a position side by side. The row tiles are [positions / 8, inner] tiles of eight positions, the lane tiles [channels / 8, inner] tiles of eight channels.

type CellOperands source · line 324 · raw

Type

A cell bias is owned beside the shared product loop. Unit carries no scalar owner; the epilogue reads one cell for eight output channels.

type Points source · line 369 · raw

Data

A pointwise product reads the rows of its blocks from the input cells and multiplies them by pairs of lane tiles, sixteen channels stored as one element. Row r of a block is cell cell + r * stride, whose lanes are eight consecutive k, the cells of a row consecutive groups of k: step k = 16h + 8o + j reads lane j of cell 2h + o of each row and pair address + k.

type Quad source · line 374 · raw

Data

Four rows of sixteen channels: four positions are as many rows as clang still inlines into the k loop at sixteen k a step.

type Row4 source · line 397 · raw

Data

type PointLoop source · line 400 · raw

Type

type PointMatrix source · line 483 · raw

Data

A product whose rows are read from cells: the rows of position p from cell cell + p * stride on; channels, positions and inner as product, inner a multiple of sixteen in the whole-inner job. A job makes four positions by the sixteen channels of a pair of groups; the upper group of the last pair may be missing.

type Place source · line 495 · raw

Data

The pair and the four-position unit of a job, in the order tile_major takes its groups and units.

type PointOperands source · line 507 · raw

Type

The pairs of the weights are [pairs, inner]; the staged output holds the pairs of a position side by side.

type PairPlan source · line 643 · raw

Data

The pair of lane tiles at index pair * inner + k: tiles 2 * pair and 2 * pair + 1 of k, the lower tile again for a missing upper group.

type PanelPlan source · line 666 · raw

Data

A panel already has the output lanes together. Pair those tiles directly from the inner-major panel, starting at base in its owning buffer.

type TilePlan source · line 684 · raw

Data

The tiles of one group from source on, each into one half of the pair at target + index.

type StagedPlan source · line 705 · raw

@-Context:Data -> Data

Cell index of the cells of the staged pairs: the half of pair (index / groups) * pairs + group / 2 that holds the group, mapped.

type StagedSlice source · line 729 · raw

Data

A contiguous fragment of the target cell order. In the group-major order a group covers all positions before the next group begins.

Definitions

def row0 source · line 55 · raw

@accumulators:Accumulators -> 0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8

def row1 source · line 59 · raw

@accumulators:Accumulators -> 0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8

def row2 source · line 63 · raw

@accumulators:Accumulators -> 0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8

def row3 source · line 67 · raw

@accumulators:Accumulators -> 0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8

def row4 source · line 71 · raw

@accumulators:Accumulators -> 0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8

def row5 source · line 75 · raw

@accumulators:Accumulators -> 0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8

def row6 source · line 79 · raw

@accumulators:Accumulators -> 0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8

def row7 source · line 83 · raw

@accumulators:Accumulators -> 0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8

def zero source · line 87 · raw

Accumulators

def direct source · line 98 · raw

@cursor:U32 -> Pair(U32, U32)

A reader gives the address of one operand at the current step and the cursor of the next. Direct: consecutive tiles from the first.

def entry_next source · line 109 · raw

@along:Bool -> @down:Bool -> @+address:U32 -> @+column:U32 -> @+row:U32 -> @+columns:U32 -> @+rows:U32 -> @+row_jump:U32 -> @+output_jump:U32 -> Entries

The entries after one: along the row, at the start of the next row, or after the last row. Only the next entries are built (rule F14).

def entry source · line 115 · raw

@cursor:Entries -> Pair(U32, Entries)

def Direct source · line 132 · raw

Data

def directs source · line 136 · raw

@cursor:Direct -> Step<Direct>

Both operands consecutive.

def unbiased source · line 139 · raw

@bias:Array<F32> -> @row:U32 -> Pair(Array<F32>, F32)

def plus source · line 142 · raw

@value:F32 -> @bias:F32 -> F32

def kept source · line 145 · raw

@value:F32 -> @bias:F32 -> F32

def lane_times source · line 151 · raw

@lane:F32 -> @row:F32 -> F32

Every row takes the step; rows at or above store.rows are never stored. The product of a lane value and a row value: lane first or row first, as the specification of the contraction multiplies them.

def row_times source · line 154 · raw

@lane:F32 -> @row:F32 -> F32

def blocks source · line 274 · raw

@rows:U32 -> U32

The blocks of eight rows that cover rows rows.

def tile_jobs source · line 286 · raw

@+matrix:TileMatrix -> U32

def block_tiles source · line 291 · raw

U32

One tile is 32 bytes; 8192 tiles are 256 KB.

def streamed source · line 296 · raw

@+groups:U32 -> @+inner:U32 -> Bool

Weights of a block or less stay in cache while each eight positions pass over them. Larger ones pass once, each channel group in cache over the positions.

def job_group source · line 299 · raw

@once:Bool -> @+index:U32 -> @+groups:U32 -> @+units:U32 -> U32

def job_unit source · line 304 · raw

@once:Bool -> @+index:U32 -> @+groups:U32 -> @+units:U32 -> U32

def tile_major source · line 309 · raw

@matrix:TileMatrix -> @index:U32 -> Job<Direct>

def cell_bias source · line 327 · raw

@state:CellOperands -> Array<0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8>

def cell_product source · line 331 · raw

@state:CellOperands -> Operands<0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8, Unit>

def cell_output source · line 335 · raw

@state:CellOperands -> Array<0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8>

def cell_stored source · line 338 · raw

@row_tiles:Array<0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8> -> @lane_tiles:Array<0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8> -> @bias:Array<0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8> -> @written:Written<0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8, Unit> -> CellOperands

def cell_read source · line 342 · raw

@row_tiles:Array<0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8> -> @lane_tiles:Array<0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8> -> @unused_bias:Unit -> @output:Array<0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8> -> @+store:Store -> @+accumulators:Accumulators -> @read:Pair(Array<0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8>, 0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8) -> CellOperands

def cell_finish source · line 348 · raw

@bias:Array<0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8> -> @state:Loop<Direct, 0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8, Unit> -> CellOperands

def cell_job source · line 352 · raw

@index:U32 -> @matrix:TileMatrix -> @state:CellOperands -> CellOperands

def cell_run source · line 356 · raw

@count:Nat -> @matrix:TileMatrix -> @state:CellOperands -> CellOperands

def quad_zero source · line 377 · raw

Quad

def quad0 source · line 381 · raw

@accumulators:Quad -> 0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile16

def quad1 source · line 385 · raw

@accumulators:Quad -> 0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile16

def quad2 source · line 389 · raw

@accumulators:Quad -> 0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile16

def quad3 source · line 393 · raw

@accumulators:Quad -> 0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile16

def first_cell source · line 441 · raw

@cell:U32 -> U32

The cell of a step: the first or the second of the two a group reads.

def second_cell source · line 444 · raw

@cell:U32 -> U32

def next_cells source · line 454 · raw

@state:PointLoop -> PointLoop

def pairs_of source · line 486 · raw

@+channels:U32 -> U32

def point_jobs source · line 489 · raw

@+matrix:TileMatrix -> U32

def point_place source · line 498 · raw

@+matrix:PointMatrix -> @+index:U32 -> Place

def point_bias source · line 510 · raw

@state:PointOperands -> Array<0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8>

def point_cells source · line 514 · raw

@state:PointOperands -> Array<0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8>

def point_pairs source · line 518 · raw

@state:PointOperands -> Array<0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile16>

def point_staged source · line 522 · raw

@state:PointOperands -> Array<0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile16>

def point_start source · line 526 · raw

@cells:Array<0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8> -> @pairs:Array<0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile16> -> @+matrix:PointMatrix -> @+place:Place -> PointLoop

def point_stored source · line 559 · raw

@staged:Array<0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile16> -> @+base:U32 -> @+stride:U32 -> @+rows:U32 -> @+biases:0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile16 -> @+accumulators:Quad -> Array<0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile16>

def upper_biased source · line 562 · raw

@cells:Array<0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8> -> @pairs:Array<0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile16> -> @staged:Array<0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile16> -> @+base:U32 -> @+stride:U32 -> @+rows:U32 -> @lower:0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8 -> @+accumulators:Quad -> @read:Pair(Array<0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8>, 0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8) -> PointOperands

def lower_biased source · line 566 · raw

@cells:Array<0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8> -> @pairs:Array<0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile16> -> @staged:Array<0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile16> -> @+base:U32 -> @+stride:U32 -> @+rows:U32 -> @+above:U32 -> @+accumulators:Quad -> @read:Pair(Array<0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8>, 0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8) -> PointOperands

def point_finish source · line 570 · raw

@bias:Array<0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8> -> @staged:Array<0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile16> -> @+matrix:PointMatrix -> @+place:Place -> @state:PointLoop -> PointOperands

def panel_bias source · line 574 · raw

@value:0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile16 -> @bias:0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile16 -> 0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile16

Keep the bias stores at one native call site per kernel (F7, F13).

def point_groups_of source · line 577 · raw

@+matrix:PointMatrix -> Nat

def point_remainder source · line 581 · raw

@+matrix:PointMatrix -> U32

def panel_times source · line 587 · raw

@lane:F32 -> @row:F32 -> F32

A distinct specialization keeps the wide hot steps single-call-site when the suffix and the full inner loop are linked together.

def tail_times source · line 590 · raw

@lane:F32 -> @row:F32 -> F32

def finish_inner source · line 611 · raw

@+matrix:PointMatrix -> @state:PointLoop -> PointLoop

def whole_inner source · line 615 · raw

@+matrix:PointMatrix -> @state:PointLoop -> PointLoop

def point_job source · line 625 · raw

@index:U32 -> @matrix:PointMatrix -> @state:PointOperands -> PointOperands

def point_run source · line 638 · raw

@count:Nat -> @matrix:PointMatrix -> @state:PointOperands -> PointOperands

def pair_upper source · line 646 · raw

@lower:0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8 -> @read:Pair(Array<0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8>, 0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8) -> Pair(Array<0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8>, 0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile16)

def pair_lower source · line 650 · raw

@+above:U32 -> @read:Pair(Array<0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8>, 0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8) -> Pair(Array<0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8>, 0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile16)

def pair_read source · line 654 · raw

@tiles:Array<0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8> -> @plan:PairPlan -> @index:U32 -> Pair(Array<0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8>, 0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile16)

def pair_placed source · line 661 · raw

@plan:PairPlan -> @index:U32 -> U32

def panel_pair_read source · line 669 · raw

@tiles:Array<0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8> -> @plan:PanelPlan -> @index:U32 -> Pair(Array<0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8>, 0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile16)

def panel_pair_placed source · line 676 · raw

@plan:PanelPlan -> @index:U32 -> U32

def tile_read source · line 687 · raw

@tiles:Array<0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8> -> @plan:TilePlan -> @index:U32 -> Pair(Array<0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8>, 0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8)

def tile_placed source · line 691 · raw

@plan:TilePlan -> @index:U32 -> U32

def lower_half source · line 695 · raw

@pair:0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile16 -> @tile:0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8 -> 0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile16

def upper_half source · line 699 · raw

@pair:0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile16 -> @tile:0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8 -> 0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile16

def staged_half source · line 708 · raw

@value:0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile16 -> @upper:Bool -> 0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8

def staged_slice_index source · line 732 · raw

@+slice:StagedSlice -> @+index:U32 -> U32

def unmapped_tile source · line 737 · raw

@context:Unit -> @tile:0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8 -> 0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8

def staged_slice_read source · line 740 · raw

@staged:Array<0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile16> -> @slice:StagedSlice -> @index:U32 -> Pair(Array<0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile16>, 0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8)

def staged_slice_destination source · line 744 · raw

@slice:StagedSlice -> @index:U32 -> U32

def point_count source · line 747 · raw

@+matrix:PointMatrix -> U32

Templates

template row_tiles_of source · line 32 · raw

@-E:Data -> @-Bias:Type -> @operands:Operands<E, Bias> -> Array<0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8>

template lane_tiles_of source · line 36 · raw

@-E:Data -> @-Bias:Type -> @operands:Operands<E, Bias> -> Array<0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8>

template bias_of source · line 40 · raw

@-E:Data -> @-Bias:Type -> @operands:Operands<E, Bias> -> Bias

template output_of source · line 44 · raw

@-E:Data -> @-Bias:Type -> @operands:Operands<E, Bias> -> Array<E>

template stepped source · line 123 · raw

@-Lane:Data -> @-Row:Data -> @lane:Pair(U32, Lane) -> @row:Pair(U32, Row) -> Step<Both<Lane, Row>>

template both source · line 128 · raw

@-Lane:Data -> @-Row:Data -> @-lane:(@_:Lane -> Pair(U32, Lane)) -> @-row:(@_:Row -> Pair(U32, Row)) -> @cursor:Both<Lane, Row> -> Step<Both<Lane, Row>>

template update source · line 157 · raw

@-times:(@_:F32 -> @_:F32 -> F32) -> @accumulators:Accumulators -> @+lane_tile:0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8 -> @row_tile:0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8 -> Accumulators

template with_row_tile source · line 163 · raw

@-Cursor:Data -> @-E:Data -> @-Bias:Type -> @-times:(@_:F32 -> @_:F32 -> F32) -> @lane_tiles:Array<0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8> -> @bias:Bias -> @output:Array<E> -> @cursor:Cursor -> @+row:U32 -> @store:Store -> @accumulators:Accumulators -> @lane_tile:0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8 -> @read:Pair(Array<0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8>, 0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8) -> Loop<Cursor, E, Bias>

template with_lane_tile source · line 168 · raw

@-Cursor:Data -> @-E:Data -> @-Bias:Type -> @-times:(@_:F32 -> @_:F32 -> F32) -> @row_tiles:Array<0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8> -> @bias:Bias -> @output:Array<E> -> @+row_address:U32 -> @cursor:Cursor -> @+row:U32 -> @store:Store -> @accumulators:Accumulators -> @read:Pair(Array<0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8>, 0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8) -> Loop<Cursor, E, Bias>

template with_cursor source · line 173 · raw

@-Cursor:Data -> @-E:Data -> @-Bias:Type -> @-times:(@_:F32 -> @_:F32 -> F32) -> @row_tiles:Array<0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8> -> @lane_tiles:Array<0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8> -> @bias:Bias -> @output:Array<E> -> @+row:U32 -> @store:Store -> @accumulators:Accumulators -> @read:Step<Cursor> -> Loop<Cursor, E, Bias>

template step source · line 179 · raw

@-Cursor:Data -> @-E:Data -> @-Bias:Type -> @-advance:(@_:Cursor -> Step<Cursor>) -> @-times:(@_:F32 -> @_:F32 -> F32) -> @state:Loop<Cursor, E, Bias> -> Loop<Cursor, E, Bias>

One ordered k step: the lane tile, then the row tile, then the products.

template kept_or source · line 185 · raw

@-E:Data -> @inside:Bool -> @+offset:U32 -> @value:E -> @read:Pair(Array<E>, E) -> Array<E>

Every cell is read and written back, with its own value only when inside: straight-line code in which each accumulator has one consumer (rule F13).

template put source · line 189 · raw

@-E:Data -> @inside:Bool -> @output:Array<E> -> @+offset:U32 -> @value:E -> Array<E>

template bias_lane source · line 198 · raw

@-fetch:(@_:Array<F32> -> @_:U32 -> Pair(Array<F32>, F32)) -> @bias:Array<F32> -> @start:U32 -> @lane:Nat -> Pair(Array<F32>, F32)

Lane l of a block's biases is the bias at start + l; the eight are read once per block.

template bias_lanes source · line 201 · raw

@-fetch:(@_:Array<F32> -> @_:U32 -> Pair(Array<F32>, F32)) -> @bias:Array<F32> -> @+start:U32 -> Pair(Array<F32>, 0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8)

template tile_finished source · line 206 · raw

@-close:(@_:F32 -> @_:F32 -> F32) -> @+count:U32 -> @+biases:0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8 -> @+values:0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8 -> 0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8

A row of the tile writer: lane l closes with the bias of lane l, lanes at or above count are +0.

template tiles_finished source · line 216 · raw

@-Bias:Type -> @-close:(@_:F32 -> @_:F32 -> F32) -> @+base:U32 -> @+row_stride:U32 -> @+rows:U32 -> @+count:U32 -> @+accumulators:Accumulators -> @output:Array<0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8> -> @read:Pair(Bias, 0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8) -> Written<0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8, Bias>

template write_tiles source · line 229 · raw

@-fetch:(@_:Array<F32> -> @_:U32 -> Pair(Array<F32>, F32)) -> @-close:(@_:F32 -> @_:F32 -> F32) -> @+bias_start:U32 -> @+store:Store -> @+accumulators:Accumulators -> @written:Written<0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8, Array<F32>> -> Written<0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8, Array<F32>>

The tile writer: each row below store.rows is one tile.

template operands_written source · line 235 · raw

@-E:Data -> @row_tiles:Array<0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8> -> @lane_tiles:Array<0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8> -> @written:Written<E, Array<F32>> -> Operands<E, Array<F32>>

template finish source · line 241 · raw

@-Cursor:Data -> @-E:Data -> @-write:(@+bias_start:U32 -> @+store:Store -> @+accumulators:Accumulators -> @_:Written<E, Array<F32>> -> Written<E, Array<F32>>) -> @state:Loop<Cursor, E, Array<F32>> -> Operands<E, Array<F32>>

One straight-line finish after the k loop: each accumulator has one consumer (rule F13).

template looped source · line 245 · raw

@-Cursor:Data -> @-E:Data -> @-Bias:Type -> @-advance:(@_:Cursor -> Step<Cursor>) -> @-times:(@_:F32 -> @_:F32 -> F32) -> @+job:Job<Cursor> -> @start:Pair(Operands<E, Bias>, Accumulators) -> Loop<Cursor, E, Bias>

template block source · line 252 · raw

@-Cursor:Data -> @-E:Data -> @-advance:(@_:Cursor -> Step<Cursor>) -> @-times:(@_:F32 -> @_:F32 -> F32) -> @-write:(@+bias_start:U32 -> @+store:Store -> @+accumulators:Accumulators -> @_:Written<E, Array<F32>> -> Written<E, Array<F32>>) -> @+job:Job<Cursor> -> @operands:Operands<E, Array<F32>> -> Operands<E, Array<F32>>

One block of eight rows: the k loop from +0, then the finish.

template job_step source · line 255 · raw

@-Plan:Data -> @-Cursor:Data -> @-E:Data -> @-job_at:(@_:Plan -> @_:U32 -> Job<Cursor>) -> @-advance:(@_:Cursor -> Step<Cursor>) -> @-times:(@_:F32 -> @_:F32 -> F32) -> @-write:(@+bias_start:U32 -> @+store:Store -> @+accumulators:Accumulators -> @_:Written<E, Array<F32>> -> Written<E, Array<F32>>) -> @index:U32 -> @plan:Plan -> @operands:Operands<E, Array<F32>> -> Operands<E, Array<F32>>

template held source · line 258 · raw

@-State:Type -> @state:State -> State

template segment source · line 263 · raw

@-State:Type -> @-Plan:Data -> @-update:(@_:U32 -> @_:Plan -> @_:State -> State) -> @depth:Nat -> @count:Nat -> @plan:Plan -> @state:State -> State

Two call sites retain this non-flat worklist segment (rule F12), so the register-allocated MAC loop stays separate from its caller.

template run source · line 268 · raw

@-Plan:Data -> @-Cursor:Data -> @-E:Data -> @-job_at:(@_:Plan -> @_:U32 -> Job<Cursor>) -> @-advance:(@_:Cursor -> Step<Cursor>) -> @-times:(@_:F32 -> @_:F32 -> F32) -> @-write:(@+bias_start:U32 -> @+store:Store -> @+accumulators:Accumulators -> @_:Written<E, Array<F32>> -> Written<E, Array<F32>>) -> @count:Nat -> @plan:Plan -> @operands:Operands<E, Array<F32>> -> Operands<E, Array<F32>>

Jobs 0 to count - 1 of the plan, in order.

template point_row_3 source · line 405 · raw

@-lane:(@_:0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8 -> F32) -> @x0:F32 -> @x1:F32 -> @x2:F32 -> @read:Pair(Array<0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8>, 0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8) -> Pair(Array<0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8>, Row4)

Lane lane of the four row cells; point_row_k holds the lanes of rows below k and reads row k.

template point_row_2 source · line 409 · raw

@-lane:(@_:0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8 -> F32) -> @+cell:U32 -> @+stride:U32 -> @x0:F32 -> @x1:F32 -> @read:Pair(Array<0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8>, 0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8) -> Pair(Array<0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8>, Row4)

template point_row_1 source · line 413 · raw

@-lane:(@_:0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8 -> F32) -> @+cell:U32 -> @+stride:U32 -> @x0:F32 -> @read:Pair(Array<0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8>, 0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8) -> Pair(Array<0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8>, Row4)

template point_row_0 source · line 417 · raw

@-lane:(@_:0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8 -> F32) -> @+cell:U32 -> @+stride:U32 -> @read:Pair(Array<0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8>, 0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8) -> Pair(Array<0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8>, Row4)

template point_rows source · line 421 · raw

@-lane:(@_:0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8 -> F32) -> @cells:Array<0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8> -> @+cell:U32 -> @+stride:U32 -> Pair(Array<0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8>, Row4)

template point_updated source · line 426 · raw

@-times:(@_:F32 -> @_:F32 -> F32) -> @accumulators:Quad -> @+weight:0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile16 -> @values:Row4 -> Quad

One ordered k step: the pair of lane tiles, the four row lanes, then the products.

template point_products source · line 431 · raw

@-times:(@_:F32 -> @_:F32 -> F32) -> @pairs:Array<0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile16> -> @cursor:Points -> @accumulators:Quad -> @weight:0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile16 -> @read:Pair(Array<0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8>, Row4) -> PointLoop

template point_weight source · line 435 · raw

@-lane:(@_:0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8 -> F32) -> @-times:(@_:F32 -> @_:F32 -> F32) -> @cells:Array<0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8> -> @+cell:U32 -> @+stride:U32 -> @cursor:Points -> @accumulators:Quad -> @read:Pair(Array<0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile16>, 0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile16) -> PointLoop

template point_step source · line 449 · raw

@-at:(@_:U32 -> U32) -> @-lane:(@_:0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8 -> F32) -> @-times:(@_:F32 -> @_:F32 -> F32) -> @state:PointLoop -> PointLoop

at and lane tell the steps of a group apart, so each specialization has one call site and clang inlines it (rule F7).

template point_group source · line 460 · raw

@-times:(@_:F32 -> @_:F32 -> F32) -> @state:PointLoop -> PointLoop

The sixteen k of two cells of each row, then the next two cells.

template point_stored_with source · line 533 · raw

@-add:(@_:0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile16 -> @_:0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile16 -> 0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile16) -> @staged:Array<0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile16> -> @+base:U32 -> @+stride:U32 -> @+rows:U32 -> @+biases:0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile16 -> @+accumulators:Quad -> Array<0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile16>

The finish: row r of the block is position start + 4 * unit + r, stored when it lies below output_positions, plus the biases of the pair's groups.

template upper_biased_with source · line 539 · raw

@-add:(@_:0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile16 -> @_:0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile16 -> 0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile16) -> @cells:Array<0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8> -> @pairs:Array<0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile16> -> @staged:Array<0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile16> -> @+base:U32 -> @+stride:U32 -> @+rows:U32 -> @lower:0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8 -> @+accumulators:Quad -> @read:Pair(Array<0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8>, 0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8) -> PointOperands

template lower_biased_with source · line 544 · raw

@-add:(@_:0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile16 -> @_:0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile16 -> 0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile16) -> @cells:Array<0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8> -> @pairs:Array<0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile16> -> @staged:Array<0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile16> -> @+base:U32 -> @+stride:U32 -> @+rows:U32 -> @+above:U32 -> @+accumulators:Quad -> @read:Pair(Array<0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8>, 0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8) -> PointOperands

template point_finish_with source · line 549 · raw

@-add:(@_:0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile16 -> @_:0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile16 -> 0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile16) -> @bias:Array<0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8> -> @staged:Array<0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile16> -> @+matrix:PointMatrix -> @+place:Place -> @state:PointLoop -> PointOperands

template tail_step source · line 595 · raw

@-at:(@_:U32 -> U32) -> @lane:Nat -> @state:PointLoop -> PointLoop

The short suffix reads only the remaining inner indices. Padding the operands would add products beyond the inner extent.

template tail_cell source · line 606 · raw

@-at:(@_:U32 -> U32) -> @count:Nat -> @+lane:U32 -> @state:PointLoop -> PointLoop

template point_job_with source · line 619 · raw

@-add:(@_:0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile16 -> @_:0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile16 -> 0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile16) -> @-times:(@_:F32 -> @_:F32 -> F32) -> @-tail:(@+matrix:PointMatrix -> @_:PointLoop -> PointLoop) -> @index:U32 -> @matrix:PointMatrix -> @state:PointOperands -> PointOperands

A job: the groups of sixteen k from +0, then the finish.

template point_run_indexed source · line 632 · raw

@-job:(@_:U32 -> @_:PointMatrix -> @_:PointOperands -> PointOperands) -> @count:Nat -> @matrix:PointMatrix -> @state:PointOperands -> PointOperands

Jobs 0 to count - 1 of the product.

template replaced source · line 679 · raw

@-E:Data -> @old:E -> @value:E -> E

template staged_mapped source · line 714 · raw

@-Context:Data -> @-map:(@_:Context -> @_:0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8 -> 0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8) -> @context:Context -> @upper:Bool -> @read:Pair(Array<0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile16>, 0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile16) -> Pair(Array<0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile16>, 0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8)

template staged_read source · line 718 · raw

@-Context:Data -> @-map:(@_:Context -> @_:0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8 -> 0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8) -> @staged:Array<0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile16> -> @plan:StagedPlan<Context> -> @index:U32 -> Pair(Array<0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile16>, 0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8)

template staged_placed source · line 724 · raw

@-Context:Data -> @plan:StagedPlan<Context> -> @index:U32 -> U32