CUDA Conv/Pool FFI #
Foreign-function declarations for TorchLean's float32 convolution and pooling adapter,
implemented in csrc/libtorch/torchlean.cpp.
All buffers are contiguous LibTorch.Buffer values and shape/stride/padding metadata is passed
explicitly through the FFI boundary.
Float32 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 1 ≤ d ≤ 3.
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 transposed convolution backward.
Returns (dKernel, dBias, dInput) as device buffers.
Array conventions match torchleanConvTransposeFwdCuda.
Float32 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 1 ≤ d ≤ 3.
Float32 convolution backward.
Returns (dKernel, dBias, dInput) as device buffers.
Array conventions match torchleanConvFwdCuda.
Float32 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 smooth max-pooling backward, returning dInput.
It shares the forward operation's finite nonzero-beta contract and sign-aware max/min input pivot.