IntelPython / dpctl

Python SYCL bindings and SYCL-based Python Array API library
https://intelpython.github.io/dpctl/
Apache License 2.0
99 stars 30 forks source link

dpt.squeeze() returns array without F-contigious flag #1180

Closed antonwolfy closed 1 year ago

antonwolfy commented 1 year ago

dpctl misses to set f_contiguous in below code example:

import numpy, dpctl, dpctl.tensor as dpt

numpy.squeeze(numpy.ones((1, 3, 1))).flags.f_contiguous
Out: True

dpt.squeeze(dpt.ones((1, 3, 1))).flags.f_contiguous
Out: False
oleksandr-pavlyk commented 1 year ago

Boils down to the following distinction:

In [6]: dpt.usm_ndarray([3], dtype="f4", strides=(1,)).flags
Out[6]:
  C_CONTIGUOUS : True
  F_CONTIGUOUS : False
  WRITABLE : True
In [7]: dpt.usm_ndarray([3], dtype="f4", strides=None).flags
Out[7]:
  C_CONTIGUOUS : True
  F_CONTIGUOUS : True
  WRITABLE : True