Operations

The Python API for metatensor also provides functions which operate on TensorMap, TensorBlock, and Labels and can be used to build your own machine learning models. These operations are provided in the metatensor-operations python package, which is installed by default when doing pip install metatensor.

The operations are implemented in Python, and handle the extra metadata (including sparsity and gradients) of metatensor. Actual manipulations of the data itself will call the corresponding functions from numpy or PyTorch, depending on how the arrays are stored in the various TensorBlock.

The list of all operations currently implemented is available in the API reference below. If you need any other operation, please open an issue!

🔥 Using the operations with PyTorch

Learn how the operations interact with PyTorch, and in particular with PyTorch’s automatic differentiation framework when handling gradients.

Operations and PyTorch
Python Operations API reference

Read the documentation for all the functions in the metatensor-operations Python package.

API reference