~/bend-docscommunity

tensor_convolution_gradient.bend checks

raw source on the hub · import stelliferous@0.0.3.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.

10 imports
import Base
import ./tensor.bend as Tensors
import ./tensor_band.bend as Bands
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

Types

type Arguments source · line 17 · raw

Data

Definitions

def Tensor source · line 14 · raw

Type

def input_dimensions source · line 20 · raw

@arguments:Arguments -> 0xd6aaab858a4fbd1461bd0fee27b97184/kernel_shape.Dimensions

def input_band_geometry source · line 25 · raw

@arguments:Arguments -> 0xd6aaab858a4fbd1461bd0fee27b97184/tensor_band.Geometry

The bands of the input gradient: rows of every image of the batch.

def input_shape source · line 29 · raw

@arguments:Arguments -> List<&2, U32>

def input_valid_with source · line 34 · raw

@+arguments:Arguments -> @d_length:Nat -> @+weight_length:Nat -> @+limits:0xd6aaab858a4fbd1461bd0fee27b97184/machine_limits.Limits -> Bool

The limits are an argument so that a proof can keep them symbolic.

def input_valid source · line 46 · raw

@arguments:Arguments -> @d_length:Nat -> @weight_length:Nat -> Bool

def input_result source · line 49 · raw

@+arguments:Arguments -> @+workers:U32 -> @+weight_shape:List<&2, U32> -> @+weight_fill:F32 -> @+weight_workers:U32 -> @result:0xd6aaab858a4fbd1461bd0fee27b97184/kernel_input_gradient.Outcome -> Pair(Tensor, Tensor)

def input_checked source · line 53 · raw

@accepted:Bool -> @+arguments:Arguments -> @+count:U32 -> @gradient:0xd6aaab858a4fbd1461bd0fee27b97184/storage_buffer.Buffer<F32> -> @weights:0xd6aaab858a4fbd1461bd0fee27b97184/storage_buffer.Buffer<F32> -> @+workers:U32 -> @+weight_shape:List<&2, U32> -> @+weight_fill:F32 -> @+weight_workers:U32 -> Pair(Tensor, Tensor)

def input_count source · line 61 · raw

@count:Maybe<&2, U32> -> @+arguments:Arguments -> @gradient:0xd6aaab858a4fbd1461bd0fee27b97184/storage_buffer.Buffer<F32> -> @weights:0xd6aaab858a4fbd1461bd0fee27b97184/storage_buffer.Buffer<F32> -> @+workers:U32 -> @+weight_shape:List<&2, U32> -> @+weight_fill:F32 -> @+weight_workers:U32 -> Pair(Tensor, Tensor)

def input_geometry source · line 70 · raw

@+stride:U32 -> @+padding:U32 -> @+height:U32 -> @+width:U32 -> @shape:Maybe<&2, 0xd6aaab858a4fbd1461bd0fee27b97184/tensor_convolution.InputShape> -> @+weight_shape:List<&2, U32> -> @gradient:0xd6aaab858a4fbd1461bd0fee27b97184/storage_buffer.Buffer<F32> -> @weights:0xd6aaab858a4fbd1461bd0fee27b97184/storage_buffer.Buffer<F32> -> @+workers:U32 -> @+weight_fill:F32 -> @+weight_workers:U32 -> Pair(Tensor, Tensor)

def input_status source · line 78 · raw

@status:0xd6aaab858a4fbd1461bd0fee27b97184/tensor.Status -> @+stride:U32 -> @+padding:U32 -> @+height:U32 -> @+width:U32 -> @gradient:0xd6aaab858a4fbd1461bd0fee27b97184/storage_buffer.Buffer<F32> -> @+d_shape:List<&2, U32> -> @+d_fill:F32 -> @+workers:U32 -> @weights:0xd6aaab858a4fbd1461bd0fee27b97184/storage_buffer.Buffer<F32> -> @+weight_shape:List<&2, U32> -> @+weight_fill:F32 -> @+weight_status:0xd6aaab858a4fbd1461bd0fee27b97184/tensor.Status -> @+weight_workers:U32 -> Pair(Tensor, Tensor)

def input source · line 89 · 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). 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 96 · raw

U32

The group length of the weight and bias gradient contract.

def weight source · line 101 · raw

@x:Tensor -> @d:Tensor -> @kernel:U32 -> @stride:U32 -> @padding:U32 -> Pair(Tensor, Pair(Tensor, Tensor))

x [N,C,H,W], d [N,O,Ho,Wo], or both without their batch axes. Returns (weight gradient [O,C,k,k], (x,d)); all sources are read only.

def bias source · line 105 · raw

@d:Tensor -> Pair(Tensor, Tensor)

d [N,O,Ho,Wo] or [O,Ho,Wo]: (bias gradient [O], d).