~/bend-docscommunity

tensor_access.bend checks

raw source on the hub · import stelliferous@0.0.4.0/tensor_access.bend as Tensor_access

Internal tensor read layouts and unchecked traversal kernels.

5 imports
import Base
import ./tensor_view.bend as Views
import ./traversal_array.bend as Traversal
import ./traversal_loop.bend as Loop
import ./tensor_cursor.bend as Cursor

Types

type Choice source · line 99 · raw

@-Element:Data -> Data

A ternary update reads the mask and the second operand at one position from a pair of arrays.

type Pool source · line 128 · raw

Data

The geometry of a two-dimensional window reduction over the last two axes. It runs as two sweeps: along the columns of every row, then along the rows.

Definitions

def zero_contiguous source · line 84 · raw

@+view:0xa2af805348d03b11eb853850859654f6/tensor_view.View -> Bool

Templates

template last_of_run source · line 15 · raw

@-Element:Data -> @extent:Nat -> @stride:U32 -> @rewind:U32 -> @rest:0xa2af805348d03b11eb853850859654f6/tensor_cursor.Depth1 -> @state:0xa2af805348d03b11eb853850859654f6/traversal_array.State<&1, &1, Array<Element>, Array<Element>, 0xa2af805348d03b11eb853850859654f6/tensor_cursor.Stride> -> 0xa2af805348d03b11eb853850859654f6/traversal_array.State<&1, &1, Array<Element>, Array<Element>, 0xa2af805348d03b11eb853850859654f6/tensor_cursor.Cursor>

A strided operation visits the source view in row-major order. It proceeds in runs of the innermost axis: every element of a run but the last advances only the address, and the last takes the ordinary cursor step, which carries into the outer axes. The element loop is a small native loop whatever else shares the cursor; stepping the whole cursor per element costs several calls with a wide state once more than one operation uses it. inside and last are the same element action, stepping a stride and the whole cursor.

template run_axis source · line 20 · raw

@-Element:Data -> @-inside:(@_:0xa2af805348d03b11eb853850859654f6/traversal_array.State<&1, &1, Array<Element>, Array<Element>, 0xa2af805348d03b11eb853850859654f6/tensor_cursor.Stride> -> 0xa2af805348d03b11eb853850859654f6/traversal_array.State<&1, &1, Array<Element>, Array<Element>, 0xa2af805348d03b11eb853850859654f6/tensor_cursor.Stride>) -> @-last:(@_:0xa2af805348d03b11eb853850859654f6/traversal_array.State<&1, &1, Array<Element>, Array<Element>, 0xa2af805348d03b11eb853850859654f6/tensor_cursor.Cursor> -> 0xa2af805348d03b11eb853850859654f6/traversal_array.State<&1, &1, Array<Element>, Array<Element>, 0xa2af805348d03b11eb853850859654f6/tensor_cursor.Cursor>) -> @remaining:Nat -> @extent:Nat -> @+stride:U32 -> @rewind:U32 -> @rest:0xa2af805348d03b11eb853850859654f6/tensor_cursor.Depth1 -> @+address:U32 -> @input:Array<Element> -> @output:Array<Element> -> @position:U32 -> 0xa2af805348d03b11eb853850859654f6/traversal_array.State<&1, &1, Array<Element>, Array<Element>, 0xa2af805348d03b11eb853850859654f6/tensor_cursor.Cursor>

template run_step source · line 29 · raw

@-Element:Data -> @-inside:(@_:0xa2af805348d03b11eb853850859654f6/traversal_array.State<&1, &1, Array<Element>, Array<Element>, 0xa2af805348d03b11eb853850859654f6/tensor_cursor.Stride> -> 0xa2af805348d03b11eb853850859654f6/traversal_array.State<&1, &1, Array<Element>, Array<Element>, 0xa2af805348d03b11eb853850859654f6/tensor_cursor.Stride>) -> @-last:(@_:0xa2af805348d03b11eb853850859654f6/traversal_array.State<&1, &1, Array<Element>, Array<Element>, 0xa2af805348d03b11eb853850859654f6/tensor_cursor.Cursor> -> 0xa2af805348d03b11eb853850859654f6/traversal_array.State<&1, &1, Array<Element>, Array<Element>, 0xa2af805348d03b11eb853850859654f6/tensor_cursor.Cursor>) -> @state:0xa2af805348d03b11eb853850859654f6/traversal_array.State<&1, &1, Array<Element>, Array<Element>, 0xa2af805348d03b11eb853850859654f6/tensor_cursor.Cursor> -> 0xa2af805348d03b11eb853850859654f6/traversal_array.State<&1, &1, Array<Element>, Array<Element>, 0xa2af805348d03b11eb853850859654f6/tensor_cursor.Cursor>

template run_guarded source · line 37 · raw

@-Element:Data -> @-inside:(@_:0xa2af805348d03b11eb853850859654f6/traversal_array.State<&1, &1, Array<Element>, Array<Element>, 0xa2af805348d03b11eb853850859654f6/tensor_cursor.Stride> -> 0xa2af805348d03b11eb853850859654f6/traversal_array.State<&1, &1, Array<Element>, Array<Element>, 0xa2af805348d03b11eb853850859654f6/tensor_cursor.Stride>) -> @-last:(@_:0xa2af805348d03b11eb853850859654f6/traversal_array.State<&1, &1, Array<Element>, Array<Element>, 0xa2af805348d03b11eb853850859654f6/tensor_cursor.Cursor> -> 0xa2af805348d03b11eb853850859654f6/traversal_array.State<&1, &1, Array<Element>, Array<Element>, 0xa2af805348d03b11eb853850859654f6/tensor_cursor.Cursor>) -> @full_run:Bool -> @whole_runs:Bool -> @runs:Nat -> @count:Nat -> @cursor:0xa2af805348d03b11eb853850859654f6/tensor_cursor.Cursor -> @destination:U32 -> @input:Array<Element> -> @output:Array<Element> -> Pair(Array<Element>, Array<Element>)

Runs are used when the cursor starts a full run and count is a whole number of runs; any other call steps element by element. Both visit the same elements in the same order.

template run_remaining source · line 48 · raw

@-Element:Data -> @-inside:(@_:0xa2af805348d03b11eb853850859654f6/traversal_array.State<&1, &1, Array<Element>, Array<Element>, 0xa2af805348d03b11eb853850859654f6/tensor_cursor.Stride> -> 0xa2af805348d03b11eb853850859654f6/traversal_array.State<&1, &1, Array<Element>, Array<Element>, 0xa2af805348d03b11eb853850859654f6/tensor_cursor.Stride>) -> @-last:(@_:0xa2af805348d03b11eb853850859654f6/traversal_array.State<&1, &1, Array<Element>, Array<Element>, 0xa2af805348d03b11eb853850859654f6/tensor_cursor.Cursor> -> 0xa2af805348d03b11eb853850859654f6/traversal_array.State<&1, &1, Array<Element>, Array<Element>, 0xa2af805348d03b11eb853850859654f6/tensor_cursor.Cursor>) -> @remaining:Nat -> @+extent:Nat -> @stride:U32 -> @rewind:U32 -> @rest:0xa2af805348d03b11eb853850859654f6/tensor_cursor.Depth1 -> @address:U32 -> @+count:Nat -> @destination:U32 -> @input:Array<Element> -> @output:Array<Element> -> Pair(Array<Element>, Array<Element>)

template run_strided source · line 60 · raw

@-Element:Data -> @-inside:(@_:0xa2af805348d03b11eb853850859654f6/traversal_array.State<&1, &1, Array<Element>, Array<Element>, 0xa2af805348d03b11eb853850859654f6/tensor_cursor.Stride> -> 0xa2af805348d03b11eb853850859654f6/traversal_array.State<&1, &1, Array<Element>, Array<Element>, 0xa2af805348d03b11eb853850859654f6/tensor_cursor.Stride>) -> @-last:(@_:0xa2af805348d03b11eb853850859654f6/traversal_array.State<&1, &1, Array<Element>, Array<Element>, 0xa2af805348d03b11eb853850859654f6/tensor_cursor.Cursor> -> 0xa2af805348d03b11eb853850859654f6/traversal_array.State<&1, &1, Array<Element>, Array<Element>, 0xa2af805348d03b11eb853850859654f6/tensor_cursor.Cursor>) -> @count:Nat -> @cursor:0xa2af805348d03b11eb853850859654f6/tensor_cursor.Cursor -> @destination:U32 -> @input:Array<Element> -> @output:Array<Element> -> Pair(Array<Element>, Array<Element>)

template copy_strided source · line 65 · raw

@-Element:Data -> @count:Nat -> @cursor:0xa2af805348d03b11eb853850859654f6/tensor_cursor.Cursor -> @destination:U32 -> @input:Array<Element> -> @output:Array<Element> -> Pair(Array<Element>, Array<Element>)

template update_strided source · line 71 · raw

@-Element:Data -> @-operation:(@_:Element -> @_:Element -> Element) -> @count:Nat -> @cursor:0xa2af805348d03b11eb853850859654f6/tensor_cursor.Cursor -> @destination:U32 -> @input:Array<Element> -> @output:Array<Element> -> Pair(Array<Element>, Array<Element>)

output[destination + i] = operation(output[destination + i], element i of the view).

template copy_run source · line 76 · raw

@-Element:Data -> @contiguous:Bool -> @count:Nat -> @source:0xa2af805348d03b11eb853850859654f6/tensor_view.View -> @destination:U32 -> @input:Array<Element> -> @output:Array<Element> -> Pair(Array<Element>, Array<Element>)

template combine_run source · line 88 · raw

@-Element:Data -> @-operation:(@_:Element -> @_:Element -> Element) -> @fast:Bool -> @count:Nat -> @right_view:0xa2af805348d03b11eb853850859654f6/tensor_view.View -> @destination:U32 -> @right:Array<Element> -> @output:Array<Element> -> Pair(Array<Element>, Array<Element>)

template choice_joined source · line 102 · raw

@-Element:Data -> @mask:Pair(Array<Element>, Element) -> @no:Pair(Array<Element>, Element) -> Pair(Pair(Array<Element>, Array<Element>), Choice<Element>)

template choice_read source · line 107 · raw

@-Element:Data -> @reader:Pair(Array<Element>, Array<Element>) -> @context:Unit -> @position:U32 -> Pair(Pair(Array<Element>, Array<Element>), Choice<Element>)

template chosen source · line 112 · raw

@-Element:Data -> @-choose:(@_:Element -> @_:Element -> @_:Element -> Element) -> @yes:Element -> @choice:Choice<Element> -> Element

template choose_run source · line 117 · raw

@-Element:Data -> @-choose:(@_:Element -> @_:Element -> @_:Element -> Element) -> @count:Nat -> @mask:Array<Element> -> @no:Array<Element> -> @output:Array<Element> -> Pair(Pair(Array<Element>, Array<Element>), Array<Element>)

output[i] = choose(mask[i], output[i], no[i]) for the first count positions.

template apply_element source · line 123 · raw

@-Element:Data -> @-operation:(@_:Element -> Element) -> @context:Unit -> @value:Element -> Element