hard primitives

Implement 1D Convolution

Implement a 1D convolution (cross-correlation) operation.

$$(x * w)[i] = \sum_{k=0}^{K-1} x[i + k] \cdot w[k] + b$$

Input:

  • x: 1D input tensor of shape (L,)
  • weight: 1D kernel of shape (K,)
  • bias: scalar bias
  • stride: convolution stride (default 1)

Output: 1D tensor of shape (L_out,) where $L_{out} = \lfloor \frac{L - K}{\text{stride}} \rfloor + 1$

Hints

convolution cnn signal-processing
Detecting runtime...