mindspore.Tensor.is_contiguous

mindspore.Tensor.is_contiguous()[源代码]

判断Tensor的内存是否连续。

返回:

Bool,如果Tensor的内存是连续的,则返回True,否则返回False。

样例:

>>> import mindspore as ms
>>> import numpy as np
>>> from mindspore import Tensor, ops
>>> x = Tensor([[1, 2, 3], [4, 5, 6]], dtype=ms.float32)
>>> y = ops.transpose(x, (1, 0))
>>> print(y.is_contiguous())
False