fovi.sensing.grid_sample_cuda

CuPy/NVRTC kernels for sampling CUDA images at moving foveated grids.

The public sampler owns coordinate preparation and backend selection. This module is a small optional implementation detail: it accepts raw Torch storage and launches on Torch’s current CUDA stream without constructing a CuPy array or a full-resolution float tensor. Floating storage is preserved while coordinate/interpolation arithmetic uses float32 for float16/float32 and float64 for float64.

fovi.sensing.grid_sample_cuda.sample_uint8(image: Tensor, base_grid: Tensor, fix_loc: Tensor, fix_size: Tensor, mode: str = 'nearest', cmf_indices: Tensor | None = None) → Tensor[source]

Return native-scale (B, C, N) samples from a shared or indexed grid bank.

The public sampler validates contiguous int64 cmf_indices of shape (B,) before dispatching here. base_grid has shape (levels, 1, N, 2).

fovi.sensing.grid_sample_cuda.sample_float(image: Tensor, base_grid: Tensor, fix_loc: Tensor, fix_size: Tensor, mode: str = 'nearest', cmf_indices: Tensor | None = None) → Tensor[source]

Sample a CUDA floating image and preserve its storage dtype at output.

fovi.sensing.grid_sample_cuda.clear_kernel_cache()[source]

Clear Python-side kernel and stream handles (primarily for tests).