TensorData - Tinker Documentation

tinker.types.TensorData

class tinker.types.TensorData()

Fields:

The shape of the tensor (see PyTorch tensor.shape). The shape of a one-dimensional list of length N is (N,). Can usually be inferred if not provided, and is generally inferred as a 1D tensor.

property data

Flattened tensor data as array of numbers.

Returns: Union[List[int], List[float]]

from_torch_sparse( tensor )

Create a sparse CSR TensorData from a dense 2-D torch tensor.

Automatically detects sparsity and encodes as CSR when it saves space. Falls back to dense if the tensor is 1-D or mostly non-zero.

Parameters:

Returns: TensorData

to_numpy()

Convert TensorData to numpy array.

Returns: npt.NDArray[Any]

to_torch()

Convert TensorData to torch tensor.

Returns: torch.Tensor

Referenced by