[docs]@torch_jit_scriptdefmake_contiguous_block(block:TensorBlock)->TensorBlock:""" Returns a new :py:class:`TensorBlock` where the values and gradient (if present) arrays are made to be contiguous. :param block: the input :py:class:`TensorBlock`. """new_block=TensorBlock(values=_dispatch.make_contiguous(block.values),samples=block.samples,components=block.components,properties=block.properties,)forparameter,gradientinblock.gradients():iflen(gradient.gradients_list())!=0:raiseNotImplementedError("gradients of gradients are not supported")new_gradient=TensorBlock(values=_dispatch.make_contiguous(gradient.values),samples=gradient.samples,components=gradient.components,properties=gradient.properties,)new_block.add_gradient(parameter,new_gradient)returnnew_block
[docs]@torch_jit_scriptdefmake_contiguous(tensor:TensorMap)->TensorMap:""" Returns a new :py:class:`TensorMap` where all values and gradient values arrays are made to be contiguous. :param tensor: the input :py:class:`TensorMap`. """new_blocks:List[TensorBlock]=[]forblockintensor.blocks():new_blocks.append(make_contiguous_block(block))returnTensorMap(tensor.keys,new_blocks)