vkML 0.1.0

Conv1d

1D convolution over (N, C, L), matching torch.nn.Conv1d.

class Conv1d : Modulepython/vkml/nn.py:703

Composed from Conv2d, not a new kernel. A 1-D convolution is the 2-D one with a height of 1: the input becomes (N, C, 1, L), the weight gets a kernel height of 1, and the axis is squeezed back out afterwards. The arithmetic is identical, so a separate GLSL kernel would be a second implementation of one algorithm — which this project has already learned costs a byte-level comparison to keep honest.

Weight layout is torch's, (out_channels, in_channels, kernel_size), so a state_dict loads without rearrangement.

ⓘ Note

Both reshapes are view operations: zero-copy, no allocation, no dispatch. The im2col underneath sees a height of 1 with no padding in that axis, so it does no work for it either.

⚠ Warning

If a profile ever shows the 1-D path dominated by the degenerate height axis — a very long sequence with a tiny channel count — a dedicated kernel becomes arguable. Nothing measures that today, and reserving a kernel for a speculative case is what ADR 0004 exists to refuse.

Construction

__init__

def __init__self, in_channels: int, out_channels: int, kernel_size: int, stride: int=1, padding: int=0, dilation: int=1, bias: bool=Truepython/vkml/nn.py:731

Forward

forward

def forwardself, x: V.Tensor -> V.Tensorpython/vkml/nn.py:754

Internals

__repr__

def __repr__self -> strpython/vkml/nn.py:773

See also Conv2d, conv2d, im2col

vkML — Vulkan-first machine learning in C++20. Apache-2.0. Signatures on this page are generated from the installed module.