mindspore.Tensor.contiguous
- Tensor.contiguous()[source]
Converts a Tensor into a continuous-memory Tensor that contains the same data as the original Tensor.
- Returns
A contiguous in memory tensor containing the same data as self tensor.
Examples
>>> 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)) >>> z = y.contiguous() >>> print(z.is_contiguous()) True