~/bend-docscommunity

tensor_move.bend checks

raw source on the hub · import stelliferous@0.0.4.0/tensor_move.bend as Tensor_move

Moving cells. A task holds the pieces it reads of a source and writes its target pieces by runs: a run is a line of target cells that read source cells one stride apart, cut where it leaves a source piece, so every copy reads one array. The target cells a part does not reach keep their values.

7 imports
import Base
import ./storage_buffer.bend as Storage
import ./storage_allocation.bend as Allocation
import ./storage_copy.bend as Copy
import ./traversal_partition.bend as Partition
import ./tensor_view.bend as Views
import ./tensor_pieces.bend as Pieces

Types

type Stack source · line 16 · raw

@-Element:Data -> Type

Pieces in ascending order of their first cell.

type Holding source · line 22 · raw

@-Element:Data -> Type

The current piece on top of ahead, the pieces before it on behind, nearest first.

type Stepped source · line 84 · raw

@-Element:Data -> Type

A run after a step: the cells it has left, from source cell offset into target from position on, and whether none are left.

type Axis source · line 124 · raw

Data

One axis of a part: its extent, the source stride (backward when back) and the target stride.

type Part source · line 130 · raw

Data

A box of target cells and the source cells it reads: every axis with its strides, the first source cell in the source tensor and the first target cell in the target piece. The last axis is the run.

type Offsets source · line 169 · raw

Data

The source and target offsets of row index of the axes before the run.

type Nest source · line 187 · raw

Data

The axes before the run: the last of them steps in the inner loop, the ones before it give the offsets of every block of its rows.

type Split source · line 229 · raw

Data

type Spare source · line 360 · raw

@-Element:Data -> Type

A buffer kept between bands, with room for capacity cells: a band assembled from several held pieces is copied into it.

type Lent source · line 369 · raw

@-Element:Data -> Type

A band lent from a held piece leaves a hole to put it back in and keeps the spare; a band assembled into the spare leaves the holding whole.

type Band source · line 375 · raw

@-Element:Data -> Type

The cells [first, first + count) of the held pieces in one buffer, from offset on.

Definitions

def inside source · line 63 · raw

@+count:U32 -> @+offset:U32 -> @+stride:U32 -> @+back:Bool -> @+first:U32 -> @+span:U32 -> U32

Cells of a run of count cells from offset, stride apart (backward when back), that lie in the piece from first of span cells. The reach counts the cells of the piece past offset in the direction of the run.

def directed source · line 68 · raw

@+back:Bool -> @+stride:U32 -> U32

def run_axes source · line 72 · raw

@contiguous:Bool -> @+cells:U32 -> @+stride:U32 -> @+back:Bool -> List<&2, 0xa2af805348d03b11eb853850859654f6/tensor_view.Axis>

The axes of a run: a contiguous run is copied from its offset alone.

def same_direction source · line 133 · raw

@+left:Bool -> @+right:Bool -> Bool

def chains source · line 136 · raw

@+outer:Axis -> @+inner:Axis -> Bool

def merged source · line 141 · raw

@+outer:Axis -> @+inner:Axis -> Axis

def joined_axis source · line 146 · raw

@chain:Bool -> @+outer:Axis -> @+inner:Axis -> @rest:List<&2, Axis> -> List<&2, Axis>

def joined_coalesced source · line 151 · raw

@+axis:Axis -> @rest:List<&2, Axis> -> List<&2, Axis>

def kept_coalesced source · line 156 · raw

@single:Bool -> @+axis:Axis -> @rest:List<&2, Axis> -> List<&2, Axis>

def coalesced source · line 163 · raw

@axes:List<&2, Axis> -> List<&2, Axis>

Adjacent axes whose strides chain on both sides, merged into one. An axis of one index steps nowhere and is left out.

def rows_of source · line 172 · raw

@axes:List<&2, Axis> -> U32

def row_offsets source · line 177 · raw

@axes:List<&2, Axis> -> @+row:U32 -> @+source:U32 -> @+target:U32 -> Offsets

def nest_prepended source · line 190 · raw

@+axis:Axis -> @nest:Nest -> Nest

def nest_of source · line 194 · raw

@axes:List<&2, Axis> -> Nest

def split_prepended source · line 232 · raw

@+axis:Axis -> @split:Split -> Split

def split_dense source · line 238 · raw

@dense:Bool -> @+axis:Axis -> Split

The last axis is the run when it steps one target cell. Otherwise every axis steps rows and each run is one cell.

def split_single source · line 243 · raw

@+axis:Axis -> Split

def split_last source · line 247 · raw

@axes:List<&2, Axis> -> Split

def run_fits source · line 256 · raw

@+run_axis:Axis -> @+offset:U32 -> @+first:U32 -> @+span:U32 -> Bool

Whether one piece holds every source cell of the axes before the run and the run from offset on: each forward axis, from the last cell the axes before it reach, is one step of a run that takes all its cells.

def fits_from source · line 260 · raw

@axes:List<&2, Axis> -> @+run_axis:Axis -> @+offset:U32 -> @+first:U32 -> @+span:U32 -> Bool

Templates

template stacked source · line 25 · raw

@-Element:Data -> @tree:0xa2af805348d03b11eb853850859654f6/tensor_pieces.Pieces(Element) -> @rest:Stack<Element> -> Stack<Element>

template held source · line 31 · raw

@-Element:Data -> @tree:0xa2af805348d03b11eb853850859654f6/tensor_pieces.Pieces(Element) -> Holding<Element>

The pieces of a tree, the first current.

template advanced source · line 35 · raw

@-Element:Data -> @below:Stack<Element> -> @step:Bool -> @+index:U32 -> @buffer:0xa2af805348d03b11eb853850859654f6/storage_buffer.Buffer<Element> -> @+first:U32 -> @+count:U32 -> @behind:Stack<Element> -> Holding<Element>

Forward past pieces that end at or before index, while a piece follows.

template backed source · line 42 · raw

@-Element:Data -> @behind:Stack<Element> -> @step:Bool -> @+index:U32 -> @ahead:Stack<Element> -> Holding<Element>

Back over pieces that begin after index, while a piece precedes.

template located source · line 47 · raw

@-Element:Data -> @before:Bool -> @+index:U32 -> @behind:Stack<Element> -> @buffer:0xa2af805348d03b11eb853850859654f6/storage_buffer.Buffer<Element> -> @+first:U32 -> @+count:U32 -> @below:Stack<Element> -> Holding<Element>

template resolve source · line 53 · raw

@-Element:Data -> @holding:Holding<Element> -> @+index:U32 -> Holding<Element>

The holding with the piece of cell index current, when it holds one.

template copied_run source · line 77 · raw

@-Element:Data -> @+cells:U32 -> @+local:U32 -> @+stride:U32 -> @+back:Bool -> @+position:U32 -> @input:0xa2af805348d03b11eb853850859654f6/storage_buffer.Buffer<Element> -> @output:0xa2af805348d03b11eb853850859654f6/storage_buffer.Buffer<Element> -> Pair(0xa2af805348d03b11eb853850859654f6/storage_buffer.Buffer<Element>, 0xa2af805348d03b11eb853850859654f6/storage_buffer.Buffer<Element>)

template stepped source · line 87 · raw

@-Element:Data -> @holding:Holding<Element> -> @target:0xa2af805348d03b11eb853850859654f6/storage_buffer.Buffer<Element> -> @+count:U32 -> @+offset:U32 -> @+stride:U32 -> @+back:Bool -> @+position:U32 -> @+cells:U32 -> Stepped<Element>

template stepped_in source · line 91 · raw

@-Element:Data -> @+count:U32 -> @+offset:U32 -> @+stride:U32 -> @+back:Bool -> @+position:U32 -> @+cells:U32 -> @behind:Stack<Element> -> @+first:U32 -> @+span:U32 -> @below:Stack<Element> -> @pair:Pair(0xa2af805348d03b11eb853850859654f6/storage_buffer.Buffer<Element>, 0xa2af805348d03b11eb853850859654f6/storage_buffer.Buffer<Element>) -> Stepped<Element>

template step source · line 97 · raw

@-Element:Data -> @holding:Holding<Element> -> @+count:U32 -> @+offset:U32 -> @+stride:U32 -> @+back:Bool -> @+position:U32 -> @target:0xa2af805348d03b11eb853850859654f6/storage_buffer.Buffer<Element> -> Stepped<Element>

The part of a run that the current piece holds, copied.

template run_on source · line 107 · raw

@-Element:Data -> @fuel:Nat -> @+stride:U32 -> @+back:Bool -> @last:Stepped<Element> -> Pair(Holding<Element>, 0xa2af805348d03b11eb853850859654f6/storage_buffer.Buffer<Element>)

The rest of a run after a step. A run stops early only where no held piece holds its cell.

template run source · line 116 · raw

@-Element:Data -> @fuel:Nat -> @+count:U32 -> @+offset:U32 -> @+stride:U32 -> @+back:Bool -> @+position:U32 -> @holding:Holding<Element> -> @target:0xa2af805348d03b11eb853850859654f6/storage_buffer.Buffer<Element> -> Pair(Holding<Element>, 0xa2af805348d03b11eb853850859654f6/storage_buffer.Buffer<Element>)

count cells from source cell offset, stride apart, into target from position on.

template row_run source · line 200 · raw

@-Element:Data -> @+run_axis:Axis -> @+source:U32 -> @+position:U32 -> @holding:Holding<Element> -> @target:0xa2af805348d03b11eb853850859654f6/storage_buffer.Buffer<Element> -> Pair(Holding<Element>, 0xa2af805348d03b11eb853850859654f6/storage_buffer.Buffer<Element>)

template inner_rows source · line 205 · raw

@-Element:Data -> @fuel:Nat -> @+step:U32 -> @+inner_target:U32 -> @+run_axis:Axis -> @+source:U32 -> @+position:U32 -> @pair:Pair(Holding<Element>, 0xa2af805348d03b11eb853850859654f6/storage_buffer.Buffer<Element>) -> Pair(Holding<Element>, 0xa2af805348d03b11eb853850859654f6/storage_buffer.Buffer<Element>)

The rows of one block, each a step of the inner axis after the last.

template block_rows source · line 213 · raw

@-Element:Data -> @+inner:Axis -> @+run_axis:Axis -> @offsets:Offsets -> @pair:Pair(Holding<Element>, 0xa2af805348d03b11eb853850859654f6/storage_buffer.Buffer<Element>) -> Pair(Holding<Element>, 0xa2af805348d03b11eb853850859654f6/storage_buffer.Buffer<Element>)

template rows source · line 219 · raw

@-Element:Data -> @fuel:Nat -> @+row:U32 -> @+outer:List<&2, Axis> -> @+inner:Axis -> @+run_axis:Axis -> @+source:U32 -> @+target_offset:U32 -> @pair:Pair(Holding<Element>, 0xa2af805348d03b11eb853850859654f6/storage_buffer.Buffer<Element>) -> Pair(Holding<Element>, 0xa2af805348d03b11eb853850859654f6/storage_buffer.Buffer<Element>)

Blocks from row on of the axes before the inner one.

template nested_rows source · line 225 · raw

@-Element:Data -> @+nest:Nest -> @+run_axis:Axis -> @+source:U32 -> @+target_offset:U32 -> @pair:Pair(Holding<Element>, 0xa2af805348d03b11eb853850859654f6/storage_buffer.Buffer<Element>) -> Pair(Holding<Element>, 0xa2af805348d03b11eb853850859654f6/storage_buffer.Buffer<Element>)

template piece_run source · line 267 · raw

@-Element:Data -> @+run_axis:Axis -> @+local:U32 -> @+position:U32 -> @input:0xa2af805348d03b11eb853850859654f6/storage_buffer.Buffer<Element> -> @target:0xa2af805348d03b11eb853850859654f6/storage_buffer.Buffer<Element> -> Pair(0xa2af805348d03b11eb853850859654f6/storage_buffer.Buffer<Element>, 0xa2af805348d03b11eb853850859654f6/storage_buffer.Buffer<Element>)

template piece_inner source · line 273 · raw

@-Element:Data -> @fuel:Nat -> @+step:U32 -> @+inner_target:U32 -> @+run_axis:Axis -> @+local:U32 -> @+position:U32 -> @pair:Pair(0xa2af805348d03b11eb853850859654f6/storage_buffer.Buffer<Element>, 0xa2af805348d03b11eb853850859654f6/storage_buffer.Buffer<Element>) -> Pair(0xa2af805348d03b11eb853850859654f6/storage_buffer.Buffer<Element>, 0xa2af805348d03b11eb853850859654f6/storage_buffer.Buffer<Element>)

The rows of one block of a part that one piece holds, each a step of the inner axis after the last, local cells from the first of the piece.

template piece_block source · line 281 · raw

@-Element:Data -> @+inner:Axis -> @+run_axis:Axis -> @offsets:Offsets -> @pair:Pair(0xa2af805348d03b11eb853850859654f6/storage_buffer.Buffer<Element>, 0xa2af805348d03b11eb853850859654f6/storage_buffer.Buffer<Element>) -> Pair(0xa2af805348d03b11eb853850859654f6/storage_buffer.Buffer<Element>, 0xa2af805348d03b11eb853850859654f6/storage_buffer.Buffer<Element>)

template piece_rows source · line 287 · raw

@-Element:Data -> @fuel:Nat -> @+row:U32 -> @+outer:List<&2, Axis> -> @+inner:Axis -> @+run_axis:Axis -> @+local:U32 -> @+target_offset:U32 -> @pair:Pair(0xa2af805348d03b11eb853850859654f6/storage_buffer.Buffer<Element>, 0xa2af805348d03b11eb853850859654f6/storage_buffer.Buffer<Element>) -> Pair(0xa2af805348d03b11eb853850859654f6/storage_buffer.Buffer<Element>, 0xa2af805348d03b11eb853850859654f6/storage_buffer.Buffer<Element>)

Blocks from row on of a part that one piece holds.

template piece_nested source · line 293 · raw

@-Element:Data -> @+nest:Nest -> @+run_axis:Axis -> @+local:U32 -> @+target_offset:U32 -> @pair:Pair(0xa2af805348d03b11eb853850859654f6/storage_buffer.Buffer<Element>, 0xa2af805348d03b11eb853850859654f6/storage_buffer.Buffer<Element>) -> Pair(0xa2af805348d03b11eb853850859654f6/storage_buffer.Buffer<Element>, 0xa2af805348d03b11eb853850859654f6/storage_buffer.Buffer<Element>)

template piece_returned source · line 297 · raw

@-Element:Data -> @behind:Stack<Element> -> @+first:U32 -> @+span:U32 -> @below:Stack<Element> -> @pair:Pair(0xa2af805348d03b11eb853850859654f6/storage_buffer.Buffer<Element>, 0xa2af805348d03b11eb853850859654f6/storage_buffer.Buffer<Element>) -> Pair(Holding<Element>, 0xa2af805348d03b11eb853850859654f6/storage_buffer.Buffer<Element>)

template piece_part source · line 302 · raw

@-Element:Data -> @inside:Bool -> @+nest:Nest -> @+run_axis:Axis -> @+source:U32 -> @+target_offset:U32 -> @behind:Stack<Element> -> @buffer:0xa2af805348d03b11eb853850859654f6/storage_buffer.Buffer<Element> -> @+first:U32 -> @+span:U32 -> @below:Stack<Element> -> @target:0xa2af805348d03b11eb853850859654f6/storage_buffer.Buffer<Element> -> Pair(Holding<Element>, 0xa2af805348d03b11eb853850859654f6/storage_buffer.Buffer<Element>)

template current_part source · line 308 · raw

@-Element:Data -> @+outer:List<&2, Axis> -> @+run_axis:Axis -> @+source:U32 -> @+target_offset:U32 -> @holding:Holding<Element> -> @target:0xa2af805348d03b11eb853850859654f6/storage_buffer.Buffer<Element> -> Pair(Holding<Element>, 0xa2af805348d03b11eb853850859654f6/storage_buffer.Buffer<Element>)

template split_part source · line 315 · raw

@-Element:Data -> @split:Split -> @+source:U32 -> @+target_offset:U32 -> @holding:Holding<Element> -> @target:0xa2af805348d03b11eb853850859654f6/storage_buffer.Buffer<Element> -> Pair(Holding<Element>, 0xa2af805348d03b11eb853850859654f6/storage_buffer.Buffer<Element>)

template part source · line 320 · raw

@-Element:Data -> @+own:Part -> @holding:Holding<Element> -> @target:0xa2af805348d03b11eb853850859654f6/storage_buffer.Buffer<Element> -> Pair(Holding<Element>, 0xa2af805348d03b11eb853850859654f6/storage_buffer.Buffer<Element>)

The target box of a part written from the held source pieces.

template parts_on source · line 324 · raw

@-Element:Data -> @listed:List<&2, Part> -> @pair:Pair(Holding<Element>, 0xa2af805348d03b11eb853850859654f6/storage_buffer.Buffer<Element>) -> Pair(Holding<Element>, 0xa2af805348d03b11eb853850859654f6/storage_buffer.Buffer<Element>)

template parts source · line 331 · raw

@-Element:Data -> @listed:List<&2, Part> -> @holding:Holding<Element> -> @target:0xa2af805348d03b11eb853850859654f6/storage_buffer.Buffer<Element> -> Pair(Holding<Element>, 0xa2af805348d03b11eb853850859654f6/storage_buffer.Buffer<Element>)

template held_read source · line 336 · raw

@-Element:Data -> @behind:Stack<Element> -> @+first:U32 -> @+span:U32 -> @below:Stack<Element> -> @pair:Pair(0xa2af805348d03b11eb853850859654f6/storage_buffer.Buffer<Element>, Element) -> Pair(Holding<Element>, Element)

template read_held source · line 340 · raw

@-Element:Data -> @held:Bool -> @+index:U32 -> @+fallback:Element -> @behind:Stack<Element> -> @buffer:0xa2af805348d03b11eb853850859654f6/storage_buffer.Buffer<Element> -> @+first:U32 -> @+span:U32 -> @below:Stack<Element> -> Pair(Holding<Element>, Element)

template read_current source · line 346 · raw

@-Element:Data -> @holding:Holding<Element> -> @+index:U32 -> @+fallback:Element -> Pair(Holding<Element>, Element)

template read source · line 353 · raw

@-Element:Data -> @holding:Holding<Element> -> @+index:U32 -> @+fallback:Element -> Pair(Holding<Element>, Element)

The source cell index, or fallback where no held piece holds it.

template spare source · line 364 · raw

@-Element:Data -> @+fill:Element -> Spare<Element>

A spare with no room yet.

template copied_into source · line 380 · raw

@-Element:Data -> @holding:Holding<Element> -> @+first:U32 -> @+count:U32 -> @target:0xa2af805348d03b11eb853850859654f6/storage_buffer.Buffer<Element> -> Pair(Holding<Element>, 0xa2af805348d03b11eb853850859654f6/storage_buffer.Buffer<Element>)

The cells [first, first + count) of the held pieces into target from its first cell on.

template copied source · line 384 · raw

@-Element:Data -> @holding:Holding<Element> -> @+first:U32 -> @+count:U32 -> @+fill:Element -> Pair(Holding<Element>, 0xa2af805348d03b11eb853850859654f6/storage_buffer.Buffer<Element>)

A copy of the cells [first, first + count) of the held pieces.

template assembled_band source · line 387 · raw

@-Element:Data -> @+capacity:U32 -> @pair:Pair(Holding<Element>, 0xa2af805348d03b11eb853850859654f6/storage_buffer.Buffer<Element>) -> Band<Element>

template roomy source · line 392 · raw

@-Element:Data -> @enough:Bool -> @+count:U32 -> @+fill:Element -> @buffer:0xa2af805348d03b11eb853850859654f6/storage_buffer.Buffer<Element> -> 0xa2af805348d03b11eb853850859654f6/storage_buffer.Buffer<Element>

The spare when it has room for count cells, otherwise a new buffer of count.

template assembled source · line 397 · raw

@-Element:Data -> @+first:U32 -> @+count:U32 -> @+fill:Element -> @holding:Holding<Element> -> @spare:Spare<Element> -> Band<Element>

template band_when source · line 401 · raw

@-Element:Data -> @within:Bool -> @+first:U32 -> @+count:U32 -> @+fill:Element -> @behind:Stack<Element> -> @buffer:0xa2af805348d03b11eb853850859654f6/storage_buffer.Buffer<Element> -> @+start:U32 -> @+span:U32 -> @below:Stack<Element> -> @spare:Spare<Element> -> Band<Element>

template band_current source · line 407 · raw

@-Element:Data -> @+first:U32 -> @+count:U32 -> @+fill:Element -> @holding:Holding<Element> -> @spare:Spare<Element> -> Band<Element>

template band source · line 415 · raw

@-Element:Data -> @holding:Holding<Element> -> @+first:U32 -> @+count:U32 -> @+fill:Element -> @spare:Spare<Element> -> Band<Element>

The band of cells [first, first + count): the held piece that holds all of it, lent, or the spare holding a copy of the parts the pieces hold.

template returned source · line 419 · raw

@-Element:Data -> @lent:Lent<Element> -> @buffer:0xa2af805348d03b11eb853850859654f6/storage_buffer.Buffer<Element> -> Pair(Holding<Element>, Spare<Element>)

The holding after a band, a lent piece back in its hole, and the spare.

template returned_holding source · line 425 · raw

@-Element:Data -> @lent:Lent<Element> -> @buffer:0xa2af805348d03b11eb853850859654f6/storage_buffer.Buffer<Element> -> Holding<Element>

The holding after a band whose spare is not kept.

template unstacked source · line 429 · raw

@-Element:Data -> @stack:Stack<Element> -> @tree:0xa2af805348d03b11eb853850859654f6/tensor_pieces.Pieces(Element) -> 0xa2af805348d03b11eb853850859654f6/tensor_pieces.Pieces(Element)

The held pieces as a tree, in order.

template onto_ahead source · line 435 · raw

@-Element:Data -> @behind:Stack<Element> -> @ahead:Stack<Element> -> Stack<Element>

The pieces of behind, nearest first, onto ahead: in the other order.

template first_leaf source · line 440 · raw

@-Element:Data -> @stack:Stack<Element> -> @+fill:Element -> Pair(0xa2af805348d03b11eb853850859654f6/tensor_pieces.Pieces(Element), Stack<Element>)

template released_stack source · line 445 · raw

@-Element:Data -> @pair:Pair(0xa2af805348d03b11eb853850859654f6/tensor_pieces.Pieces(Element), Stack<Element>) -> 0xa2af805348d03b11eb853850859654f6/tensor_pieces.Pieces(Element)

template released source · line 450 · raw

@-Element:Data -> @holding:Holding<Element> -> @+fill:Element -> 0xa2af805348d03b11eb853850859654f6/tensor_pieces.Pieces(Element)

The held pieces back as a tree in ascending order.