xnn.gnn.fast.allegro_kernels#

Triton kernels and autograd function of the Allegro fast path (see xnn.gnn.fast.allegro).

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

out[r, k] = sum_t c_t x[r, i_t] y[r, j_t] over the nonzero entries t = (k_t, i_t, j_t) of a sparse coupling. One kernel per pattern and per role of its three axes (output, first and second operand), generated from the pattern: a program takes a block of rows, one row per thread, loads the operand columns once and writes every output column from its unrolled sum. The coefficients are a tensor argument, so the kernels run the model’s own constants in either precision. The gradients of the contraction are the same contraction with the roles of the axes exchanged.

Module Attributes

BLOCK

Rows per program (one per thread) and warps per program.

Pattern

The nonzero entries (k, i, j) of a coupling and its shape (dim_out, dim1, dim2).

Functions

contract(x, y, c, pattern)

The sparse contraction of the Allegro tensor product (see xnn.gnn.fast.allegro).

Classes

BilinearFunction(*args, **kwargs)

out[r, a0] = sum c x[r, a1] y[r, a2] over the entries of pattern, the axes in the order roles; differentiable at any order in x and y.