[docs]@torch_jit_scriptdefis_contiguous_block(block:TensorBlock)->bool:""" Checks whether the values array and gradients values arrays (if present) of an input :py:class:`TensorBlock` are contiguous. Note that arrays of :py:class:`Labels` objects are not checked for contiguity. :param block: the input :py:class:`TensorBlock`. :return: bool, true if all values arrays contiguous, false otherwise. """ifnot_dispatch.is_contiguous(block.values):returnFalsefor_parameter,gradientinblock.gradients():iflen(gradient.gradients_list())!=0:raiseNotImplementedError("gradients of gradients are not supported")ifnot_dispatch.is_contiguous(gradient.values):returnFalsereturnTrue
[docs]@torch_jit_scriptdefis_contiguous(tensor:TensorMap)->bool:""" Checks whether all values arrays and gradients values arrays (if present) in all :py:class:`TensorBlock` of an input :py:class:`TensorMap` are contiguous. Note that arrays of :py:class:`Labels` objects are not checked for contiguity. :param tensor: the input :py:class:`TensorMap`. :return: bool, true if all values arrays contiguous, false otherwise. """forblockintensor.blocks():ifnotis_contiguous_block(block):returnFalsereturnTrue