Skip to main content

conv2d_bn_silu_forward

Function conv2d_bn_silu_forward 

Source
pub fn conv2d_bn_silu_forward<T: Triton, 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>(
    x_ptr: T::Pointer<f32>,
    w_ptr: T::Pointer<f32>,
    bn_scale_ptr: T::Pointer<f32>,
    bn_shift_ptr: T::Pointer<f32>,
    y_ptr: T::Pointer<f32>,
    _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<f32>: AddOffsets<i32, 1, T::I32Tensor, Output = T::Tensor<T::Pointer<f32>>>,
Expand description

Fused Conv2d + BatchNorm2d (inference) + SiLU forward pass.

Epilog fusion: after the conv accumulation loop, applies BN affine and SiLU in registers before the final global store, eliminating 2 intermediate global memory round-trips vs 3 separate kernels.

BN parameters must be precomputed by the caller as: bn_scale[c] = gamma[c] / sqrt(var[c] + eps) bn_shift[c] = beta[c] - bn_scale[c] * mean[c]

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

Inference-only; no backward pass.