tensor_matrix_products.bend checks
raw source on the hub · import stelliferous@0.0.4.0/tensor_matrix_products.bend as Tensor_matrix_products
The products of left [count,rows,inner] with a shared right [outputs,inner] or a right of every image [count,inner,outputs], followed by bias [outputs]. The left takes its lanes on the inner axis. The right takes its lanes on the outputs, with the groups outermost for shared weights and innermost for image panels. The result [count,rows,outputs] has the output lanes, with its groups outermost for the shared-group schedule and innermost otherwise.
12 imports
import Base import ./kernel_tile.bend as Tile import ./kernel_gemm_buffer.bend as GemmBuffer import ./machine_limits.bend as Machine import ./storage_buffer.bend as Storage import ./tensor.bend as Tensors import ./tensor_grid.bend as Grid import ./tensor_pieces.bend as Pieces import ./tensor_tiled.bend as Tiled import ./tensor_tiled_map.bend as TiledMap import ./tensor_convolution.bend as Convolution import ./tensor_point_products.bend as PointProducts
Types
type Schedule source · line 38 · raw
Data
WindowSchedule
ImagePanelsSchedule
Definitions
def supported source · line 22 · raw
@+count:U32 -> @+rows:U32 -> @+inner:U32 -> @+outputs:U32 -> @+limits:0xa2af805348d03b11eb853850859654f6/machine_limits.Limits -> Bool
The lanes of the last group of rows and of outputs, the inner tiles and the result fit the machine.
def innermost source · line 28 · raw
@tiled:0xa2af805348d03b11eb853850859654f6/tensor_tiled.Tiled -> @+axis:Nat -> 0xa2af805348d03b11eb853850859654f6/tensor.Tensor<0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8>
def weight_cells source · line 32 · raw
@right:0xa2af805348d03b11eb853850859654f6/tensor_tiled.Tiled -> 0xa2af805348d03b11eb853850859654f6/tensor.Tensor<0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8>
Shared weights take their lanes along outputs, with complete groups adjacent.
def result source · line 35 · raw
@+count:U32 -> @+rows:U32 -> @+outputs:U32 -> @status:0xa2af805348d03b11eb853850859654f6/tensor.Status -> @cells:0xa2af805348d03b11eb853850859654f6/tensor.Tensor<0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8> -> 0xa2af805348d03b11eb853850859654f6/tensor_tiled.Tiled
def schedule source · line 46 · raw
@panels:Bool -> @+count:U32 -> @+rows:U32 -> @+inner:U32 -> @+outputs:U32 -> Schedule
def panel_products source · line 51 · raw
@whole:Bool -> @+count:U32 -> @+rows:U32 -> @+inner:U32 -> @+outputs:U32 -> @+workers:U32 -> @left:0xa2af805348d03b11eb853850859654f6/tensor_pieces.Pieces(0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8) -> @right:0xa2af805348d03b11eb853850859654f6/tensor_pieces.Pieces(0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8) -> @bias:0xa2af805348d03b11eb853850859654f6/storage_buffer.Buffer<0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8> -> 0xa2af805348d03b11eb853850859654f6/tensor_pieces.Pieces(0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8)
def apply_schedule source · line 59 · raw
@route:Schedule -> @+count:U32 -> @+rows:U32 -> @+inner:U32 -> @+outputs:U32 -> @+workers:U32 -> @left:0xa2af805348d03b11eb853850859654f6/tensor_pieces.Pieces(0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8) -> @weights:0xa2af805348d03b11eb853850859654f6/tensor.Tensor<0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8> -> @bias:0xa2af805348d03b11eb853850859654f6/storage_buffer.Buffer<0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8> -> 0xa2af805348d03b11eb853850859654f6/tensor_tiled.Tiled
The window reads the weights as one buffer, the other schedules read their pieces where they lie.
def scheduled_status source · line 75 · raw
@status:0xa2af805348d03b11eb853850859654f6/tensor.Status -> @+route:Schedule -> @+count:U32 -> @+rows:U32 -> @+inner:U32 -> @+outputs:U32 -> @+workers:U32 -> @left:0xa2af805348d03b11eb853850859654f6/tensor_pieces.Pieces(0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8) -> @weights:0xa2af805348d03b11eb853850859654f6/tensor.Tensor<0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8> -> @bias:0xa2af805348d03b11eb853850859654f6/storage_buffer.Buffer<0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8> -> 0xa2af805348d03b11eb853850859654f6/tensor_tiled.Tiled
def scheduled_run source · line 83 · raw
@+route:Schedule -> @+count:U32 -> @+rows:U32 -> @+inner:U32 -> @+outputs:U32 -> @+workers:U32 -> @left:0xa2af805348d03b11eb853850859654f6/tensor.Tensor<0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8> -> @weights:0xa2af805348d03b11eb853850859654f6/tensor.Tensor<0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8> -> @bias:0xa2af805348d03b11eb853850859654f6/tensor.Tensor<0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8> -> 0xa2af805348d03b11eb853850859654f6/tensor_tiled.Tiled
def left_rows source · line 91 · raw
@+count:U32 -> @+rows:U32 -> @+inner:U32 -> @left:0xa2af805348d03b11eb853850859654f6/tensor.Tensor<0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8> -> 0xa2af805348d03b11eb853850859654f6/tensor.Tensor<0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8>
The rows of left as [count,rows,1,groups].
def scheduled_lines source · line 94 · raw
@route:Schedule -> @+count:U32 -> @+rows:U32 -> @+inner:U32 -> @+outputs:U32 -> @+workers:U32 -> @left:0xa2af805348d03b11eb853850859654f6/tensor.Tensor<0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8> -> @right:0xa2af805348d03b11eb853850859654f6/tensor_tiled.Tiled -> @bias:0xa2af805348d03b11eb853850859654f6/tensor.Tensor<0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8> -> 0xa2af805348d03b11eb853850859654f6/tensor_tiled.Tiled
def lines source · line 105 · raw
@+count:U32 -> @+rows:U32 -> @+inner:U32 -> @+outputs:U32 -> @+workers:U32 -> @+right_axis:Nat -> @left:0xa2af805348d03b11eb853850859654f6/tensor_tiled.Tiled -> @right:0xa2af805348d03b11eb853850859654f6/tensor_tiled.Tiled -> @bias:0xa2af805348d03b11eb853850859654f6/tensor_tiled.Tiled -> 0xa2af805348d03b11eb853850859654f6/tensor_tiled.Tiled
left [count,rows,inner], right with its outputs at right_axis and bias [outputs]: the result [count,rows,outputs] with its lanes on the outputs, or the first failure. Every output adds its products in increasing inner index from +0.0, then its bias.