tensor_convolution_gradient.bend checks
raw source on the hub · import stelliferous@0.0.4.0/tensor_convolution_gradient.bend as Tensor_convolution_gradient
Gradients of conv2d in a fixed FP32 order. Every function gives the tensors it only reads back to its caller.
13 imports
import Base import ./tensor.bend as Tensors import ./tensor_grid.bend as Grid import ./tensor_pieces.bend as Pieces import ./tensor_convolution.bend as TensorConvolution import ./kernel_input_gradient.bend as InputKernel import ./kernel_shape.bend as KernelShape import ./storage_buffer.bend as Storage import ./default_machine_limits.bend as Default import ./machine_limits.bend as Machine import ./tensor_parameter_gradient.bend as ParameterGradient import ./tensor_tiled.bend as Tiled import ./kernel_tile.bend as Tile
Types
type Arguments source · line 23 · raw
Data
Arguments@geometry:0xa2af805348d03b11eb853850859654f6/kernel_input_gradient.Geometry -> @batch:U32 -> @batched:Bool -> Arguments
type Kept source · line 68 · raw
Data
What the call keeps of the weights besides their cells.
Kept@shape:List<&2, U32> -> @lanes:U32 -> @fill:0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8 -> @status:0xa2af805348d03b11eb853850859654f6/tensor.Status -> @workers:U32 -> Kept
Definitions
def Cells source · line 17 · raw
Type
def Tensor source · line 20 · raw
Type
def input_dimensions source · line 26 · raw
@arguments:Arguments -> 0xa2af805348d03b11eb853850859654f6/kernel_shape.Dimensions
def input_shape source · line 30 · raw
@arguments:Arguments -> List<&2, U32>
def input_cell_shape source · line 36 · raw
@arguments:Arguments -> List<&2, U32>
The cells of the input gradient: the positions of every image, the groups of a position side by side.
def input_cells source · line 41 · raw
@+arguments:Arguments -> @+workers:U32 -> @output:0xa2af805348d03b11eb853850859654f6/tensor_pieces.Pieces(0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8) -> Tensor
The input gradient as cells with the channels in their lanes.
def input_valid_with source · line 46 · raw
@+arguments:Arguments -> @+d_cells:U32 -> @+weight_cells:U32 -> @+limits:0xa2af805348d03b11eb853850859654f6/machine_limits.Limits -> Bool
The limits are an argument so that a proof can keep them symbolic.
def weights_back source · line 64 · raw
@+shape:List<&2, U32> -> @+lanes:U32 -> @+fill:0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8 -> @status:0xa2af805348d03b11eb853850859654f6/tensor.Status -> @+workers:U32 -> @weights:0xa2af805348d03b11eb853850859654f6/storage_buffer.Buffer<0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8> -> Tensor
The weights come back as cells of the groups outermost.
def kept_shape source · line 71 · raw
@kept:Kept -> List<&2, U32>
def kept_lanes source · line 75 · raw
@kept:Kept -> U32
def kept_workers source · line 79 · raw
@kept:Kept -> U32
def kept_back source · line 83 · raw
@kept:Kept -> @weights:0xa2af805348d03b11eb853850859654f6/storage_buffer.Buffer<0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8> -> Tensor
def input_result source · line 87 · raw
@+arguments:Arguments -> @+workers:U32 -> @+kept:Kept -> @result:0xa2af805348d03b11eb853850859654f6/kernel_input_gradient.Outcome -> Pair(Tensor, Tensor)
def input_whole source · line 93 · raw
@+arguments:Arguments -> @+d_grid:0xa2af805348d03b11eb853850859654f6/tensor_grid.Grid -> U32
A task holds whole images of d and of the input gradient when the pieces of both do.
def input_checked source · line 97 · raw
@accepted:Bool -> @+arguments:Arguments -> @+d_shape:List<&2, U32> -> @gradient:0xa2af805348d03b11eb853850859654f6/tensor_pieces.Pieces(0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8) -> @+workers:U32 -> @weights:0xa2af805348d03b11eb853850859654f6/storage_buffer.Buffer<0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8> -> @+kept:Kept -> Pair(Tensor, Tensor)
def input_geometry source · line 108 · raw
@+stride:U32 -> @+padding:U32 -> @+height:U32 -> @+width:U32 -> @+limits:0xa2af805348d03b11eb853850859654f6/machine_limits.Limits -> @shape:Maybe<&2, 0xa2af805348d03b11eb853850859654f6/tensor_convolution.InputShape> -> @weight_logical:List<&2, U32> -> @+d_shape:List<&2, U32> -> @gradient:0xa2af805348d03b11eb853850859654f6/tensor_pieces.Pieces(0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8) -> @+workers:U32 -> @weights:0xa2af805348d03b11eb853850859654f6/storage_buffer.Buffer<0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8> -> @+kept:Kept -> Pair(Tensor, Tensor)
def input_status source · line 119 · raw
@status:0xa2af805348d03b11eb853850859654f6/tensor.Status -> @+stride:U32 -> @+padding:U32 -> @+height:U32 -> @+width:U32 -> @gradient:0xa2af805348d03b11eb853850859654f6/tensor_pieces.Pieces(0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8) -> @+d_cells:List<&2, U32> -> @+d_lanes:U32 -> @+d_fill:0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8 -> @+workers:U32 -> @weights:0xa2af805348d03b11eb853850859654f6/storage_buffer.Buffer<0xa2af805348d03b11eb853850859654f6/kernel_tile.Tile8> -> @+kept:Kept -> Pair(Tensor, Tensor)
def input_values source · line 131 · raw
@d:Cells -> @+d_lanes:U32 -> @weights:Cells -> @+weight_lanes:U32 -> @+stride:U32 -> @+padding:U32 -> @+height:U32 -> @+width:U32 -> Pair(Tensor, Tensor)
d with the channels in its lanes, the groups innermost, and the weights with the input channels in their lanes, the groups outermost.
def input_aligned source · line 138 · raw
@d:Tensor -> @weights:Tensor -> @stride:U32 -> @padding:U32 -> @height:U32 -> @width:U32 -> Pair(Tensor, Tensor)
def channel_lanes source · line 145 · raw
@pair:Pair(Tensor, List<&2, U32>) -> Tensor
The cells of x and d with their lanes on the channels, the axis before the rows, the groups innermost.
def input source · line 154 · raw
@d:Tensor -> @weights:Tensor -> @stride:U32 -> @padding:U32 -> @height:U32 -> @width:U32 -> Pair(Tensor, Tensor)
d [N,O,Ho,Wo] or [O,Ho,Wo] and weights [O,C,k,k] of a convolution of an input of the given height and width: (the gradient of that input, the weights with the input channels in their lanes). Several input sizes give the same output size when the stride is above 1, so height and width are given.
def group_length source · line 158 · raw
U32
The group length of the weight and bias gradient contract.
def weight_result source · line 161 · raw
@+x_axis:Nat -> @+x_lanes:U32 -> @+d_axis:Nat -> @+d_lanes:U32 -> @result:Pair(Tensor, Pair(Cells, Cells)) -> Pair(Tensor, Pair(Tensor, Tensor))
def weight_cells source · line 166 · raw
@x:Tensor -> @d:Tensor -> @+kernel:U32 -> @+stride:U32 -> @+padding:U32 -> @+group:U32 -> Pair(Tensor, Pair(Tensor, Tensor))
def weight_grouped source · line 175 · raw
@x:Tensor -> @d:Tensor -> @kernel:U32 -> @stride:U32 -> @padding:U32 -> @group:U32 -> Pair(Tensor, Pair(Tensor, Tensor))
x [N,C,H,W], d [N,O,Ho,Wo], or both without their batch axes: (weight gradient [O,C,k,k] with the outputs in its lanes, the groups outermost, (x,d)), read from the cells of the channels, its sums in groups of group positions.
def weight source · line 178 · raw
@x:Tensor -> @d:Tensor -> @kernel:U32 -> @stride:U32 -> @padding:U32 -> Pair(Tensor, Pair(Tensor, Tensor))
def bias_result source · line 181 · raw
@+axis:Nat -> @+lanes:U32 -> @result:Pair(Tensor, Cells) -> Pair(Tensor, Tensor)
def bias_cells source · line 185 · raw
@d:Tensor -> @+group:U32 -> Pair(Tensor, Tensor)
def bias source · line 192 · raw
@d:Tensor -> Pair(Tensor, Tensor)
d [N,O,Ho,Wo] or [O,Ho,Wo]: (bias gradient [O] with the outputs in its lanes, d), read from the cells of the channels in the order of the contract, its sums in groups of group positions.