pub fn conv1d(
input: &Array,
weight: &Array,
stride: usize,
padding: usize,
dilation: usize,
groups: usize,
) -> Result<Array>Expand description
The 1-D convolution (cross-correlation) of input ([N, L, C_in]) with weight
([C_out, K, C_in / groups]), as MLX’s conv1d: output [N, L_out, C_out] with
L_out = (L + 2·padding − dilation·(K − 1) − 1) / stride + 1. Channels split into
groups independent groups (groups = C_in = C_out is a depthwise convolution).
Products accumulate in float32 and round once, as MLX’s kernels.
use nuvec_core::{Array, Result, conv1d};
// A moving sum of three, one channel.
let x = Array::from_slice(&[1.0f32, 2.0, 3.0, 4.0, 5.0], &[1, 5, 1])?;
let w = Array::from_slice(&[1.0f32, 1.0, 1.0], &[1, 3, 1])?;
assert_eq!(conv1d(&x, &w, 1, 0, 1, 1)?.to_vec::<f32>()?, [6.0, 9.0, 12.0]);
assert_eq!(conv1d(&x, &w, 2, 1, 1, 1)?.to_vec::<f32>()?, [3.0, 9.0, 9.0]);