tensor_grid.bend checks
raw source on the hub · import stelliferous@0.0.4.0/tensor_grid.bend as Tensor_grid
The canonical order of cells and the pieces that store them.
A tiled tensor of a logical shape keeps eight values of its lane axis in one cell. Its cell axes are the other axes in order with the groups of the lane axis, ceil(lanes / 8), innermost, or outermost for operands a kernel streams by group. Cells are row-major over the cell axes.
Storage is pieces: aligned blocks of units, a unit being the trailing block of the shortest prefix of the cell axes that holds at most target cells. Pieces depend on the cell axes and the target alone, so two tensors of one shape have the same pieces and a reshape that keeps the cell axes keeps them.
2 imports
import Base import ./tensor_view.bend as Views
Types
type Position source · line 15 · raw
Data
InnermostPosition
OutermostPosition
type Layout source · line 19 · raw
Data
Layout@axis:Nat -> @position:Position -> Layout
type Grid source · line 39 · raw
Data
The pieces of a grid. The cell axes split into a prefix and a unit: outer indices of the prefix axes but its last, extent indices of its last, and unit_cells cells in a unit. A piece is an aligned block of piece_units indices of the last prefix axis inside one outer index, per_outer of them for each outer index, so every piece is a box of the cell axes. prefix is the number of prefix axes.
Grid@count:U32 -> @prefix:U32 -> @outer:U32 -> @extent:U32 -> @unit_cells:U32 -> @piece_units:U32 -> @per_outer:U32 -> @pieces:U32 -> Grid
type Strided source · line 58 · raw
Data
The row-major strides of extents, every one the product of the axes after it, and the product of them all, in one walk.
Strided@strides:List<&2, U32> -> @product:U32 -> Strided
type Units source · line 148 · raw
Data
The unit of cell axes: the axes after the shortest prefix whose rest holds at most target cells. The last axis is never split. outer is the product of the prefix axes but its last, extent the last.
Units@prefix:U32 -> @outer:U32 -> @extent:U32 -> @unit_cells:U32 -> Units
Definitions
def is_outermost source · line 22 · raw
@position:Position -> Bool
def same_position source · line 27 · raw
@left:Position -> @right:Position -> Bool
def groups source · line 42 · raw
@+lanes:U32 -> U32
def piece_target source · line 48 · raw
U32
The piece size of every tensor: one piece of the cheapest pass costs far more than dispatching it as a task and stays in the second level cache across a fused chain.
def product source · line 51 · raw
@extents:List<&2, U32> -> U32
def stride_before source · line 61 · raw
@+extent:U32 -> @inner:Strided -> Strided
def strided source · line 65 · raw
@extents:List<&2, U32> -> Strided
def strides_listed source · line 70 · raw
@found:Strided -> List<&2, U32>
def strides source · line 74 · raw
@extents:List<&2, U32> -> List<&2, U32>
def removed source · line 77 · raw
@extents:List<&2, U32> -> @axis:Nat -> List<&2, U32>
def inserted source · line 83 · raw
@extents:List<&2, U32> -> @axis:Nat -> @+value:U32 -> List<&2, U32>
def lanes_at source · line 89 · raw
@extents:List<&2, U32> -> @axis:Nat -> U32
def placed source · line 95 · raw
@lane:Bool -> @position:Position -> @others:List<&2, U32> -> @+groups:U32 -> List<&2, U32>
def cell_shape source · line 103 · raw
@+shape:List<&2, U32> -> @+layout:Layout -> List<&2, U32>
The cell axes of a logical shape. The lane axis of a shape of rank 0 is a unit axis past its end: its one cell has no cell axes.
def without_last source · line 107 · raw
@extents:List<&2, U32> -> List<&2, U32>
def last_of source · line 113 · raw
@extents:List<&2, U32> -> U32
def others_of source · line 119 · raw
@position:Position -> @cells:List<&2, U32> -> List<&2, U32>
def logical_when source · line 127 · raw
@within:Bool -> @cells:List<&2, U32> -> @+axis:Nat -> @+position:Position -> @+lanes:U32 -> List<&2, U32>
The logical shape of cell axes: the lane axis comes back with lanes values. Cell axes of a lane axis past the end of the shape are the shape itself.
def logical_shape source · line 132 · raw
@+cells:List<&2, U32> -> @+layout:Layout -> @+lanes:U32 -> List<&2, U32>
def outer_count source · line 136 · raw
@+cells:List<&2, U32> -> @+position:Position -> U32
def groups_of source · line 139 · raw
@+position:Position -> @+cells:List<&2, U32> -> U32
def cells_from source · line 152 · raw
@extents:List<&2, U32> -> @strides:List<&2, U32> -> U32
The cells of the axes from the first of extents on, by its stride.
def units_from source · line 158 · raw
@extents:List<&2, U32> -> @strides:List<&2, U32> -> @fits:Bool -> @+prefix:U32 -> @+outer:U32 -> @+extent:U32 -> @+target:U32 -> Units
strides are the strides of extents.
def piece_units source · line 169 · raw
@+unit_cells:U32 -> @+extent:U32 -> @+target:U32 -> U32
The most indices of the last prefix axis whose cells fit the target, at least one and at most the extent: storage comes in powers of two, and the target is one, so a piece fills its storage but for less than a unit.
def divided_up source · line 172 · raw
@+count:U32 -> @+size:U32 -> U32
def grid_of_units source · line 175 · raw
@+found:Units -> @+target:U32 -> Grid
def grid_strided source · line 181 · raw
@+cells:List<&2, U32> -> @+target:U32 -> @found:Strided -> Grid
def grid source · line 185 · raw
@+cells:List<&2, U32> -> @+target:U32 -> Grid
def same_grid source · line 188 · raw
@left:Grid -> @right:Grid -> Bool
def start source · line 194 · raw
@+grid:Grid -> @+piece:U32 -> U32
The first cell and the cells of a piece, and the piece of a cell.
def span source · line 199 · raw
@+grid:Grid -> @+piece:U32 -> U32
def piece_of source · line 203 · raw
@+grid:Grid -> @+index:U32 -> U32
def later_pieces source · line 210 · raw
@+grid:Grid -> @+first:U32 -> @+count:U32 -> Nat
The pieces after the first of the pieces that hold cells [first, first + count), count at least one.
def block source · line 215 · raw
@+grid:Grid -> @+axis:U32 -> @+extent:U32 -> U32
The block of a piece along a cell axis of the given extent: one index on a prefix axis but the last, piece_units on the last, the whole axis after it.
def count_of source · line 219 · raw
@grid:Grid -> U32
def flat_blocks source · line 225 · raw
@+grid:Grid -> Bool
The pieces are equal blocks of the cell order, the last one perhaps shorter: one outer index, or whole blocks of every outer index.
def piece_cells source · line 229 · raw
@+grid:Grid -> U32
def same_pieces source · line 234 · raw
@+left:Grid -> @+right:Grid -> Bool
Two grids of as many cells cut them at the same places.
def pieces_of source · line 237 · raw
@grid:Grid -> U32
def coordinates_by source · line 242 · raw
@extents:List<&2, U32> -> @strides:List<&2, U32> -> @+index:U32 -> List<&2, U32>
The coordinates of a cell index over the cell axes.
def coordinates source · line 249 · raw
@+extents:List<&2, U32> -> @+index:U32 -> List<&2, U32>
def box source · line 254 · raw
@extents:List<&2, U32> -> @+axis:U32 -> @+prefix:U32 -> @+units:U32 -> List<&2, U32>
The extents of the box of a piece of count cells: one index of a prefix axis but the last, its units of the last, every index after it.
def box_of source · line 260 · raw
@+grid:Grid -> @+cells:List<&2, U32> -> @+count:U32 -> List<&2, U32>
def prepended source · line 264 · raw
@+axis:0xa2af805348d03b11eb853850859654f6/tensor_view.Axis -> @view:0xa2af805348d03b11eb853850859654f6/tensor_view.View -> 0xa2af805348d03b11eb853850859654f6/tensor_view.View
def restricted source · line 270 · raw
@axes:List<&2, 0xa2af805348d03b11eb853850859654f6/tensor_view.Axis> -> @coordinates:List<&2, U32> -> @extents:List<&2, U32> -> @+offset:U32 -> 0xa2af805348d03b11eb853850859654f6/tensor_view.View
One walk over the axes: a View used twice would make the compiler share every View constructor.
def axes_by source · line 277 · raw
@extents:List<&2, U32> -> @strides:List<&2, U32> -> List<&2, 0xa2af805348d03b11eb853850859654f6/tensor_view.Axis>
The contiguous axes of extents.
def dense_axes source · line 282 · raw
@+extents:List<&2, U32> -> List<&2, 0xa2af805348d03b11eb853850859654f6/tensor_view.Axis>
def box_view source · line 286 · raw
@+grid:Grid -> @+cells:List<&2, U32> -> @+count:U32 -> 0xa2af805348d03b11eb853850859654f6/tensor_view.View
A piece of count cells read in its own order over its box.
def piece_view source · line 291 · raw
@+grid:Grid -> @+cells:List<&2, U32> -> @+first:U32 -> @+count:U32 -> @view:0xa2af805348d03b11eb853850859654f6/tensor_view.View -> 0xa2af805348d03b11eb853850859654f6/tensor_view.View
A view of the cells of shape cells read only over the box of the piece that starts at first and holds count cells, in the piece's own order.