tensor_tiled_broadcast.bend checks
raw source on the hub · import stelliferous@0.0.4.0/tensor_tiled_broadcast.bend as Tensor_tiled_broadcast
Binary operations of tiled operands that broadcast. When the left operand has the common extents, the right takes its lanes on the axis NumPy broadcasting aligns with the lane axis of the left, both groups innermost, and the cells broadcast as the values do: the right cells are read through the view of the cells of its stretched view, the view a gather of the cells reads. A right operand repeated along that axis has its values one a cell, every lane of a left cell combining with the value of its right cell. A left operand of other extents, and an empty operand, is repeated to the common extents first.
10 imports
import Base import ./kernel_tile.bend as Tile import ./tensor.bend as Tensors import ./tensor_grid.bend as Grid import ./tensor_shape.bend as Shapes import ./tensor_tiled.bend as Tiled import ./tensor_tiled_map.bend as TiledMap import ./tensor_tiled_view.bend as TiledView import ./tensor_view.bend as Views import ./tensor_tiled_layout.bend as TiledLayout
Definitions
def innermost source · line 21 · raw
@tiled:0xa2af805348d03b11eb853850859654f6/tensor_tiled.Tiled -> @+axis:Nat -> 0xa2af805348d03b11eb853850859654f6/tensor_tiled.Tiled
def repeated source · line 34 · raw
@same:Bool -> @+shape:List<&2, U32> -> @tiled:0xa2af805348d03b11eb853850859654f6/tensor_tiled.Tiled -> 0xa2af805348d03b11eb853850859654f6/tensor_tiled.Tiled
An operand of other extents is repeated to the common ones.
def spread_axes source · line 53 · raw
@within:Bool -> @+axes:List<&2, 0xa2af805348d03b11eb853850859654f6/tensor_view.Axis> -> @+axis:Nat -> @+groups:U32 -> List<&2, 0xa2af805348d03b11eb853850859654f6/tensor_view.Axis>
A view of values that repeats their lane axis, as a view of their cells: the other axes, then the groups at stride 0. Lanes past the axes leave the view as it is.
def lane_is source · line 77 · raw
@lane:Maybe<&2, Nat> -> @+axis:Nat -> Bool
Templates
template same_axes source · line 26 · raw
@-operation:(@_:F32 -> @_:F32 -> F32) -> @name:String -> @operations:F32 -> @left:Pair(0xa2af805348d03b11eb853850859654f6/tensor_tiled.Tiled, Nat) -> @right:0xa2af805348d03b11eb853850859654f6/tensor_tiled.Tiled -> 0xa2af805348d03b11eb853850859654f6/tensor_tiled.Tiled
Operands of one shape combine cell by cell, the lanes of the right on the axis of the left.
template same source · line 30 · raw
@-operation:(@_:F32 -> @_:F32 -> F32) -> @name:String -> @operations:F32 -> @left:0xa2af805348d03b11eb853850859654f6/tensor_tiled.Tiled -> @right:0xa2af805348d03b11eb853850859654f6/tensor_tiled.Tiled -> 0xa2af805348d03b11eb853850859654f6/tensor_tiled.Tiled
template values source · line 40 · raw
@-operation:(@_:F32 -> @_:F32 -> F32) -> @name:String -> @operations:F32 -> @+ls:List<&2, U32> -> @+rs:List<&2, U32> -> @+shape:List<&2, U32> -> @left:0xa2af805348d03b11eb853850859654f6/tensor_tiled.Tiled -> @right:0xa2af805348d03b11eb853850859654f6/tensor_tiled.Tiled -> 0xa2af805348d03b11eb853850859654f6/tensor_tiled.Tiled
Both operands repeated to the common extents combine cell by cell.
template spread_pairs source · line 45 · raw
@-operation:(@_:F32 -> @_:F32 -> F32) -> @left:0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8 -> @right:0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8 -> 0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8
The operation of every lane of the left tile with the first lane of the right.
template spread_with source · line 60 · raw
@-operation:(@_:F32 -> @_:F32 -> F32) -> @operations:F32 -> @+axis:Nat -> @+ls:List<&2, U32> -> @+axes:List<&2, 0xa2af805348d03b11eb853850859654f6/tensor_view.Axis> -> @+offset:U32 -> @left:0xa2af805348d03b11eb853850859654f6/tensor_tiled.Tiled -> @right:0xa2af805348d03b11eb853850859654f6/tensor_tiled.Tiled -> 0xa2af805348d03b11eb853850859654f6/tensor_tiled.Tiled
A right operand repeated along the lane axis of the left has its values one a cell, read through its stretched view as a view of the left cells.
template spread_or source · line 65 · raw
@-operation:(@_:F32 -> @_:F32 -> F32) -> @name:String -> @operations:F32 -> @spread:Bool -> @+axis:Nat -> @+ls:List<&2, U32> -> @+rs:List<&2, U32> -> @+axes:List<&2, 0xa2af805348d03b11eb853850859654f6/tensor_view.Axis> -> @+offset:U32 -> @left:0xa2af805348d03b11eb853850859654f6/tensor_tiled.Tiled -> @right:0xa2af805348d03b11eb853850859654f6/tensor_tiled.Tiled -> 0xa2af805348d03b11eb853850859654f6/tensor_tiled.Tiled
template aligned_with source · line 71 · raw
@-operation:(@_:F32 -> @_:F32 -> F32) -> @name:String -> @operations:F32 -> @held:Bool -> @+axis:Nat -> @+right_axis:Nat -> @+ls:List<&2, U32> -> @+rs:List<&2, U32> -> @+axes:List<&2, 0xa2af805348d03b11eb853850859654f6/tensor_view.Axis> -> @+offset:U32 -> @+cell_axes:List<&2, 0xa2af805348d03b11eb853850859654f6/tensor_view.Axis> -> @+cell_offset:U32 -> @left:0xa2af805348d03b11eb853850859654f6/tensor_tiled.Tiled -> @right:0xa2af805348d03b11eb853850859654f6/tensor_tiled.Tiled -> 0xa2af805348d03b11eb853850859654f6/tensor_tiled.Tiled
template held_cells source · line 86 · raw
@-operation:(@_:F32 -> @_:F32 -> F32) -> @name:String -> @operations:F32 -> @mapped:0xa2af805348d03b11eb853850859654f6/tensor_tiled_view.Mapped -> @+axis:Nat -> @+right_axis:Nat -> @+ls:List<&2, U32> -> @+rs:List<&2, U32> -> @+lanes:0xa2af805348d03b11eb853850859654f6/tensor_tiled_view.Lanes -> @+axes:List<&2, 0xa2af805348d03b11eb853850859654f6/tensor_view.Axis> -> @+offset:U32 -> @left:0xa2af805348d03b11eb853850859654f6/tensor_tiled.Tiled -> @right:0xa2af805348d03b11eb853850859654f6/tensor_tiled.Tiled -> 0xa2af805348d03b11eb853850859654f6/tensor_tiled.Tiled
The right keeps its lanes when its stretched view keeps them on the lane axis of the left, as a gather of the cells does: the right cells are read through the view of the cells of that gather. Otherwise a right operand that repeats along the lane axis of the left is read one value a cell.
template held_view source · line 96 · raw
@-operation:(@_:F32 -> @_:F32 -> F32) -> @name:String -> @operations:F32 -> @view:0xa2af805348d03b11eb853850859654f6/tensor_view.View -> @+axis:Nat -> @+right_axis:Nat -> @+ls:List<&2, U32> -> @+rs:List<&2, U32> -> @left:0xa2af805348d03b11eb853850859654f6/tensor_tiled.Tiled -> @right:0xa2af805348d03b11eb853850859654f6/tensor_tiled.Tiled -> 0xa2af805348d03b11eb853850859654f6/tensor_tiled.Tiled
template aligned_cells source · line 104 · raw
@-operation:(@_:F32 -> @_:F32 -> F32) -> @name:String -> @operations:F32 -> @+ls:List<&2, U32> -> @+rs:List<&2, U32> -> @started:Pair(0xa2af805348d03b11eb853850859654f6/tensor_tiled.Tiled, Nat) -> @right:0xa2af805348d03b11eb853850859654f6/tensor_tiled.Tiled -> 0xa2af805348d03b11eb853850859654f6/tensor_tiled.Tiled
The lanes of the left on axis: the right axis aligned with it holds the same extent or repeats one index.
template full_cells source · line 109 · raw
@-operation:(@_:F32 -> @_:F32 -> F32) -> @name:String -> @full:Bool -> @operations:F32 -> @+ls:List<&2, U32> -> @+rs:List<&2, U32> -> @+shape:List<&2, U32> -> @left:0xa2af805348d03b11eb853850859654f6/tensor_tiled.Tiled -> @right:0xa2af805348d03b11eb853850859654f6/tensor_tiled.Tiled -> 0xa2af805348d03b11eb853850859654f6/tensor_tiled.Tiled
template common_shape source · line 115 · raw
@-operation:(@_:F32 -> @_:F32 -> F32) -> @name:String -> @common:Maybe<&2, List<&2, U32>> -> @operations:F32 -> @+ls:List<&2, U32> -> @+rs:List<&2, U32> -> @left:0xa2af805348d03b11eb853850859654f6/tensor_tiled.Tiled -> @right:0xa2af805348d03b11eb853850859654f6/tensor_tiled.Tiled -> 0xa2af805348d03b11eb853850859654f6/tensor_tiled.Tiled
template combine source · line 123 · raw
@-operation:(@_:F32 -> @_:F32 -> F32) -> @name:String -> @operations:F32 -> @+ls:List<&2, U32> -> @+rs:List<&2, U32> -> @left:0xa2af805348d03b11eb853850859654f6/tensor_tiled.Tiled -> @right:0xa2af805348d03b11eb853850859654f6/tensor_tiled.Tiled -> 0xa2af805348d03b11eb853850859654f6/tensor_tiled.Tiled
Usable tiled operands of other extents under NumPy broadcasting, on the cells. Incompatible extents fail and keep the left tensor.