make_contiguous

These operations are equivalent of numpy.ascontiguousarray() in numpy and torch.Tensor.contiguous() in torch.

metatensor.make_contiguous(tensor: TensorMap) TensorMap[source]

Returns a new TensorMap where all values and gradient values arrays are made to be contiguous.

Parameters:

tensor (TensorMap) – the input TensorMap.

Return type:

TensorMap

metatensor.make_contiguous_block(block: TensorBlock) TensorBlock[source]

Returns a new TensorBlock where the values and gradient (if present) arrays are made to be contiguous.

Parameters:

block (TensorBlock) – the input TensorBlock.

Return type:

TensorBlock