~/bend-docscommunity

tensor_indexed.bend checks

raw source on the hub · import stelliferous@0.0.2.0/tensor_indexed.bend as Tensor_indexed

Indexed mapping with a runtime context and a closed index template. The source and destination traversal are shared with checked tensor operations.

4 imports
import Base
import ./traversal_array.bend as Traversal
import ./traversal_loop.bend as Loop
import ./default_machine_limits.bend as Default

Types

type Call source · line 21 · raw

@-Context:Data -> Data

type Block source · line 35 · raw

Data

The same mapping over blocks of consecutive positions. A block starts where the previous one ended and gives position p the index base + (p - start), so an index that is a quotient and a remainder of the position costs one base per block instead of a division per element.

type Blocks source · line 42 · raw

@-Context:Data -> Data

Definitions

def block_index source · line 38 · raw

@block:Block -> @position:U32 -> U32

def block_limit source · line 71 · raw

U32

Blocks are used only up to the machine capacity, where the block size divides a position in U32 without overflow. No storage is larger.

Templates

template value source · line 8 · raw

@-Element:Data -> @-Context:Data -> @-index:(@_:Context -> @_:U32 -> U32) -> @-operation:(@_:U32 -> @_:Element -> Element) -> @context:Context -> @position:U32 -> @result:Pair(Array<Element>, Element) -> Pair(Array<Element>, Element)

template read source · line 13 · raw

@-Element:Data -> @-Context:Data -> @-index:(@_:Context -> @_:U32 -> U32) -> @-operation:(@_:U32 -> @_:Element -> Element) -> @source:Array<Element> -> @context:Context -> @position:U32 -> Pair(Array<Element>, Element)

template destination source · line 18 · raw

@-Context:Data -> @context:Context -> @position:U32 -> U32

template run source · line 24 · raw

@-Element:Data -> @-Context:Data -> @-index:(@_:Context -> @_:U32 -> U32) -> @-operation:(@_:U32 -> @_:Element -> Element) -> @call:Call<Context> -> @input:Array<Element> -> @output:Array<Element> -> Pair(Array<Element>, Array<Element>)

template next_block source · line 45 · raw

@-Element:Data -> @-Context:Data -> @block:U32 -> @size:U32 -> @context:Context -> @state:0x9be3b13bf249759bc81e1958bcd1a4c0/traversal_array.State<&1, &1, Array<Element>, Array<Element>, Block> -> 0x9be3b13bf249759bc81e1958bcd1a4c0/traversal_array.State<&1, &1, Array<Element>, Array<Element>, Blocks<Context>>

template block_step source · line 50 · raw

@-Element:Data -> @-Context:Data -> @-base:(@_:Context -> @_:U32 -> U32) -> @-operation:(@_:U32 -> @_:Element -> Element) -> @state:0x9be3b13bf249759bc81e1958bcd1a4c0/traversal_array.State<&1, &1, Array<Element>, Array<Element>, Blocks<Context>> -> 0x9be3b13bf249759bc81e1958bcd1a4c0/traversal_array.State<&1, &1, Array<Element>, Array<Element>, Blocks<Context>>

template run_blocks source · line 57 · raw

@-Element:Data -> @-Context:Data -> @-base:(@_:Context -> @_:U32 -> U32) -> @-operation:(@_:U32 -> @_:Element -> Element) -> @blocks:Nat -> @size:U32 -> @context:Context -> @input:Array<Element> -> @output:Array<Element> -> Pair(Array<Element>, Array<Element>)

template run_whole source · line 63 · raw

@-Element:Data -> @-Context:Data -> @-index:(@_:Context -> @_:U32 -> U32) -> @-base:(@_:Context -> @_:U32 -> U32) -> @-operation:(@_:U32 -> @_:Element -> Element) -> @whole:Bool -> @blocks:U32 -> @size:U32 -> @total:U32 -> @context:Context -> @input:Array<Element> -> @output:Array<Element> -> Pair(Array<Element>, Array<Element>)

template run_tiled source · line 77 · raw

@-Element:Data -> @-Context:Data -> @-index:(@_:Context -> @_:U32 -> U32) -> @-base:(@_:Context -> @_:U32 -> U32) -> @-blocks:(@_:Context -> U32) -> @-size:(@_:Context -> U32) -> @-operation:(@_:U32 -> @_:Element -> Element) -> @+total:U32 -> @+context:Context -> @input:Array<Element> -> @output:Array<Element> -> Pair(Array<Element>, Array<Element>)

total positions in blocks(context) blocks of size(context) positions. The blocks are used only when they are exactly the total and the total is within the limit; any other count keeps the index function.