tensor_line_chain.bend checks
raw source on the hub · import stelliferous@0.0.4.0/tensor_line_chain.bend as Tensor_line_chain
Folds of every line of the cells. A line holds length cells of a block, inner cells apart, and the inner lines of a block interleave in its length * inner cells. Line i is line i % inner of block i / inner. The state of line i begins from context i modulo the count of contexts, folds the cells of the line in order and turns once into its final. A block longer than a piece lies in the pieces of whole outer indices and carries the states of its lines from piece to piece in order: a task holds whole blocks and walks its pieces once.
6 imports
import Base import ./storage_buffer.bend as Storage import ./traversal_partition.bend as Partition import ./tensor_grid.bend as Grid import ./tensor_pieces.bend as Pieces import ./tensor_tasks.bend as Tasks
Types
type Line source · line 17 · raw
Data
How the lines lie: length cells a line, inner cells apart.
Line@length:U32 -> @inner:U32 -> Line
type Lines source · line 29 · raw
@-Context:Data -> Data
The contexts of the lines and how they lie.
Lines@-Context:Data -> @contexts:List<&2, Context> -> @line:Line -> Lines<Context>
type States source · line 42 · raw
@-State:Type -> Type
The states of lines in order. A state may own storage, so it never lies in a List, which every program shares.
NoStates@-State:Type -> States<State>
Carried@-State:Type -> @state:State -> @rest:States<State> -> States<State>
type Folding source · line 49 · raw
@-Context:Data -> @-State:Type -> @-Final:Data -> Type
A pass that folds: column cells of the block in progress folded into starts, the contexts of the lines from the next block on, and the finals of the lines done, last first.
Folding@-Context:Data -> @-State:Type -> @-Final:Data -> @column:U32 -> @upcoming:List<&2, Context> -> @starts:States<State> -> @finals:List<&2, Final> -> Folding<Context, State, Final>
Definitions
def cells_of source · line 20 · raw
@line:Line -> U32
def inner_of source · line 24 · raw
@line:Line -> U32
def segments source · line 128 · raw
@+count:U32 -> @+cells:U32 -> Nat
Segments of a block of count cells: a block ends in it at most once a block it holds, and one block goes on past it.
Templates
template line_of source · line 32 · raw
@-Context:Data -> @lines:Lines<Context> -> Line
template contexts_of source · line 36 · raw
@-Context:Data -> @lines:Lines<Context> -> List<&2, Context>
template onto source · line 52 · raw
@-State:Type -> @folded:States<State> -> @states:States<State> -> States<State>
template unchanged source · line 57 · raw
@-Value:Data -> @value:Value -> Value
template refilled source · line 61 · raw
@-Context:Data -> @+all:List<&2, Context> -> @later:List<&2, Context> -> List<&2, Context>
The contexts after one taken: all again once they run out.
template placed source · line 68 · raw
@-Block:Type -> @-State:Type -> @-Final:Data -> @-turn:(@_:State -> Final) -> @ends:Bool -> @folded:States<State> -> @finals:List<&2, Final> -> @pair:Pair(Block, State) -> Pair(Block, Pair(States<State>, List<&2, Final>))
A folded line turned into its final when its block ends here, otherwise carried, last first.
template lines_folded source · line 78 · raw
@-Block:Type -> @-Context:Data -> @-State:Type -> @-Final:Data -> @+column:U32 -> @upcoming:List<&2, Context> -> @states:States<State> -> @progress:Pair(Block, Pair(States<State>, List<&2, Final>)) -> Pair(Block, Folding<Context, State, Final>)
template fold_lines source · line 88 · raw
@-Block:Type -> @-Context:Data -> @-State:Type -> @-Final:Data -> @-begin:(@_:Context -> State) -> @-fold:(@+count:Nat -> @+position:U32 -> @+step:U32 -> @initial:State -> @_:Block -> Pair(Block, State)) -> @-turn:(@_:State -> Final) -> @remaining:Nat -> @begins:Bool -> @+ends:Bool -> @+line:U32 -> @+inner:U32 -> @+column:U32 -> @+offset:U32 -> @+count:U32 -> @+next:U32 -> @+all:List<&2, Context> -> @upcoming:List<&2, Context> -> @states:States<State> -> @progress:Pair(Block, Pair(States<State>, List<&2, Final>)) -> Pair(Block, Folding<Context, State, Final>)
The lines of the block in progress from line on, each folded over its cells among count cells from offset whose first lies column cells into the block. A line begins from the next context when the block begins here, otherwise from the head of states. next is the column after the segment.
template fold_segments source · line 111 · raw
@-Block:Type -> @-Context:Data -> @-State:Type -> @-Final:Data -> @-begin:(@_:Context -> State) -> @-fold:(@+count:Nat -> @+position:U32 -> @+step:U32 -> @initial:State -> @_:Block -> Pair(Block, State)) -> @-turn:(@_:State -> Final) -> @fuel:Nat -> @done:Bool -> @+lines:Lines<Context> -> @+offset:U32 -> @+remaining:U32 -> @progress:Pair(Block, Folding<Context, State, Final>) -> Pair(Block, Folding<Context, State, Final>)
The remaining cells of a block from offset on, one segment of a block at a time. The lines of a block turn in the segment where it ends.
template fold_folded source · line 131 · raw
@-Block:Type -> @-Context:Data -> @-State:Type -> @-Final:Data -> @+first:U32 -> @+count:U32 -> @result:Pair(Block, Folding<Context, State, Final>) -> Pair(0xa2af805348d03b11eb853850859654f6/traversal_partition.Tree<&1, Block, Unit>, Folding<Context, State, Final>)
template fold_leaf source · line 137 · raw
@-Block:Type -> @-Context:Data -> @-State:Type -> @-Final:Data -> @-begin:(@_:Context -> State) -> @-fold:(@+count:Nat -> @+position:U32 -> @+step:U32 -> @initial:State -> @_:Block -> Pair(Block, State)) -> @-turn:(@_:State -> Final) -> @lines:Lines<Context> -> @first:U32 -> @count:U32 -> @block:Block -> @folding:Folding<Context, State, Final> -> Pair(0xa2af805348d03b11eb853850859654f6/traversal_partition.Tree<&1, Block, Unit>, Folding<Context, State, Final>)
A line of no cell folds nothing.
template finals_of source · line 146 · raw
@-Context:Data -> @-State:Type -> @-Final:Data -> @folding:Folding<Context, State, Final> -> List<&2, Final>
template upcoming_of source · line 151 · raw
@-Context:Data -> @+contexts:List<&2, Context> -> @+line:Line -> @+first:U32 -> List<&2, Context>
The contexts from the line of cell first on.
template folds_task source · line 155 · raw
@-Block:Type -> @-Context:Data -> @-State:Type -> @-Final:Data -> @-begin:(@_:Context -> State) -> @-fold:(@+count:Nat -> @+position:U32 -> @+step:U32 -> @initial:State -> @_:Block -> Pair(Block, State)) -> @-turn:(@_:State -> Final) -> @lines:Lines<Context> -> @first:U32 -> @count:U32 -> @tree:0xa2af805348d03b11eb853850859654f6/traversal_partition.Tree<&1, Block, Unit> -> 0xa2af805348d03b11eb853850859654f6/traversal_partition.Tree<&1, Pair(0xa2af805348d03b11eb853850859654f6/traversal_partition.Tree<&1, Block, Unit>, Folding<Context, State, Final>), Unit>
template task_finals source · line 164 · raw
@-Block:Type -> @-Context:Data -> @-State:Type -> @-Final:Data -> @result:Pair(0xa2af805348d03b11eb853850859654f6/traversal_partition.Tree<&1, Block, Unit>, Folding<Context, State, Final>) -> @done:List<&2, Final> -> Pair(0xa2af805348d03b11eb853850859654f6/traversal_partition.Tree<&1, Block, Unit>, List<&2, Final>)
template tasks_forked source · line 169 · raw
@-Block:Type -> @-Final:Data -> @right:0xa2af805348d03b11eb853850859654f6/traversal_partition.Tree<&1, Block, Unit> -> @left:Pair(0xa2af805348d03b11eb853850859654f6/traversal_partition.Tree<&1, Block, Unit>, List<&2, Final>) -> Pair(0xa2af805348d03b11eb853850859654f6/traversal_partition.Tree<&1, Block, Unit>, List<&2, Final>)
template tasks_unzipped source · line 174 · raw
@-Block:Type -> @-Context:Data -> @-State:Type -> @-Final:Data -> @tree:0xa2af805348d03b11eb853850859654f6/traversal_partition.Tree<&1, Pair(0xa2af805348d03b11eb853850859654f6/traversal_partition.Tree<&1, Block, Unit>, Folding<Context, State, Final>), Unit> -> @done:List<&2, Final> -> Pair(0xa2af805348d03b11eb853850859654f6/traversal_partition.Tree<&1, Block, Unit>, List<&2, Final>)
The blocks of every task and the finals of their lines, in order.
template folds_decided source · line 182 · raw
@-Block:Type -> @-Context:Data -> @-State:Type -> @-Final:Data -> @-begin:(@_:Context -> State) -> @-fold:(@+count:Nat -> @+position:U32 -> @+step:U32 -> @initial:State -> @_:Block -> Pair(Block, State)) -> @-turn:(@_:State -> Final) -> @decision:0xa2af805348d03b11eb853850859654f6/tensor_tasks.Decision -> @lines:Lines<Context> -> @pieces:0xa2af805348d03b11eb853850859654f6/traversal_partition.Tree<&1, Block, Unit> -> Pair(0xa2af805348d03b11eb853850859654f6/traversal_partition.Tree<&1, Block, Unit>, List<&2, Final>)
template folds source · line 193 · raw
@-Block:Type -> @-Fill:Data -> @-Context:Data -> @-State:Type -> @-Final:Data -> @-begin:(@_:Context -> State) -> @-fold:(@+count:Nat -> @+position:U32 -> @+step:U32 -> @initial:State -> @_:Block -> Pair(Block, State)) -> @-turn:(@_:State -> Final) -> @-vacant:(@_:Fill -> Block) -> @+contexts:List<&2, Context> -> @+line:Line -> @+group:U32 -> @+rows:F32 -> @+steps:F32 -> @+grid:0xa2af805348d03b11eb853850859654f6/tensor_grid.Grid -> @+fill:Fill -> @+workers:U32 -> @pieces:0xa2af805348d03b11eb853850859654f6/traversal_partition.Tree<&1, Block, Unit> -> Pair(0xa2af805348d03b11eb853850859654f6/traversal_partition.Tree<&1, Block, Unit>, List<&2, Final>)
The final of every line, in order: the state of a line begins from its context, fold folds its cells and turn ends it in its final. A block lies in the pieces of group outer indices of the grid. The pieces come back in the tree of those groups. rows and steps count one cell.