CUDA Conv/Pool FFI #
Foreign-function declarations for TorchLean's float32 convolution and pooling kernels. The real
CUDA implementation lives in csrc/cuda/conv_pool/; CPU stubs with the same symbols are used when
TorchLean is built without -K cuda=true.
All buffers are contiguous Cuda.Buffer values and shape/stride/padding metadata is passed
explicitly through the FFI boundary.
Float32 N-D transposed convolution forward (channels-first, no batch).
Shapes/parameters:
inSpatial: lengthd(input spatial dims)kernelSpatial: lengthd(kernel window)stride: lengthdpadding: lengthd
All arrays must have the same length d ≤ 8.
Layout conventions:
- input:
(inC, spatial...) - kernel:
(inC, outC, kernelSpatial...) - bias:
(outC) - output:
(outC, outSpatial...), whereoutSpatial[i] = (inSpatial[i] - 1) * stride[i] - 2*padding[i] + kernelSpatial[i].
Float32 N-D transposed convolution backward.
Returns (dKernel, dBias, dInput) as device buffers.
Array conventions match torchleanConvTransposeFwdCuda.
Float32 N-D convolution forward (channels-first, no batch).
Shapes/parameters:
inSpatial: lengthd(spatial dims)kernelSpatial: lengthd(kernel window)stride: lengthdpadding: lengthd
All arrays must have the same length d ≤ 8.
Float32 N-D convolution backward.
Returns (dKernel, dBias, dInput) as device buffers.
Array conventions match torchleanConvFwdCuda.
Float32 N-D smooth max-pooling forward with channels preserved.
The native implementation requires finite nonzero beta and uses a maximum input pivot for
positive beta or a minimum input pivot for negative beta, matching the two-dimensional path.
Float32 N-D smooth max-pooling backward, returning dInput.
It shares the forward operation's finite nonzero-beta contract and sign-aware max/min input pivot.