Skip to main content

conv2d_backward_dx

Function conv2d_backward_dx 

Source
pub fn conv2d_backward_dx<T: Triton, D: Num, const KH: i32, const KW: i32, const STRIDE_H: i32, const STRIDE_W: i32, const PAD_H: i32, const PAD_W: i32, const G: i32, const BLOCK_OW: i32>(
    dy_ptr: T::Pointer<D>,
    w_ptr: T::Pointer<D>,
    dx_ptr: T::Pointer<D>,
    _B: i32,
    C_IN: i32,
    C_OUT: i32,
    H: i32,
    W: i32,
    OH: i32,
    OW: i32,
)
where T::I32Tensor: Tensor<i32, 1> + Comparison<i32, BoolTensor = T::BoolTensor>, T::BoolTensor: BitAnd<Output = T::BoolTensor>, T::Pointer<D>: AddOffsets<i32, 1, T::I32Tensor, Output = T::Tensor<T::Pointer<D>>>,
Expand description

2-D convolution backward pass — gradient with respect to input (dx).

Uses the same grid as the forward pass (over output positions) and scatters the gradient back to the input via atomic_add, which correctly handles overlapping receptive fields when STRIDE < kernel size.

G — number of groups (1 = standard conv, G = C_IN = C_OUT for depthwise). Weight layout: [C_OUT, C_IN/G, KH, KW].

Grid: pid = ((b * C_OUT + c_out) * OH + oh) * num_ow_tiles + ow_tile

Padding positions (those that correspond to out-of-bounds input locations) are skipped.