tensor_partials.bend checks
raw source on the hub · import stelliferous@0.0.4.0/tensor_partials.bend as Tensor_partials
The order of a sum across rows. A row is a line of the axis before the trailing kept axes, and its partial is the fold of its values. The cells of the trailing axes interleave in the rows: every index of them has rows of its own, as if those axes came before the axis of the rows. Row i begins from context i modulo the count of contexts. The partials of the rows an output adds merge in one tree over the reduced axes, outermost first: over the indices of an axis a left-complete binary tree whose left side holds the largest power of two below the count, each of its leaves the tree over the next axis, the last axis merging the partials. The tree depends on the shape only, never on the pieces, the tasks or the workers.
10 imports
import Base import ./storage_buffer.bend as Storage import ./tensor_view.bend as Views import ./tensor_pieces.bend as Pieces import ./tensor_grid.bend as Grid import ./tensor.bend as Tensors import ./tensor_line_chain.bend as LineChain import ./tensor_layout.bend as Layout import ./tensor_shape.bend as Shapes import ./traversal_partition.bend as Partition
Definitions
def ones_below source · line 38 · raw
@remaining:Nat -> @odd:Bool -> @+index:U32 -> Nat
def trailing_ones source · line 44 · raw
@+index:U32 -> Nat
The trailing ones of index.
def flag_removed source · line 109 · raw
@flags:List<&2, Bool> -> @axis:Nat -> List<&2, Bool>
def flag_at source · line 115 · raw
@flags:List<&2, Bool> -> @axis:Nat -> Bool
def extents_removed source · line 121 · raw
@count:Nat -> @extents:List<&2, U32> -> @+axis:Nat -> List<&2, U32>
def flags_removed source · line 126 · raw
@count:Nat -> @flags:List<&2, Bool> -> @+axis:Nat -> List<&2, Bool>
def row_extents source · line 133 · raw
@reduced:Bool -> @extents:List<&2, U32> -> @+first:Nat -> @+spanned:Nat -> List<&2, U32>
The extents and flags of the box: the spanned axes of a reduced row from first on removed.
def row_flags source · line 138 · raw
@reduced:Bool -> @flags:List<&2, Bool> -> @+first:Nat -> @+spanned:Nat -> List<&2, Bool>
def cells_per_outer source · line 153 · raw
@+grid:0xa2af805348d03b11eb853850859654f6/tensor_grid.Grid -> U32
def row_line source · line 163 · raw
@reduced:Bool -> @+shape:List<&2, U32> -> @+first:Nat -> @+spanned:Nat -> 0xa2af805348d03b11eb853850859654f6/tensor_line_chain.Line
The rows of the spanned axes from first on, the cells of the axes after them apart, or every cell a row when the axes are kept.
def kept_extent source · line 193 · raw
@reduced:Bool -> @extent:U32 -> @rest:List<&2, U32> -> List<&2, U32>
def kept_extents source · line 198 · raw
@extents:List<&2, U32> -> @flags:List<&2, Bool> -> List<&2, U32>
Templates
template merged_runs source · line 33 · raw
@-Partial:Data -> @-merge:(@_:Partial -> @_:Partial -> Partial) -> @left:List<&2, Partial> -> @right:List<&2, Partial> -> List<&2, Partial>
Two runs merged at every position, left after right.
template counted source · line 47 · raw
@-Partial:Data -> @-merge:(@_:Partial -> @_:Partial -> Partial) -> @counter:List<&2, List<&2, Partial>> -> @merges:Nat -> @run:List<&2, Partial> -> List<&2, List<&2, Partial>>
template counter_merged source · line 52 · raw
@-Partial:Data -> @-merge:(@_:Partial -> @_:Partial -> Partial) -> @counter:List<&2, List<&2, Partial>> -> @run:List<&2, Partial> -> List<&2, Partial>
template counter_total source · line 57 · raw
@-Partial:Data -> @-merge:(@_:Partial -> @_:Partial -> Partial) -> @counter:List<&2, List<&2, Partial>> -> List<&2, Partial>
template reduced_pass source · line 64 · raw
@-Partial:Data -> @-merge:(@_:Partial -> @_:Partial -> Partial) -> @runs:List<&2, List<&2, Partial>> -> @last:Bool -> @+extent:U32 -> @+index:U32 -> @counter:List<&2, List<&2, Partial>> -> @done:List<&2, List<&2, Partial>> -> List<&2, List<&2, Partial>>
The runs of the lines of a reduced axis of extent indices, last first after done; last says whether the run in front ends its line.
template reversed_onto source · line 73 · raw
@-Partial:Data -> @run:List<&2, Partial> -> @joined:List<&2, Partial> -> List<&2, Partial>
template kept_pass source · line 80 · raw
@-Partial:Data -> @runs:List<&2, List<&2, Partial>> -> @last:Bool -> @+extent:U32 -> @+index:U32 -> @joined:List<&2, Partial> -> @done:List<&2, List<&2, Partial>> -> List<&2, List<&2, Partial>>
The runs of the lines of a kept axis joined, last first after done; joined holds the line so far reversed.
template axis_pass source · line 86 · raw
@-Partial:Data -> @-merge:(@_:Partial -> @_:Partial -> Partial) -> @reduced:Bool -> @+extent:U32 -> @runs:List<&2, List<&2, Partial>> -> List<&2, List<&2, Partial>>
template passes source · line 92 · raw
@-Partial:Data -> @-merge:(@_:Partial -> @_:Partial -> Partial) -> @extents:List<&2, U32> -> @flags:List<&2, Bool> -> @runs:List<&2, List<&2, Partial>> -> List<&2, List<&2, Partial>>
The passes of the axes, innermost first: extents and flags reversed.
template singles source · line 97 · raw
@-Partial:Data -> @partials:List<&2, Partial> -> List<&2, List<&2, Partial>>
template only_run source · line 102 · raw
@-Partial:Data -> @runs:List<&2, List<&2, Partial>> -> List<&2, Partial>
template box_outputs source · line 145 · raw
@-Partial:Data -> @-merge:(@_:Partial -> @_:Partial -> Partial) -> @+extents:List<&2, U32> -> @+flags:List<&2, Bool> -> @partials:List<&2, Partial> -> List<&2, Partial>
The partials of the outputs of a box of rows, given the partials of the rows in the row-major order of the box without the row axis.
template carried_joined source · line 148 · raw
@-Block:Type -> @-Partial:Data -> @-merge:(@_:Partial -> @_:Partial -> Partial) -> @+extents:List<&2, U32> -> @+flags:List<&2, Bool> -> @folded:Pair(0xa2af805348d03b11eb853850859654f6/traversal_partition.Tree<&1, Block, Unit>, List<&2, Partial>) -> Pair(0xa2af805348d03b11eb853850859654f6/traversal_partition.Tree<&1, Block, Unit>, List<&2, Partial>)
template regrouped_back source · line 157 · raw
@-Block:Type -> @-Fill:Data -> @-Partial:Data -> @-vacant:(@_:Fill -> Block) -> @+grid:0xa2af805348d03b11eb853850859654f6/tensor_grid.Grid -> @+fill:Fill -> @result:Pair(0xa2af805348d03b11eb853850859654f6/traversal_partition.Tree<&1, Block, Unit>, List<&2, Partial>) -> Pair(0xa2af805348d03b11eb853850859654f6/traversal_partition.Tree<&1, Block, Unit>, List<&2, Partial>)
template read source · line 177 · raw
@-Block:Type -> @-Fill:Data -> @-Context:Data -> @-Row:Type -> @-Partial:Data -> @-begin:(@_:Context -> Row) -> @-fold:(@+count:Nat -> @+position:U32 -> @+step:U32 -> @initial:Row -> @_:Block -> Pair(Block, Row)) -> @-close:(@_:Row -> Partial) -> @-merge:(@_:Partial -> @_:Partial -> Partial) -> @-vacant:(@_:Fill -> Block) -> @+contexts:List<&2, Context> -> @+rows:F32 -> @+steps:F32 -> @+shape:List<&2, U32> -> @+flags:List<&2, Bool> -> @+trailing:Nat -> @+spanned:Nat -> @+fill:Fill -> @+workers:U32 -> @pieces:0xa2af805348d03b11eb853850859654f6/traversal_partition.Tree<&1, Block, Unit> -> Pair(0xa2af805348d03b11eb853850859654f6/traversal_partition.Tree<&1, Block, Unit>, List<&2, Partial>)
The merged partials of the outputs of a reduction of the pieces of cells of shape, no extent zero, in the row-major order of the kept axes, and the pieces back in the tree of their grid. The last trailing axes are kept and interleave in the rows of the spanned axes before them, which are reduced or all kept. fold folds count cells of a row step apart from position into a row state; a block too short for a task is vacant. rows and steps count one cell. The rows fold across the pieces in order, then their partials merge in the tree.
template finished source · line 188 · raw
@-Element:Data -> @-Partial:Data -> @-finish:(@_:Partial -> Element) -> @partials:List<&2, Partial> -> List<&2, Element>
template partials_only source · line 203 · raw
@-Block:Type -> @-Partial:Data -> @result:Pair(0xa2af805348d03b11eb853850859654f6/traversal_partition.Tree<&1, Block, Unit>, List<&2, Partial>) -> List<&2, Partial>
template reduce_sized source · line 209 · raw
@-Element:Data -> @-Context:Data -> @-Row:Type -> @-Partial:Data -> @-begin:(@_:Context -> Row) -> @-fold:(@+count:Nat -> @+position:U32 -> @+step:U32 -> @initial:Row -> @_:0xa2af805348d03b11eb853850859654f6/storage_buffer.Buffer<Element> -> Pair(0xa2af805348d03b11eb853850859654f6/storage_buffer.Buffer<Element>, Row)) -> @-close:(@_:Row -> Partial) -> @-merge:(@_:Partial -> @_:Partial -> Partial) -> @-finish:(@_:Partial -> Element) -> @empty:Bool -> @unread:Bool -> @+operations:F32 -> @+context:Context -> @+zero:Partial -> @pieces:0xa2af805348d03b11eb853850859654f6/tensor_pieces.Pieces(Element) -> @+shape:List<&2, U32> -> @+flags:List<&2, Bool> -> @+fill:Element -> @+workers:U32 -> 0xa2af805348d03b11eb853850859654f6/tensor.Tensor<Element>
empty: a kept extent is zero, every output then fill. unread: a reduced extent is zero, every output then the finish of zero.
template reduce_listed source · line 221 · raw
@-Element:Data -> @-Context:Data -> @-Row:Type -> @-Partial:Data -> @-begin:(@_:Context -> Row) -> @-fold:(@+count:Nat -> @+position:U32 -> @+step:U32 -> @initial:Row -> @_:0xa2af805348d03b11eb853850859654f6/storage_buffer.Buffer<Element> -> Pair(0xa2af805348d03b11eb853850859654f6/storage_buffer.Buffer<Element>, Row)) -> @-close:(@_:Row -> Partial) -> @-merge:(@_:Partial -> @_:Partial -> Partial) -> @-finish:(@_:Partial -> Element) -> @+name:String -> @status:0xa2af805348d03b11eb853850859654f6/tensor.Status -> @valid:Bool -> @+operations:F32 -> @+context:Context -> @+zero:Partial -> @pieces:0xa2af805348d03b11eb853850859654f6/tensor_pieces.Pieces(Element) -> @+shape:List<&2, U32> -> @+flags:List<&2, Bool> -> @+fill:Element -> @+workers:U32 -> 0xa2af805348d03b11eb853850859654f6/tensor.Tensor<Element>
template reduce source · line 236 · raw
@-Element:Data -> @-Context:Data -> @-Row:Type -> @-Partial:Data -> @-begin:(@_:Context -> Row) -> @-fold:(@+count:Nat -> @+position:U32 -> @+step:U32 -> @initial:Row -> @_:0xa2af805348d03b11eb853850859654f6/storage_buffer.Buffer<Element> -> Pair(0xa2af805348d03b11eb853850859654f6/storage_buffer.Buffer<Element>, Row)) -> @-close:(@_:Row -> Partial) -> @-merge:(@_:Partial -> @_:Partial -> Partial) -> @-finish:(@_:Partial -> Element) -> @name:String -> @+operations:F32 -> @+context:Context -> @+zero:Partial -> @tensor:0xa2af805348d03b11eb853850859654f6/tensor.Tensor<Element> -> @+axes:List<&2, U32> -> 0xa2af805348d03b11eb853850859654f6/tensor.Tensor<Element>
The reduction of the listed axes in the order of this file: every row folded from begin of the context by fold and closed, the partials merged in the tree, and finish of the merged partial. The result has the extents of the axes kept. operations counts the steps of one value. A row is a line of the last axis when it is reduced, otherwise every value.