Skip to main content

sparse_conv1d

Function sparse_conv1d 

Source
pub fn sparse_conv1d(
    input: &SparseTensor,
    weight: &Tensor,
    bias: Option<&Tensor>,
    stride: usize,
    padding: usize,
    dilation: usize,
) -> Result<SparseTensor>
Expand description

Sparse 1D convolution

Performs 1D convolution on sparse input tensors with dense kernels. This is efficient for sparse inputs as it only processes non-zero elements.

§Mathematical Formula

For input x and kernel w: y[b, i] = Σ(x[b, i + k*d - p] * w[o, k]) + bias[o] where b=batch, i=output position, k=kernel position, d=dilation, p=padding, o=output channel

§Arguments

  • input - Sparse input tensor [batch_size, input_length]
  • weight - Dense weight tensor [out_channels, kernel_size]
  • bias - Optional bias tensor [out_channels]
  • stride - Convolution stride
  • padding - Zero padding
  • dilation - Kernel dilation

§Returns

Sparse output tensor after convolution