~/bend-docscommunity

tensor_band_window.bend checks

raw source on the hub · import stelliferous@0.0.2.0/tensor_band_window.bend as Tensor_band_window

Window geometry is independent of convolution arithmetic. Each output row belongs to one existing core band; neighbours contribute only halo rows.

4 imports
import Base
import ./tensor_band.bend as Bands
import ./storage_buffer.bend as Storage
import ./traversal_partition.bend as Partition

Types

type Geometry source · line 8 · raw

Data

type Rows source · line 11 · raw

Data

type RowWindow source · line 17 · raw

Data

A leaf's output rows, its halo rows above and below the core, and the image rows its window holds: from the stride-aligned first row its outputs read to the last, so the window packs as a shorter image.

type Halo source · line 61 · raw

@-Element:Data -> Type

Definitions

def ceiling source · line 20 · raw

@+value:U32 -> @+stride:U32 -> U32

def subtract_clipped source · line 23 · raw

@+value:U32 -> @+amount:U32 -> U32

def clipped source · line 26 · raw

@+first:U32 -> @+end:U32 -> Rows

def nonempty source · line 29 · raw

@active:Bool -> @window:RowWindow -> RowWindow

def start source · line 37 · raw

@+height:U32 -> @+output_first:U32 -> @+stride:U32 -> @+padding:U32 -> U32

The first row a window holds: the first row its outputs read, moved down to a stride multiple.

def window source · line 45 · raw

@geometry:Geometry -> @+first:U32 -> @+count:U32 -> RowWindow

Output partition boundaries follow the input cores, with the first and last cores also owning any output rows introduced by padding. The halos hold every window row outside the core, so a window is its image rows exactly. Caller geometry checks establish positive stride/height and bounded products.

def input_geometry source · line 109 · raw

@geometry:Geometry -> 0x9be3b13bf249759bc81e1958bcd1a4c0/tensor_band.Geometry

Templates

template Halos source · line 64 · raw

@-Element:Data -> Type

template extract source · line 67 · raw

@-Element:Data -> @+geometry:0x9be3b13bf249759bc81e1958bcd1a4c0/tensor_band.Geometry -> @fill:Element -> @range:Rows -> @bands:0x9be3b13bf249759bc81e1958bcd1a4c0/tensor_band.Bands(Element) -> Pair(0x9be3b13bf249759bc81e1958bcd1a4c0/tensor_band.Bands(Element), 0x9be3b13bf249759bc81e1958bcd1a4c0/storage_buffer.Buffer<Element>)

template halo source · line 71 · raw

@-Element:Data -> @+geometry:0x9be3b13bf249759bc81e1958bcd1a4c0/tensor_band.Geometry -> @+fill:Element -> @+first:U32 -> @+count:U32 -> @window:RowWindow -> @bands:0x9be3b13bf249759bc81e1958bcd1a4c0/tensor_band.Bands(Element) -> Pair(0x9be3b13bf249759bc81e1958bcd1a4c0/tensor_band.Bands(Element), Halos(Element))

template copied_window source · line 79 · raw

@-Element:Data -> @owners:Pair(0x9be3b13bf249759bc81e1958bcd1a4c0/tensor_band.Bands(Element), 0x9be3b13bf249759bc81e1958bcd1a4c0/storage_buffer.Buffer<Element>) -> 0x9be3b13bf249759bc81e1958bcd1a4c0/storage_buffer.Buffer<Element>

template assembled source · line 88 · raw

@-Element:Data -> @exact:Bool -> @+fill:Element -> @+geometry:0x9be3b13bf249759bc81e1958bcd1a4c0/tensor_band.Geometry -> @+window:Rows -> @+core:Rows -> @+above:Rows -> @+below:Rows -> @core_buffer:0x9be3b13bf249759bc81e1958bcd1a4c0/storage_buffer.Buffer<Element> -> @above_buffer:0x9be3b13bf249759bc81e1958bcd1a4c0/storage_buffer.Buffer<Element> -> @below_buffer:0x9be3b13bf249759bc81e1958bcd1a4c0/storage_buffer.Buffer<Element> -> 0x9be3b13bf249759bc81e1958bcd1a4c0/storage_buffer.Buffer<Element>

The window rows of every channel, stored contiguously. A window equal to the core (for example a 1x1 stride-1 operation) is the core itself; any other window is the shared range copy of its rows from the upper halo, the core and the lower halo, one contiguous range per channel per source. The three copies are direct calls: a leaf task must not reach a closure.

template assemble source · line 102 · raw

@-Element:Data -> @+fill:Element -> @+geometry:0x9be3b13bf249759bc81e1958bcd1a4c0/tensor_band.Geometry -> @+window:Rows -> @+core:Rows -> @+above:Rows -> @+below:Rows -> @core_buffer:0x9be3b13bf249759bc81e1958bcd1a4c0/storage_buffer.Buffer<Element> -> @above_buffer:0x9be3b13bf249759bc81e1958bcd1a4c0/storage_buffer.Buffer<Element> -> @below_buffer:0x9be3b13bf249759bc81e1958bcd1a4c0/storage_buffer.Buffer<Element> -> 0x9be3b13bf249759bc81e1958bcd1a4c0/storage_buffer.Buffer<Element>

template prepare source · line 116 · raw

@-Element:Data -> @+geometry:Geometry -> @+fill:Element -> @layout:0x9be3b13bf249759bc81e1958bcd1a4c0/tensor_band.Plan -> @bands:0x9be3b13bf249759bc81e1958bcd1a4c0/tensor_band.Bands(Element) -> Pair(0x9be3b13bf249759bc81e1958bcd1a4c0/tensor_band.Bands(Element), Halos(Element))

The full core tree is threaded through the preparation pass without cloning. Each allocation is a requested neighbour range, never a core-sized window. The resulting halo tree follows the same layout, ready to pair with cores.

template window_band source · line 125 · raw

@-Element:Data -> @-Context:Data -> @-leaf:(@_:Context -> @_:U32 -> @_:U32 -> @_:0x9be3b13bf249759bc81e1958bcd1a4c0/storage_buffer.Buffer<Element> -> @_:Halo<Element> -> 0x9be3b13bf249759bc81e1958bcd1a4c0/tensor_band.Bands(Element)) -> @context:Context -> @first:U32 -> @rows:U32 -> @input:0x9be3b13bf249759bc81e1958bcd1a4c0/storage_buffer.Buffer<Element> -> @halo:Halo<Element> -> @resource:Unit -> 0x9be3b13bf249759bc81e1958bcd1a4c0/tensor_band.Bands(Element)

template apply source · line 131 · raw

@-Element:Data -> @-Context:Data -> @-leaf:(@_:Context -> @_:U32 -> @_:U32 -> @_:0x9be3b13bf249759bc81e1958bcd1a4c0/storage_buffer.Buffer<Element> -> @_:Halo<Element> -> 0x9be3b13bf249759bc81e1958bcd1a4c0/tensor_band.Bands(Element)) -> @layout:0x9be3b13bf249759bc81e1958bcd1a4c0/tensor_band.Plan -> @mode:Bool -> @enabled:Bool -> @geometry:0x9be3b13bf249759bc81e1958bcd1a4c0/tensor_band.Geometry -> @context:Context -> @bands:0x9be3b13bf249759bc81e1958bcd1a4c0/tensor_band.Bands(Element) -> @halos:Halos(Element) -> 0x9be3b13bf249759bc81e1958bcd1a4c0/tensor_band.Bands(Element)

Every core leaf with its halo, through the shared band recursion. Trees of another shape keep the cores.