Tensara Logo

tensara

1D Convolution

EASY

Perform 1D convolution between an input signal and a kernel:

C[i]=j=0K1A[i+j]B[j]\text{C}[i] = \sum_{j=0}^{K-1} \text{A}[i + j] \cdot \text{B}[j]

The convolution operation slides the kernel over the input signal, computing the sum of element-wise multiplications at each position. Zero padding is used at the boundaries.

Input:

  • Vector A\text{A} of size N\text{N} (input signal)
  • Vector B\text{B} of size K\text{K} (convolution kernel)

Output:

  • Vector C\text{C} of size N\text{N} (convolved signal)

Notes:

  • K\text{K} is odd and smaller than N\text{N}
  • Use zero padding at the boundaries where the kernel extends beyond the input signal
  • The kernel is centered at each position, with (K1)/2(K-1)/2 elements on each side
  • This problem is adapted from KernelBench

GPU Type

Language

Data Type

Loading...

Loading editor...

CUDA C++ environment

Sample Run Results

Hit "Run" to test your code with sample inputs

Desktop Required for Code Submission

For the best coding experience, please switch to a desktop device to write and submit your solution.