Skip to main content

filter2d

Function filter2d 

pub fn filter2d(
    images: Tensor<4>,
    kernel: Tensor<2>,
    border: PadMode,
) -> Tensor<4>
Expand description

Depthwise convolution of a tensor with a 2D kernel.

images is laid out as [N, C, H, W]. Every channel is filtered independently — a grouped convolution with groups = C, so the same kernel is broadcast across channels without mixing them. The output keeps the input’s spatial size for odd kernel dimensions; even dimensions pad asymmetrically toward the top/left.

§Arguments

  • input - A tensor shaped [N, C, H, W].
  • kernel - The A 2D tensor to convolve with the input.
  • border - The padding mode applied to the input before the convolution.

§Returns

The filtered batched images, same shape as the input.