mars.tensor.ascontiguousarray

mars.tensor.ascontiguousarray(a, dtype=None, chunk_size=None)[源代码]

Return a contiguous tensor (ndim >= 1) in memory (C order).

参数
  • a (array_like) – Input tensor.

  • dtype (str or dtype object, optional) – Data-type of returned tensor.

  • chunk_size (int, tuple, optional) – Specifies chunk size for each dimension.

返回

out – Contiguous tensor of same shape and content as a, with type dtype if specified.

返回类型

Tensor

参见

asfortranarray

Convert input to a tensor with column-major memory order.

Tensor.flags

Information about the memory layout of the tensor.

实际案例

>>> import mars.tensor as mt
>>> x = mt.arange(6).reshape(2,3)
>>> mt.ascontiguousarray(x, dtype=mt.float32)
array([[ 0.,  1.,  2.],
       [ 3.,  4.,  5.]], dtype=float32)
>>> x.flags['C_CONTIGUOUS']
True

Note: This function returns a tensor with at least one-dimension (1-d) so it will not preserve 0-d tensors.