kernel_window.bend checks
raw source on the hub · import stelliferous@0.0.2.0/kernel_window.bend as Kernel_window
Input rows a spatial range reads. A window stores rows [first, first + rows) of every channel contiguously. The first row is a stride multiple, so packing a window is packing a shorter image with output rows shifted by first / stride.
2 imports
import Base import ./traversal_array.bend as Traversal
Types
type Band source · line 7 · raw
Data
Band@first:U32 -> @rows:U32 -> Band
Definitions
def first_row source · line 10 · raw
@+stride:U32 -> @+padding:U32 -> @+output_row:U32 -> U32
def end_row source · line 14 · raw
@+height:U32 -> @+kernel:U32 -> @+stride:U32 -> @+padding:U32 -> @+output_row:U32 -> U32
def band source · line 21 · raw
@+parent_first:U32 -> @+parent_rows:U32 -> @+height:U32 -> @+kernel:U32 -> @+stride:U32 -> @+padding:U32 -> @+output_width:U32 -> @+offset:U32 -> @+span:U32 -> Band
Rows read by output positions [offset, offset + span), kept inside the parent window [parent_first, parent_first + parent_rows). A band has at least one row, and its first row stays a stride multiple.
def covers source · line 34 · raw
@+parent_first:U32 -> @+parent_rows:U32 -> @+height:U32 -> @+kernel:U32 -> @+stride:U32 -> @+padding:U32 -> @+output_width:U32 -> @+offset:U32 -> @+span:U32 -> @+band:Band -> Bool
The checked facts that let a band stand in for its parent over a nonempty span: rows inside the parent window, a stride-aligned first row that no read needs above, an end no read needs below (or the image end), and room for the kernel. The comparisons avoid wrapped sums: rows are bounded by the parent end minus the first row. Pipelines copy only a band that passes; any other split keeps a clone of the parent.
def copies_band source · line 49 · raw
@+parent_first:U32 -> @+parent_rows:U32 -> @+height:U32 -> @+kernel:U32 -> @+stride:U32 -> @+padding:U32 -> @+output_width:U32 -> @+offset:U32 -> @+span:U32 -> @+band:Band -> Bool
A fork copies the left child's band only when rows are whole eight-position blocks and the band passes its coverage check; otherwise it clones the parent.
def padded source · line 54 · raw
@positions:U32 -> U32
Output positions rounded up to whole eight-position blocks.
def start source · line 59 · raw
@+offset:U32 -> @+stride:U32 -> @+output_width:U32 -> @+first:U32 -> U32
Packing start of a window: output rows before its first row move the start back by first / stride rows. A window that starts at row 0 keeps the offset.
def copy_planes source · line 64 · raw
@remaining:Nat -> @+channel:U32 -> @+count:U32 -> @+source_stride:U32 -> @+source_start:U32 -> @+target_stride:U32 -> @owners:Pair(Array<F32>, Array<F32>) -> Pair(Array<F32>, Array<F32>)
Channel c copies count values from c * source_stride + source_start to c * target_stride. Each plane is one contiguous copy.