xnn.gnn.fast.linear.SpeciesTensorProduct#

class xnn.gnn.fast.linear.SpeciesTensorProduct(*args, **kwargs)[source]#

Bases: FullyConnectedTensorProduct, FastPathModule

Tensor product with the one-hot chemical element of each atom, with a fast path.

An e3nn.o3.FullyConnectedTensorProduct (same arguments, parameters and state_dict) whose second input is one scalar irrep per element. With one-hot rows in that input, the product is a linear map of the first input chosen by each atom’s element. The fast path groups the atoms by element and applies each element’s map to its atoms only, instead of the reference’s product with every element. It runs outside CUDA-graph capture (grouping reads the element counts on the host) and when no gradient with respect to the element input is needed.

fast_supported(device, dtype)[source]#

Whether the fast path can run for inputs on device in dtype.

Parameters:
Return type:

bool

forward(x, y, weight=None)[source]#

The tensor product of x (shape (..., irreps_in1.dim)) with the element attributes y ((..., num_species), one-hot rows on the fast path).

Parameters:
Return type:

Tensor

ir_mul(x, y)[source]#

The product with every irrep block of x and of the result laid out (2l + 1, mul) (fast path only).

Parameters:
Return type:

Tensor