~/bend-docscommunity

tensor.bend checks

raw source on the hub · import stelliferous@0.0.3.0/tensor.bend as Tensor

A public tensor owns bands of row-major storage and the geometry they split, its extents, the value used to initialize allocations, a sticky status, and the number of workers its operations may use. A whole tensor is one band that holds every element. A failed operation leaves values untouched and records why; later operations skip a failed tensor, and check is the only way to observe or clear the failure.

12 imports
import Base
import ./storage_buffer.bend as Storage
import ./storage_allocation.bend as Allocation
import ./tensor_shape.bend as Shapes
import ./tensor_view.bend as Views
import ./tensor_operations.bend as Operations
import ./machine_limits.bend as Machine
import ./default_machine_limits.bend as Default
import ./tensor_band.bend as Bands
import ./tensor_band_schedule.bend as BandSchedule
import ./tensor_band_view.bend as BandViews
import ./traversal_partition.bend as Partition

Types

type Reason source · line 20 · raw

Data

type Problem source · line 27 · raw

Data

type Status source · line 30 · raw

Data

type Tensor source · line 38 · raw

@-Element:Data -> Type

Like a PyTorch tensor's device, workers is execution context: the size of the runtime's worker pool, read once with IO.thread_count and set with with_workers. Pure constructors cannot read it and use one worker. Results keep the largest worker count of their operands. It never changes a value.

type Parts source · line 44 · raw

@-Element:Data -> Type

A nonempty sequence of tensors. Base List is not used for tensors: the compiler shares every constructor of a list type that is duplicated anywhere, and that sharing would reach the certificate inside each tensor's storage.

type Gathered source · line 388 · raw

@-Element:Data -> Data

What every band of a gather shares: the operation, the banded view of the input geometry, the flags of the local view and the fill of fresh storage.

Definitions

def within source · line 49 · raw

@fits:Bool -> @count:U32 -> Maybe<&2, U32>

Element count of a shape that the default machine can allocate.

def allocatable source · line 54 · raw

@count:Maybe<&2, U32> -> Maybe<&2, U32>

def count_of source · line 59 · raw

@+shape:List<&2, U32> -> Maybe<&2, U32>

def known_count source · line 62 · raw

@count:Maybe<&2, U32> -> U32

def count_or_zero source · line 68 · raw

@+shape:List<&2, U32> -> U32

The element count as a number; a shape too large to allocate counts 0.

def view_of source · line 71 · raw

@+shape:List<&2, U32> -> Maybe<&2, 0xd6aaab858a4fbd1461bd0fee27b97184/tensor_view.View>

def significant_bits source · line 77 · raw

@remaining:Nat -> @+value:U32 -> @+bits:Nat -> @zero:Bool -> Nat

Bits of value, counted by tail recursion. Storage.bit_length is not tail recursive, and a non-tail recursive callee turns the calling chain into worklist dispatch: measured allocation of 2^20 floats took twice as long.

def depth_for source · line 81 · raw

@+count:U32 -> Nat

The smallest depth whose capacity holds count elements (at least one).

def usable source · line 130 · raw

@status:Status -> Bool

def mismatch source · line 168 · raw

@same:Bool -> @left:List<&2, U32> -> @right:List<&2, U32> -> Reason

def same_or_invalid source · line 173 · raw

@+left:List<&2, U32> -> @+right:List<&2, U32> -> Reason

def matches_count source · line 207 · raw

@count:Maybe<&2, U32> -> @length:Nat -> Bool

def first_failure source · line 294 · raw

@left:Status -> @right:Status -> Status

def stretched source · line 300 · raw

@view:Maybe<&2, 0xd6aaab858a4fbd1461bd0fee27b97184/tensor_view.View> -> @+target:List<&2, U32> -> Maybe<&2, 0xd6aaab858a4fbd1461bd0fee27b97184/tensor_view.View>

A view of an operand read with the extents target; see Views.stretch.

def indexed_width_positive source · line 596 · raw

@geometry:0xd6aaab858a4fbd1461bd0fee27b97184/tensor_band.Geometry -> Bool

def show_extents source · line 635 · raw

@extents:List<&2, U32> -> String

def show_shape source · line 641 · raw

@extents:List<&2, U32> -> String

def explain source · line 644 · raw

@reason:Reason -> String

def describe source · line 657 · raw

@problem:Problem -> String

Templates

template buffer source · line 84 · raw

@-Element:Data -> @+fill:Element -> @+count:U32 -> 0xd6aaab858a4fbd1461bd0fee27b97184/storage_buffer.Buffer<Element>

template whole source · line 89 · raw

@-Element:Data -> @storage:0xd6aaab858a4fbd1461bd0fee27b97184/storage_buffer.Buffer<Element> -> @+shape:List<&2, U32> -> @fill:Element -> @status:Status -> @workers:U32 -> Tensor<Element>

Row-major storage as a tensor: one band of one row whose width is every element of the shape.

template leaf_whole_storage source · line 94 · raw

@-Element:Data -> @whole:Bool -> @+geometry:0xd6aaab858a4fbd1461bd0fee27b97184/tensor_band.Geometry -> @+fill:Element -> @data:0xd6aaab858a4fbd1461bd0fee27b97184/storage_buffer.Buffer<Element> -> @first:U32 -> @rows:U32 -> 0xd6aaab858a4fbd1461bd0fee27b97184/storage_buffer.Buffer<Element>

The whole storage of bands. A leaf that holds the whole image already is it; other bands are gathered into one allocation.

template whole_storage source · line 99 · raw

@-Element:Data -> @+geometry:0xd6aaab858a4fbd1461bd0fee27b97184/tensor_band.Geometry -> @+fill:Element -> @bands:0xd6aaab858a4fbd1461bd0fee27b97184/tensor_band.Bands(Element) -> 0xd6aaab858a4fbd1461bd0fee27b97184/storage_buffer.Buffer<Element>

template arrive_when source · line 104 · raw

@-Element:Data -> @same:Bool -> @geometry:0xd6aaab858a4fbd1461bd0fee27b97184/tensor_band.Geometry -> @+fill:Element -> @layout:0xd6aaab858a4fbd1461bd0fee27b97184/tensor_band.Plan -> @other:0xd6aaab858a4fbd1461bd0fee27b97184/tensor_band.Geometry -> @bands:0xd6aaab858a4fbd1461bd0fee27b97184/tensor_band.Bands(Element) -> 0xd6aaab858a4fbd1461bd0fee27b97184/tensor_band.Bands(Element)

template arrive source · line 112 · raw

@-Element:Data -> @+geometry:0xd6aaab858a4fbd1461bd0fee27b97184/tensor_band.Geometry -> @layout:0xd6aaab858a4fbd1461bd0fee27b97184/tensor_band.Plan -> @tensor:Tensor<Element> -> 0xd6aaab858a4fbd1461bd0fee27b97184/tensor_band.Bands(Element)

The bands of a tensor in the layout an operation runs in. Bands of the same geometry are aligned to the plan. Bands of another geometry are read in row-major order and cut by the plan, which relabels a whole image as is.

template with_whole source · line 118 · raw

@-Element:Data -> @-Result:Type -> @tensor:Tensor<Element> -> @body:(@_:0xd6aaab858a4fbd1461bd0fee27b97184/storage_buffer.Buffer<Element> -> @_:List<&2, U32> -> @_:Element -> @_:Status -> @_:U32 -> Result) -> Result

The storage of a tensor arrived in the geometry of whole: the one leaf of its unsplit layout.

template with_metadata source · line 125 · raw

@-Element:Data -> @-Result:Type -> @tensor:Tensor<Element> -> @body:(@_:Tensor<Element> -> @_:List<&2, U32> -> @_:Element -> @_:Status -> @_:U32 -> Result) -> Result

Metadata inspection retains the original layout and affine storage.

template checked_band source · line 137 · raw

@-Element:Data -> @+first:U32 -> @+rows:U32 -> @result:Tensor<Element> -> 0xd6aaab858a4fbd1461bd0fee27b97184/tensor_band.Transformed(Element)

The band a checked call made, as whole storage. It counts as usable only when the call was usable.

template failed source · line 141 · raw

@-Element:Data -> @operation:String -> @reason:Reason -> @shape:List<&2, U32> -> @+fill:Element -> @workers:U32 -> Tensor<Element>

template transformed_accepted source · line 144 · raw

@-Element:Data -> @accepted:Bool -> @operation:String -> @reason:Reason -> @bands:0xd6aaab858a4fbd1461bd0fee27b97184/tensor_band.Bands(Element) -> @+geometry:0xd6aaab858a4fbd1461bd0fee27b97184/tensor_band.Geometry -> @+shape:List<&2, U32> -> @fill:Element -> @workers:U32 -> Tensor<Element>

template transformed_inspected source · line 150 · raw

@-Element:Data -> @usable:Bool -> @operation:String -> @reason:Reason -> @+geometry:0xd6aaab858a4fbd1461bd0fee27b97184/tensor_band.Geometry -> @+shape:List<&2, U32> -> @fill:Element -> @workers:U32 -> @inspected:Pair(0xd6aaab858a4fbd1461bd0fee27b97184/tensor_band.Bands(Element), 0xd6aaab858a4fbd1461bd0fee27b97184/tensor_band.Inspection) -> Tensor<Element>

template transformed source · line 157 · raw

@-Element:Data -> @operation:String -> @reason:Reason -> @+geometry:0xd6aaab858a4fbd1461bd0fee27b97184/tensor_band.Geometry -> @+shape:List<&2, U32> -> @fill:Element -> @workers:U32 -> @result:Pair(0xd6aaab858a4fbd1461bd0fee27b97184/tensor_band.Bands(Element), Bool) -> Tensor<Element>

Bands made by checked calls are the result when every call was usable and the bands cover the geometry; otherwise the operation fails for reason.

template rejected source · line 163 · raw

@-Element:Data -> @name:String -> @tensor:Tensor<Element> -> Tensor<Element>

A usable tensor fails with an invalid argument of the operation; a failed one keeps its problem.

template full_count source · line 178 · raw

@-Element:Data -> @+shape:List<&2, U32> -> @count:Maybe<&2, U32> -> @+value:Element -> Tensor<Element>

template full source · line 183 · raw

@-Element:Data -> @+shape:List<&2, U32> -> @+value:Element -> Tensor<Element>

template listed_count source · line 186 · raw

@-Element:Data -> @matches:Bool -> @+shape:List<&2, U32> -> @+count:U32 -> @values:List<&2, Element> -> @+fill:Element -> Tensor<Element>

template listed source · line 192 · raw

@-Element:Data -> @+shape:List<&2, U32> -> @count:Maybe<&2, U32> -> @+values:List<&2, Element> -> @+fill:Element -> Tensor<Element>

template from_list source · line 199 · raw

@-Element:Data -> @+shape:List<&2, U32> -> @+values:List<&2, Element> -> @+fill:Element -> Tensor<Element>

fill initializes storage this tensor or its results allocate; it is never observable in a successful result.

template stored source · line 202 · raw

@-Element:Data -> @matches:Bool -> @storage:0xd6aaab858a4fbd1461bd0fee27b97184/storage_buffer.Buffer<Element> -> @+shape:List<&2, U32> -> @fill:Element -> Tensor<Element>

template storage_of source · line 212 · raw

@-Element:Data -> @+shape:List<&2, U32> -> @count:Maybe<&2, U32> -> @storage:0xd6aaab858a4fbd1461bd0fee27b97184/storage_buffer.Buffer<Element> -> @fill:Element -> Tensor<Element>

template from_storage source · line 217 · raw

@-Element:Data -> @+shape:List<&2, U32> -> @storage:0xd6aaab858a4fbd1461bd0fee27b97184/storage_buffer.Buffer<Element> -> @+fill:Element -> Tensor<Element>

Storage handed over by foreign I/O keeps its documented trust boundary.

template with_workers source · line 223 · raw

@-Element:Data -> @tensor:Tensor<Element> -> @+count:U32 -> Tensor<Element>

Sets the worker count, at least one; values and status are unchanged.

template workers source · line 227 · raw

@-Element:Data -> @tensor:Tensor<Element> -> Pair(Tensor<Element>, U32)

template shape source · line 233 · raw

@-Element:Data -> @tensor:Tensor<Element> -> Pair(Tensor<Element>, List<&2, U32>)

template checked source · line 237 · raw

@-Element:Data -> @status:Status -> @bands:0xd6aaab858a4fbd1461bd0fee27b97184/tensor_band.Bands(Element) -> @geometry:0xd6aaab858a4fbd1461bd0fee27b97184/tensor_band.Geometry -> @shape:List<&2, U32> -> @fill:Element -> @workers:U32 -> Result<&1, &1, Pair(Tensor<Element>, Problem), Tensor<Element>>

template check source · line 243 · raw

@-Element:Data -> @tensor:Tensor<Element> -> Result<&1, &1, Pair(Tensor<Element>, Problem), Tensor<Element>>

template released source · line 247 · raw

@-Element:Data -> @status:Status -> @storage:0xd6aaab858a4fbd1461bd0fee27b97184/storage_buffer.Buffer<Element> -> Result<&2, &1, Problem, 0xd6aaab858a4fbd1461bd0fee27b97184/storage_buffer.Buffer<Element>>

template into_storage source · line 252 · raw

@-Element:Data -> @tensor:Tensor<Element> -> Result<&2, &1, Problem, 0xd6aaab858a4fbd1461bd0fee27b97184/storage_buffer.Buffer<Element>>

template listed_values source · line 255 · raw

@-Element:Data -> @status:Status -> @storage:Array<Element> -> @length:Nat -> Result<&2, &2, Problem, List<&2, Element>>

template listed_buffer source · line 260 · raw

@-Element:Data -> @status:Status -> @buffer:0xd6aaab858a4fbd1461bd0fee27b97184/storage_buffer.Buffer<Element> -> Result<&2, &2, Problem, List<&2, Element>>

template to_list source · line 264 · raw

@-Element:Data -> @tensor:Tensor<Element> -> Result<&2, &2, Problem, List<&2, Element>>

template only_value source · line 268 · raw

@-Element:Data -> @+shape:List<&2, U32> -> @values:List<&2, Element> -> Result<&2, &2, Problem, Element>

template single source · line 273 · raw

@-Element:Data -> @+shape:List<&2, U32> -> @values:Result<&2, &2, Problem, List<&2, Element>> -> Result<&2, &2, Problem, Element>

template item source · line 278 · raw

@-Element:Data -> @tensor:Tensor<Element> -> Result<&2, &2, Problem, Element>

template value_or source · line 284 · raw

@-Value:Data -> @result:Result<&2, &2, Problem, Value> -> @fallback:Value -> Value

The value read, or fallback when the tensor carries a failure.

template with_status source · line 305 · raw

@-Element:Data -> @status:Status -> @tensor:Tensor<Element> -> Tensor<Element>

template offered source · line 309 · raw

@-Element:Data -> @+geometry:0xd6aaab858a4fbd1461bd0fee27b97184/tensor_band.Geometry -> @shape:List<&2, U32> -> @fill:Element -> @status:Status -> @workers:U32 -> @owners:Pair(0xd6aaab858a4fbd1461bd0fee27b97184/tensor_band.Bands(Element), 0xd6aaab858a4fbd1461bd0fee27b97184/tensor_band.Plan) -> Pair(Tensor<Element>, 0xd6aaab858a4fbd1461bd0fee27b97184/tensor_band_schedule.Target)

template offer source · line 315 · raw

@-Element:Data -> @tensor:Tensor<Element> -> Pair(Tensor<Element>, 0xd6aaab858a4fbd1461bd0fee27b97184/tensor_band_schedule.Target)

The layout a tensor offers to an operation: its own geometry and plan.

template then source · line 321 · raw

@-First:Type -> @-Second:Type -> @-Result:Type -> @pair:Pair(First, Second) -> @body:(@_:First -> @_:Second -> Result) -> Result

Read-only operations return their tensor in a pair; Bend destructures only parameters, so a continuation receives both halves.

template combine_met_with source · line 327 · raw

@-Element:Data -> @-kernel:(@+count:Nat -> @+right_view:0xd6aaab858a4fbd1461bd0fee27b97184/tensor_view.View -> @+offset:U32 -> @_:0xd6aaab858a4fbd1461bd0fee27b97184/storage_buffer.Buffer<Element> -> @_:0xd6aaab858a4fbd1461bd0fee27b97184/storage_buffer.Buffer<Element> -> Pair(0xd6aaab858a4fbd1461bd0fee27b97184/storage_buffer.Buffer<Element>, 0xd6aaab858a4fbd1461bd0fee27b97184/storage_buffer.Buffer<Element>)) -> @operations:F32 -> @target:0xd6aaab858a4fbd1461bd0fee27b97184/tensor_band_schedule.Target -> @shape:List<&2, U32> -> @fill:Element -> @+workers:U32 -> @left:Tensor<Element> -> @right:Tensor<Element> -> Tensor<Element>

The two operands arrive in the layout they met in and one band kernel combines them.

template combine_offered_with source · line 333 · raw

@-Element:Data -> @-kernel:(@+count:Nat -> @+right_view:0xd6aaab858a4fbd1461bd0fee27b97184/tensor_view.View -> @+offset:U32 -> @_:0xd6aaab858a4fbd1461bd0fee27b97184/storage_buffer.Buffer<Element> -> @_:0xd6aaab858a4fbd1461bd0fee27b97184/storage_buffer.Buffer<Element> -> Pair(0xd6aaab858a4fbd1461bd0fee27b97184/storage_buffer.Buffer<Element>, 0xd6aaab858a4fbd1461bd0fee27b97184/storage_buffer.Buffer<Element>)) -> @operations:F32 -> @+workers:U32 -> @+shape:List<&2, U32> -> @+fill:Element -> @left:Tensor<Element> -> @right:Tensor<Element> -> Tensor<Element>

template combine_equal_with source · line 341 · raw

@-Element:Data -> @-kernel:(@+count:Nat -> @+right_view:0xd6aaab858a4fbd1461bd0fee27b97184/tensor_view.View -> @+offset:U32 -> @_:0xd6aaab858a4fbd1461bd0fee27b97184/storage_buffer.Buffer<Element> -> @_:0xd6aaab858a4fbd1461bd0fee27b97184/storage_buffer.Buffer<Element> -> Pair(0xd6aaab858a4fbd1461bd0fee27b97184/storage_buffer.Buffer<Element>, 0xd6aaab858a4fbd1461bd0fee27b97184/storage_buffer.Buffer<Element>)) -> @operations:F32 -> @status:Status -> @+workers:U32 -> @+shape:List<&2, U32> -> @left:0xd6aaab858a4fbd1461bd0fee27b97184/tensor_band.Bands(Element) -> @+geometry:0xd6aaab858a4fbd1461bd0fee27b97184/tensor_band.Geometry -> @+left_fill:Element -> @right:0xd6aaab858a4fbd1461bd0fee27b97184/tensor_band.Bands(Element) -> @+right_geometry:0xd6aaab858a4fbd1461bd0fee27b97184/tensor_band.Geometry -> @right_fill:Element -> Tensor<Element>

Usable operands of equal extents meet in one layout. A failed operand fails the call, which keeps the left bands, geometry, extents and fill.

template copied source · line 351 · raw

@-Element:Data -> @name:String -> @+source_shape:List<&2, U32> -> @+target_shape:List<&2, U32> -> @+fill:Element -> @+workers:U32 -> @result:0xd6aaab858a4fbd1461bd0fee27b97184/tensor_operations.Outcome<Pair(0xd6aaab858a4fbd1461bd0fee27b97184/storage_buffer.Buffer<Element>, 0xd6aaab858a4fbd1461bd0fee27b97184/storage_buffer.Buffer<Element>)> -> Pair(Tensor<Element>, Tensor<Element>)

A checked copy of the elements a view selects into a new whole tensor: (result, source).

template gather_views source · line 360 · raw

@-Element:Data -> @name:String -> @source_view:Maybe<&2, 0xd6aaab858a4fbd1461bd0fee27b97184/tensor_view.View> -> @+reversed:List<&2, Bool> -> @target_view:Maybe<&2, 0xd6aaab858a4fbd1461bd0fee27b97184/tensor_view.View> -> @count:Maybe<&2, U32> -> @input:0xd6aaab858a4fbd1461bd0fee27b97184/storage_buffer.Buffer<Element> -> @+source_shape:List<&2, U32> -> @+target_shape:List<&2, U32> -> @+fill:Element -> @+workers:U32 -> Pair(Tensor<Element>, Tensor<Element>)

template gather_status source · line 372 · raw

@-Element:Data -> @name:String -> @status:Status -> @source_view:Maybe<&2, 0xd6aaab858a4fbd1461bd0fee27b97184/tensor_view.View> -> @+reversed:List<&2, Bool> -> @+view_shape:List<&2, U32> -> @+target_shape:List<&2, U32> -> @input:0xd6aaab858a4fbd1461bd0fee27b97184/storage_buffer.Buffer<Element> -> @+source_shape:List<&2, U32> -> @+fill:Element -> @+workers:U32 -> Pair(Tensor<Element>, Tensor<Element>)

Copy the elements selected by source_view, in its row-major order with the flagged axes in reverse, into a new tensor whose storage is laid out as view_shape and labelled target_shape.

template result_of source · line 382 · raw

@-Element:Data -> @pair:Pair(Tensor<Element>, Tensor<Element>) -> Tensor<Element>

template gathered_rows source · line 394 · raw

@-Element:Data -> @empty:Bool -> @name:String -> @+banded:0xd6aaab858a4fbd1461bd0fee27b97184/tensor_band_view.Banded -> @+batch:U32 -> @+channels:U32 -> @+height:U32 -> @+width:U32 -> @+reversed:List<&2, Bool> -> @+fill:Element -> @+first:U32 -> @+rows:U32 -> @input:0xd6aaab858a4fbd1461bd0fee27b97184/storage_buffer.Buffer<Element> -> 0xd6aaab858a4fbd1461bd0fee27b97184/tensor_band.Transformed(Element)

A band gathers the cells its local view selects into the output band of the same rows, each row repeated as the view repeats it. A band of no rows has no cells to read.

template gathered_band source · line 407 · raw

@-Element:Data -> @context:Gathered<Element> -> @first:U32 -> @rows:U32 -> @input:0xd6aaab858a4fbd1461bd0fee27b97184/storage_buffer.Buffer<Element> -> 0xd6aaab858a4fbd1461bd0fee27b97184/tensor_band.Transformed(Element)

template gather_banded source · line 413 · raw

@-Element:Data -> @+name:String -> @+banded:0xd6aaab858a4fbd1461bd0fee27b97184/tensor_band_view.Banded -> @+geometry:0xd6aaab858a4fbd1461bd0fee27b97184/tensor_band.Geometry -> @+reversed:List<&2, Bool> -> @+shape:List<&2, U32> -> @+target:List<&2, U32> -> @+fill:Element -> @+workers:U32 -> @bands:0xd6aaab858a4fbd1461bd0fee27b97184/tensor_band.Bands(Element) -> Tensor<Element>

template gather_whole_local source · line 418 · raw

@-Element:Data -> @+name:String -> @+banded:0xd6aaab858a4fbd1461bd0fee27b97184/tensor_band_view.Banded -> @local:Maybe<&2, List<&2, Bool>> -> @+whole:0xd6aaab858a4fbd1461bd0fee27b97184/tensor_band.Geometry -> @+shape:List<&2, U32> -> @+target:List<&2, U32> -> @+fill:Element -> @+workers:U32 -> @tensor:Tensor<Element> -> Tensor<Element>

template gather_whole source · line 424 · raw

@-Element:Data -> @+name:String -> @found:Maybe<&2, 0xd6aaab858a4fbd1461bd0fee27b97184/tensor_band_view.Banded> -> @+reversed:List<&2, Bool> -> @+whole:0xd6aaab858a4fbd1461bd0fee27b97184/tensor_band.Geometry -> @+shape:List<&2, U32> -> @+target:List<&2, U32> -> @+fill:Element -> @+workers:U32 -> @tensor:Tensor<Element> -> Tensor<Element>

template gather_arrived source · line 431 · raw

@-Element:Data -> @+name:String -> @+reversed:List<&2, Bool> -> @+axes:List<&2, 0xd6aaab858a4fbd1461bd0fee27b97184/tensor_view.Axis> -> @+offset:U32 -> @bands:0xd6aaab858a4fbd1461bd0fee27b97184/tensor_band.Bands(Element) -> @+geometry:0xd6aaab858a4fbd1461bd0fee27b97184/tensor_band.Geometry -> @+shape:List<&2, U32> -> @+target:List<&2, U32> -> @+fill:Element -> @+workers:U32 -> Tensor<Element>

Other bands first arrive as the one band of one row of the whole geometry.

template gather_local source · line 436 · raw

@-Element:Data -> @+name:String -> @+banded:0xd6aaab858a4fbd1461bd0fee27b97184/tensor_band_view.Banded -> @local:Maybe<&2, List<&2, Bool>> -> @+reversed:List<&2, Bool> -> @+axes:List<&2, 0xd6aaab858a4fbd1461bd0fee27b97184/tensor_view.Axis> -> @+offset:U32 -> @bands:0xd6aaab858a4fbd1461bd0fee27b97184/tensor_band.Bands(Element) -> @+geometry:0xd6aaab858a4fbd1461bd0fee27b97184/tensor_band.Geometry -> @+shape:List<&2, U32> -> @+target:List<&2, U32> -> @+fill:Element -> @+workers:U32 -> Tensor<Element>

template gather_found source · line 444 · raw

@-Element:Data -> @+name:String -> @found:Maybe<&2, 0xd6aaab858a4fbd1461bd0fee27b97184/tensor_band_view.Banded> -> @+reversed:List<&2, Bool> -> @+axes:List<&2, 0xd6aaab858a4fbd1461bd0fee27b97184/tensor_view.Axis> -> @+offset:U32 -> @bands:0xd6aaab858a4fbd1461bd0fee27b97184/tensor_band.Bands(Element) -> @+geometry:0xd6aaab858a4fbd1461bd0fee27b97184/tensor_band.Geometry -> @+shape:List<&2, U32> -> @+target:List<&2, U32> -> @+fill:Element -> @+workers:U32 -> Tensor<Element>

Bands whose images and rows the view keeps in place and reads forward gather their own cells; other bands first arrive as one band.

template gather_counted source · line 451 · raw

@-Element:Data -> @+name:String -> @empty:Bool -> @+axes:List<&2, 0xd6aaab858a4fbd1461bd0fee27b97184/tensor_view.Axis> -> @+offset:U32 -> @+reversed:List<&2, Bool> -> @bands:0xd6aaab858a4fbd1461bd0fee27b97184/tensor_band.Bands(Element) -> @+geometry:0xd6aaab858a4fbd1461bd0fee27b97184/tensor_band.Geometry -> @+shape:List<&2, U32> -> @+target:List<&2, U32> -> @+fill:Element -> @+workers:U32 -> Tensor<Element>

template gather_axes source · line 459 · raw

@-Element:Data -> @+name:String -> @count:Maybe<&2, U32> -> @+axes:List<&2, 0xd6aaab858a4fbd1461bd0fee27b97184/tensor_view.Axis> -> @+offset:U32 -> @+reversed:List<&2, Bool> -> @bands:0xd6aaab858a4fbd1461bd0fee27b97184/tensor_band.Bands(Element) -> @+geometry:0xd6aaab858a4fbd1461bd0fee27b97184/tensor_band.Geometry -> @+shape:List<&2, U32> -> @+target:List<&2, U32> -> @+fill:Element -> @+workers:U32 -> Tensor<Element>

The result must have a count. The view comes taken apart, so that no View value is used twice: that would make every View constructor shared.

template gather source · line 468 · raw

@-Element:Data -> @name:String -> @status:Status -> @source:Maybe<&2, 0xd6aaab858a4fbd1461bd0fee27b97184/tensor_view.View> -> @+reversed:List<&2, Bool> -> @bands:0xd6aaab858a4fbd1461bd0fee27b97184/tensor_band.Bands(Element) -> @+geometry:0xd6aaab858a4fbd1461bd0fee27b97184/tensor_band.Geometry -> @+shape:List<&2, U32> -> @+target:List<&2, U32> -> @+fill:Element -> @+workers:U32 -> Tensor<Element>

The elements a view of the tensor's row-major elements selects, in the view's row-major order with the flagged axes in reverse, as a tensor of extents target. An axis without a flag is read forward.

template gather_extents source · line 476 · raw

@-Element:Data -> @name:String -> @status:Status -> @source:Maybe<&2, 0xd6aaab858a4fbd1461bd0fee27b97184/tensor_view.View> -> @+reversed:List<&2, Bool> -> @bands:0xd6aaab858a4fbd1461bd0fee27b97184/tensor_band.Bands(Element) -> @+geometry:0xd6aaab858a4fbd1461bd0fee27b97184/tensor_band.Geometry -> @+shape:List<&2, U32> -> @+fill:Element -> @+workers:U32 -> Tensor<Element>

The same gather labelled with the extents of the view.

template broadcast_view source · line 484 · raw

@-Element:Data -> @status:Status -> @view:Maybe<&2, 0xd6aaab858a4fbd1461bd0fee27b97184/tensor_view.View> -> @bands:0xd6aaab858a4fbd1461bd0fee27b97184/tensor_band.Bands(Element) -> @+geometry:0xd6aaab858a4fbd1461bd0fee27b97184/tensor_band.Geometry -> @+shape:List<&2, U32> -> @+target:List<&2, U32> -> @+fill:Element -> @+workers:U32 -> Tensor<Element>

The tensor repeated to the extents target under NumPy broadcasting: one gather through the stretched view.

template broadcast_to source · line 490 · raw

@-Element:Data -> @tensor:Tensor<Element> -> @+target:List<&2, U32> -> Tensor<Element>

template combine_spread_when source · line 497 · raw

@-Element:Data -> @-kernel:(@+count:Nat -> @+right_view:0xd6aaab858a4fbd1461bd0fee27b97184/tensor_view.View -> @+offset:U32 -> @_:0xd6aaab858a4fbd1461bd0fee27b97184/storage_buffer.Buffer<Element> -> @_:0xd6aaab858a4fbd1461bd0fee27b97184/storage_buffer.Buffer<Element> -> Pair(0xd6aaab858a4fbd1461bd0fee27b97184/storage_buffer.Buffer<Element>, 0xd6aaab858a4fbd1461bd0fee27b97184/storage_buffer.Buffer<Element>)) -> @operations:F32 -> @boxed:Bool -> @+shape:List<&2, U32> -> @+workers:U32 -> @+geometry:0xd6aaab858a4fbd1461bd0fee27b97184/tensor_band.Geometry -> @+layout:0xd6aaab858a4fbd1461bd0fee27b97184/tensor_band.Plan -> @left:0xd6aaab858a4fbd1461bd0fee27b97184/tensor_band.Bands(Element) -> @+fill:Element -> @source:0xd6aaab858a4fbd1461bd0fee27b97184/storage_buffer.Buffer<Element> -> @+right_shape:List<&2, U32> -> @right_fill:Element -> Tensor<Element>

Each band of the left takes the part of the right source it reads through the stretched view. A layout whose bands have no view of their cells reads the right repeated to the common extents.

template combine_viewed_with source · line 508 · raw

@-Element:Data -> @-kernel:(@+count:Nat -> @+right_view:0xd6aaab858a4fbd1461bd0fee27b97184/tensor_view.View -> @+offset:U32 -> @_:0xd6aaab858a4fbd1461bd0fee27b97184/storage_buffer.Buffer<Element> -> @_:0xd6aaab858a4fbd1461bd0fee27b97184/storage_buffer.Buffer<Element> -> Pair(0xd6aaab858a4fbd1461bd0fee27b97184/storage_buffer.Buffer<Element>, 0xd6aaab858a4fbd1461bd0fee27b97184/storage_buffer.Buffer<Element>)) -> @operations:F32 -> @+shape:List<&2, U32> -> @+workers:U32 -> @+geometry:0xd6aaab858a4fbd1461bd0fee27b97184/tensor_band.Geometry -> @+fill:Element -> @planned:Pair(0xd6aaab858a4fbd1461bd0fee27b97184/tensor_band.Bands(Element), 0xd6aaab858a4fbd1461bd0fee27b97184/tensor_band.Plan) -> @source:0xd6aaab858a4fbd1461bd0fee27b97184/storage_buffer.Buffer<Element> -> @+right_shape:List<&2, U32> -> @right_fill:Element -> Tensor<Element>

template combine_stretched_with source · line 517 · raw

@-Element:Data -> @-kernel:(@+count:Nat -> @+right_view:0xd6aaab858a4fbd1461bd0fee27b97184/tensor_view.View -> @+offset:U32 -> @_:0xd6aaab858a4fbd1461bd0fee27b97184/storage_buffer.Buffer<Element> -> @_:0xd6aaab858a4fbd1461bd0fee27b97184/storage_buffer.Buffer<Element> -> Pair(0xd6aaab858a4fbd1461bd0fee27b97184/storage_buffer.Buffer<Element>, 0xd6aaab858a4fbd1461bd0fee27b97184/storage_buffer.Buffer<Element>)) -> @operations:F32 -> @+shape:List<&2, U32> -> @+workers:U32 -> @left:Tensor<Element> -> @right:Tensor<Element> -> Tensor<Element>

A left operand of the common extents keeps its layout; the right operand is read through its view stretched to those extents.

template combine_repeated_when source · line 524 · raw

@-Element:Data -> @-kernel:(@+count:Nat -> @+right_view:0xd6aaab858a4fbd1461bd0fee27b97184/tensor_view.View -> @+offset:U32 -> @_:0xd6aaab858a4fbd1461bd0fee27b97184/storage_buffer.Buffer<Element> -> @_:0xd6aaab858a4fbd1461bd0fee27b97184/storage_buffer.Buffer<Element> -> Pair(0xd6aaab858a4fbd1461bd0fee27b97184/storage_buffer.Buffer<Element>, 0xd6aaab858a4fbd1461bd0fee27b97184/storage_buffer.Buffer<Element>)) -> @operations:F32 -> @same:Bool -> @+shape:List<&2, U32> -> @+workers:U32 -> @+fill:Element -> @left:Tensor<Element> -> @right:Tensor<Element> -> Tensor<Element>

template combine_repeated_with source · line 532 · raw

@-Element:Data -> @-kernel:(@+count:Nat -> @+right_view:0xd6aaab858a4fbd1461bd0fee27b97184/tensor_view.View -> @+offset:U32 -> @_:0xd6aaab858a4fbd1461bd0fee27b97184/storage_buffer.Buffer<Element> -> @_:0xd6aaab858a4fbd1461bd0fee27b97184/storage_buffer.Buffer<Element> -> Pair(0xd6aaab858a4fbd1461bd0fee27b97184/storage_buffer.Buffer<Element>, 0xd6aaab858a4fbd1461bd0fee27b97184/storage_buffer.Buffer<Element>)) -> @operations:F32 -> @+shape:List<&2, U32> -> @+workers:U32 -> @+fill:Element -> @left:Tensor<Element> -> @right:Tensor<Element> -> Tensor<Element>

A repeated left operand meets a right operand of the common extents as an operand of equal extents.

template combine_common_with source · line 539 · raw

@-Element:Data -> @-kernel:(@+count:Nat -> @+right_view:0xd6aaab858a4fbd1461bd0fee27b97184/tensor_view.View -> @+offset:U32 -> @_:0xd6aaab858a4fbd1461bd0fee27b97184/storage_buffer.Buffer<Element> -> @_:0xd6aaab858a4fbd1461bd0fee27b97184/storage_buffer.Buffer<Element> -> Pair(0xd6aaab858a4fbd1461bd0fee27b97184/storage_buffer.Buffer<Element>, 0xd6aaab858a4fbd1461bd0fee27b97184/storage_buffer.Buffer<Element>)) -> @name:String -> @operations:F32 -> @same:Bool -> @count:Maybe<&2, U32> -> @+shape:List<&2, U32> -> @+workers:U32 -> @+fill:Element -> @left:Tensor<Element> -> @right:Tensor<Element> -> Tensor<Element>

A left operand of other extents is first repeated to the common extents.

template combine_broadcast_with source · line 548 · raw

@-Element:Data -> @-kernel:(@+count:Nat -> @+right_view:0xd6aaab858a4fbd1461bd0fee27b97184/tensor_view.View -> @+offset:U32 -> @_:0xd6aaab858a4fbd1461bd0fee27b97184/storage_buffer.Buffer<Element> -> @_:0xd6aaab858a4fbd1461bd0fee27b97184/storage_buffer.Buffer<Element> -> Pair(0xd6aaab858a4fbd1461bd0fee27b97184/storage_buffer.Buffer<Element>, 0xd6aaab858a4fbd1461bd0fee27b97184/storage_buffer.Buffer<Element>)) -> @name:String -> @operations:F32 -> @status:Status -> @common:Maybe<&2, List<&2, U32>> -> @+workers:U32 -> @left:0xd6aaab858a4fbd1461bd0fee27b97184/tensor_band.Bands(Element) -> @+geometry:0xd6aaab858a4fbd1461bd0fee27b97184/tensor_band.Geometry -> @+left_shape:List<&2, U32> -> @+left_fill:Element -> @right:0xd6aaab858a4fbd1461bd0fee27b97184/tensor_band.Bands(Element) -> @+right_geometry:0xd6aaab858a4fbd1461bd0fee27b97184/tensor_band.Geometry -> @+right_shape:List<&2, U32> -> @right_fill:Element -> Tensor<Element>

Operands of other extents follow NumPy broadcasting (Shapes.broadcast) and fail only when they are incompatible.

template combine_shapes source · line 560 · raw

@-Element:Data -> @-kernel:(@+count:Nat -> @+right_view:0xd6aaab858a4fbd1461bd0fee27b97184/tensor_view.View -> @+offset:U32 -> @_:0xd6aaab858a4fbd1461bd0fee27b97184/storage_buffer.Buffer<Element> -> @_:0xd6aaab858a4fbd1461bd0fee27b97184/storage_buffer.Buffer<Element> -> Pair(0xd6aaab858a4fbd1461bd0fee27b97184/storage_buffer.Buffer<Element>, 0xd6aaab858a4fbd1461bd0fee27b97184/storage_buffer.Buffer<Element>)) -> @name:String -> @operations:F32 -> @same:Bool -> @left:0xd6aaab858a4fbd1461bd0fee27b97184/tensor_band.Bands(Element) -> @+geometry:0xd6aaab858a4fbd1461bd0fee27b97184/tensor_band.Geometry -> @+left_shape:List<&2, U32> -> @+left_fill:Element -> @left_status:Status -> @left_workers:U32 -> @right:0xd6aaab858a4fbd1461bd0fee27b97184/tensor_band.Bands(Element) -> @+right_geometry:0xd6aaab858a4fbd1461bd0fee27b97184/tensor_band.Geometry -> @+right_shape:List<&2, U32> -> @right_fill:Element -> @right_status:Status -> @right_workers:U32 -> Tensor<Element>

Operands of equal extents run in the layout they meet in; operands of other extents broadcast.

template combine_with source · line 573 · raw

@-Element:Data -> @-kernel:(@+count:Nat -> @+right_view:0xd6aaab858a4fbd1461bd0fee27b97184/tensor_view.View -> @+offset:U32 -> @_:0xd6aaab858a4fbd1461bd0fee27b97184/storage_buffer.Buffer<Element> -> @_:0xd6aaab858a4fbd1461bd0fee27b97184/storage_buffer.Buffer<Element> -> Pair(0xd6aaab858a4fbd1461bd0fee27b97184/storage_buffer.Buffer<Element>, 0xd6aaab858a4fbd1461bd0fee27b97184/storage_buffer.Buffer<Element>)) -> @name:String -> @operations:F32 -> @left:Tensor<Element> -> @right:Tensor<Element> -> Tensor<Element>

operation(left element, right element), retaining the band layout of the operands. Alignment is done once, before any parallel leaf work. operations counts the operation's scalar work for the band schedule.

template combine source · line 580 · raw

@-Element:Data -> @-operation:(@_:Element -> @_:Element -> Element) -> @name:String -> @operations:F32 -> @left:Tensor<Element> -> @right:Tensor<Element> -> Tensor<Element>

The elementwise form: the kernel applies operation to each pair in order.

template apply_bands_context source · line 583 · raw

@-Element:Data -> @-Context:Data -> @-mapper:(@+count:Nat -> @+position:U32 -> @+context:Context -> @_:0xd6aaab858a4fbd1461bd0fee27b97184/storage_buffer.Buffer<Element> -> 0xd6aaab858a4fbd1461bd0fee27b97184/storage_buffer.Buffer<Element>) -> @context:Context -> @operations:F32 -> @status:Status -> @bands:0xd6aaab858a4fbd1461bd0fee27b97184/tensor_band.Bands(Element) -> @+geometry:0xd6aaab858a4fbd1461bd0fee27b97184/tensor_band.Geometry -> @shape:List<&2, U32> -> @fill:Element -> @+workers:U32 -> Tensor<Element>

template apply_context source · line 589 · raw

@-Element:Data -> @-Context:Data -> @-mapper:(@+count:Nat -> @+position:U32 -> @+context:Context -> @_:0xd6aaab858a4fbd1461bd0fee27b97184/storage_buffer.Buffer<Element> -> 0xd6aaab858a4fbd1461bd0fee27b97184/storage_buffer.Buffer<Element>) -> @context:Context -> @operations:F32 -> @tensor:Tensor<Element> -> Tensor<Element>

template apply source · line 593 · raw

@-Element:Data -> @-mapper:(@+count:Nat -> @+position:U32 -> @_:0xd6aaab858a4fbd1461bd0fee27b97184/storage_buffer.Buffer<Element> -> 0xd6aaab858a4fbd1461bd0fee27b97184/storage_buffer.Buffer<Element>) -> @operations:F32 -> @tensor:Tensor<Element> -> Tensor<Element>

template apply_indexed_positive source · line 602 · raw

@-Element:Data -> @-operation:(@_:U32 -> @_:Element -> Element) -> @positive:Bool -> @operations:F32 -> @bands:0xd6aaab858a4fbd1461bd0fee27b97184/tensor_band.Bands(Element) -> @+geometry:0xd6aaab858a4fbd1461bd0fee27b97184/tensor_band.Geometry -> @+shape:List<&2, U32> -> @+fill:Element -> @+workers:U32 -> Tensor<Element>

An empty width holds no element, so the bands stay as they are. The choice is made once, before the band scheduler or element loop.

template apply_indexed_bands source · line 608 · raw

@-Element:Data -> @-operation:(@_:U32 -> @_:Element -> Element) -> @operations:F32 -> @status:Status -> @bands:0xd6aaab858a4fbd1461bd0fee27b97184/tensor_band.Bands(Element) -> @+geometry:0xd6aaab858a4fbd1461bd0fee27b97184/tensor_band.Geometry -> @shape:List<&2, U32> -> @+fill:Element -> @+workers:U32 -> Tensor<Element>

template apply_indexed source · line 615 · raw

@-Element:Data -> @-operation:(@_:U32 -> @_:Element -> Element) -> @operations:F32 -> @tensor:Tensor<Element> -> Tensor<Element>

The function also receives each element's row-major index.

template same source · line 619 · raw

@-Element:Data -> @value:Element -> Element

template scalar_bands source · line 623 · raw

@-Element:Data -> @-operation:(@_:Element -> @_:Element -> Element) -> @operations:F32 -> @status:Status -> @bands:0xd6aaab858a4fbd1461bd0fee27b97184/tensor_band.Bands(Element) -> @+geometry:0xd6aaab858a4fbd1461bd0fee27b97184/tensor_band.Geometry -> @shape:List<&2, U32> -> @fill:Element -> @+workers:U32 -> @value:Element -> Tensor<Element>

Updates every element x to operation(x, value).

template combine_scalar source · line 629 · raw

@-Element:Data -> @-operation:(@_:Element -> @_:Element -> Element) -> @operations:F32 -> @tensor:Tensor<Element> -> @value:Element -> Tensor<Element>

template expected source · line 661 · raw

@-Element:Data -> @result:Result<&1, &1, Pair(Tensor<Element>, Problem), Tensor<Element>> -> IO(Tensor<Element>)

template expect source · line 667 · raw

@-Element:Data -> @tensor:Tensor<Element> -> IO(Tensor<Element>)

Stops the program with the recorded problem, for scripts and examples.

template expected_storage source · line 670 · raw

@-Element:Data -> @result:Result<&2, &1, Problem, 0xd6aaab858a4fbd1461bd0fee27b97184/storage_buffer.Buffer<Element>> -> IO(0xd6aaab858a4fbd1461bd0fee27b97184/storage_buffer.Buffer<Element>)

template expect_storage source · line 675 · raw

@-Element:Data -> @tensor:Tensor<Element> -> IO(0xd6aaab858a4fbd1461bd0fee27b97184/storage_buffer.Buffer<Element>)