tensor_tiled_depthwise.bend checks
raw source on the hub · import stelliferous@0.0.4.0/tensor_tiled_depthwise.bend as Tensor_tiled_depthwise
Depthwise convolution of tiled tensors. An input of shape [N,]C,H,W takes its lanes on the channels with the groups innermost, the image cells of the window, and the weights of shape C,1,K,K and the bias of shape C take theirs on the channel axis with the groups outermost, so lane l of a cell of group g convolves channel 8g + l with its own window, weights and bias. The result keeps the lanes on the channels with the groups innermost, +0 past the true channel count.
10 imports
import Base import ./kernel_tile.bend as Tile import ./storage_buffer.bend as Storage import ./tensor_access.bend as Access import ./tensor.bend as Tensors import ./tensor_grid.bend as Grid import ./tensor_window.bend as Window import ./tensor_tiled.bend as Tiled import ./tensor_tiled_map.bend as TiledMap import ./default_machine_limits.bend as Default
Definitions
def channels source · line 19 · raw
@shape:List<&2, U32> -> Maybe<&2, U32>
def kernel_when source · line 25 · raw
@valid:Bool -> @+kernel:U32 -> Maybe<&2, U32>
def parameters_fit source · line 32 · raw
@+channels:U32 -> @+kernel:U32 -> Bool
The weights and the bias of every channel group fit one buffer of the machine.
def kernel_of source · line 38 · raw
@channels:Maybe<&2, U32> -> @weights:List<&2, U32> -> @bias:List<&2, U32> -> Maybe<&2, U32>
The kernel extent of weights of shape C,1,K,K and a bias of shape C for an input of C channels whose parameters fit the machine.
def failed source · line 44 · raw
@+name:String -> @+shape:List<&2, U32> -> @status:0xa2af805348d03b11eb853850859654f6/tensor.Status -> @+workers:U32 -> 0xa2af805348d03b11eb853850859654f6/tensor_tiled.Tiled
def parameters_of source · line 49 · raw
@weights:Result<&2, &2, 0xa2af805348d03b11eb853850859654f6/tensor.Problem, List<&2, 0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8>> -> @bias:Result<&2, &2, 0xa2af805348d03b11eb853850859654f6/tensor.Problem, List<&2, 0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8>> -> Result<&2, &2, 0xa2af805348d03b11eb853850859654f6/tensor.Problem, List<&2, 0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8>>
def convolved source · line 61 · raw
@+taps:0xa2af805348d03b11eb853850859654f6/tensor_window.Taps -> @+lanes:U32 -> @+out_height:U32 -> @+out_width:U32 -> @+outputs:List<&2, U32> -> @+workers:U32 -> @parameters:List<&2, 0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8> -> @cells:0xa2af805348d03b11eb853850859654f6/tensor.Tensor<0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8> -> 0xa2af805348d03b11eb853850859654f6/tensor.Tensor<0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8>
The output cells of the input cells. Rows and steps of an output cell: every tap loads a sample tile and a weight tile and runs one lane multiply, one lane add and thirteen steps of addressing and bounds, every kernel row twelve steps, and the cell loads its bias tile and stores one tile with twenty steps around them.
def run source · line 72 · raw
@+taps:0xa2af805348d03b11eb853850859654f6/tensor_window.Taps -> @+axis:Nat -> @+lanes:U32 -> @+out_height:U32 -> @+out_width:U32 -> @+outputs:List<&2, U32> -> @+workers:U32 -> @parameters:Result<&2, &2, 0xa2af805348d03b11eb853850859654f6/tensor.Problem, List<&2, 0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8>> -> @cells:0xa2af805348d03b11eb853850859654f6/tensor.Tensor<0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8> -> 0xa2af805348d03b11eb853850859654f6/tensor_tiled.Tiled
def planned source · line 79 · raw
@+pool:0xa2af805348d03b11eb853850859654f6/tensor_access.Pool -> @+shape:List<&2, U32> -> @+workers:U32 -> @input:0xa2af805348d03b11eb853850859654f6/tensor_tiled.Tiled -> @weights:0xa2af805348d03b11eb853850859654f6/tensor_tiled.Tiled -> @bias:0xa2af805348d03b11eb853850859654f6/tensor_tiled.Tiled -> 0xa2af805348d03b11eb853850859654f6/tensor_tiled.Tiled
def checked source · line 86 · raw
@valid:Bool -> @+pool:0xa2af805348d03b11eb853850859654f6/tensor_access.Pool -> @+shape:List<&2, U32> -> @+workers:U32 -> @input:0xa2af805348d03b11eb853850859654f6/tensor_tiled.Tiled -> @weights:0xa2af805348d03b11eb853850859654f6/tensor_tiled.Tiled -> @bias:0xa2af805348d03b11eb853850859654f6/tensor_tiled.Tiled -> 0xa2af805348d03b11eb853850859654f6/tensor_tiled.Tiled
def shaped source · line 91 · raw
@status:0xa2af805348d03b11eb853850859654f6/tensor.Status -> @kernel:Maybe<&2, U32> -> @+shape:List<&2, U32> -> @+stride:U32 -> @+padding:U32 -> @+workers:U32 -> @input:0xa2af805348d03b11eb853850859654f6/tensor_tiled.Tiled -> @weights:0xa2af805348d03b11eb853850859654f6/tensor_tiled.Tiled -> @bias:0xa2af805348d03b11eb853850859654f6/tensor_tiled.Tiled -> 0xa2af805348d03b11eb853850859654f6/tensor_tiled.Tiled
def depthwise_conv2d source · line 103 · raw
@input:0xa2af805348d03b11eb853850859654f6/tensor_tiled.Tiled -> @weights:0xa2af805348d03b11eb853850859654f6/tensor_tiled.Tiled -> @bias:0xa2af805348d03b11eb853850859654f6/tensor_tiled.Tiled -> @+stride:U32 -> @+padding:U32 -> 0xa2af805348d03b11eb853850859654f6/tensor_tiled.Tiled
Every channel of an input of shape [N,]C,H,W convolves with its own weights of shape 1,K,K and adds its own bias, as conv2d of one channel does; the result keeps the channels of the input.