xnn.cnn.fast.spherical_kernels#

Triton kernels of the SphericalCNN fast path (see xnn.cnn.fast.spherical).

Imported only when the fast path runs, so that triton is needed only there.

Spectra are compact and blocked by degree: the entries |m|, |n| <= l of the signals of a batch B with C channels form, for each degree, one contiguous block (B, 2l + 1, C, 2l + 1) indexed (b, m, c, n) (SO(3)) or (B, 2l + 1, C) indexed (b, m, c) (S^2), and the blocks follow each other degree after degree; complex numbers are (real, imaginary) pairs on a trailing axis of two. A block is then the matrix of a correlation’s spectral product of that degree, rows (b, m) and columns (c, n), as a view. For small batches the blocks may instead be padded to 2L - 1 entries per index for every degree (centered, zeros outside |m|, |n| <= l), so that the products of all degrees are one batched matrix product. Two kernels:

  • the contraction over beta of the forward transforms, F[(l, b, m, c, n)] = sum_j X[b, c, j, m, n] T[(m, n), j, l] for every l >= max(|m|, |n|), which reads the FFT of the grid signal at the band positions (frequency m at position m mod S) and is a small matrix product per frequency;

  • the contraction over the degree of the inverse transforms, X[b, c, j, m, n] = sum_l F[(l, b, m, c, n)] T[(m, n), j, l], written onto the whole FFT grid, zero where no frequency of the band sits.

For the same (real) table the two are adjoint to each other, so the backward of each transform is the other kernel and differentiable again. float32 products run on tl.dot in IEEE precision, float64 ones as broadcast sums.

Functions

compact_size(L, so3)

Entries of a compact spectrum of bandwidth L: L (4 L^2 - 1) / 3 or L^2.

to_grid(z, plan, lead)

The FFT grids of the inverse transform of degree-blocked spectra, differentiable to any order.

to_spectrum(x, plan)

Degree-blocked spectra from the FFTs of grid signals, differentiable to any order.

Classes

SpectralPlan(table, J, L, S, so3[, padded])

One transform between a grid and compact spectra, for the contraction kernels.