Open
Description
I came across a case where the input array is C-contiguous
but was trying to create a output array with order=F
& copy=False
. There are some differences between cupy & dpnp/dpctl. I am not sure where (i.e., dpnp or dpctl) to post this issue.
I am not sure what is the guidance on this. The implementation in dpctl/tensor seems to be doing the right thing but dont understand the cupy's behavior here. Attached has some backtrace info and was wondering if someone has any pointers on this.
import dpnp as cp
# Create a C-contiguous array
a = cp.arange(12).reshape(3, 4) # shape (3,4) — row-major layout
print("a.flags.c_contiguous =", a.flags.c_contiguous) # True
print("a.flags.f_contiguous =", a.flags.f_contiguous) # False
# Now try to call cupy.array with order='F', copy=False
b = cp.array(a, order='F', copy=False)
print("b.flags.c_contiguous =", b.flags.c_contiguous)
print("b.flags.f_contiguous =", b.flags.f_contiguous)
print("Did copy occur? a is b:", a is b)
With cupy this is the output:
a.flags.c_contiguous = True
a.flags.f_contiguous = False
b.flags.c_contiguous = False
b.flags.f_contiguous = True
Did copy occur? a is b: False
With dpnp/dpctl:
a.flags.c_contiguous = True
a.flags.f_contiguous = False
Traceback (most recent call last):
File "/lus/flare/projects/NWChemEx_aesp_CNDA/abagusetty/gpu4pyscf/test_cupy_array_copyfalse.py", line 10, in <module>
b = cp.array(a, order='F', copy=False)
File "/lus/flare/projects/NWChemEx_aesp_CNDA/abagusetty/gpu4pyscf/dpnp/dpnp/dpnp_iface_arraycreation.py", line 429, in array
result = dpnp_container.asarray(
File "/lus/flare/projects/NWChemEx_aesp_CNDA/abagusetty/gpu4pyscf/dpnp/dpnp/dpnp_container.py", line 121, in asarray
array_obj = dpt.asarray(
File "/lus/flare/projects/NWChemEx_aesp_CNDA/abagusetty/gpu4pyscf/dpctl/dpctl/tensor/_ctors.py", line 573, in asarray
return _asarray_from_usm_ndarray(
File "/lus/flare/projects/NWChemEx_aesp_CNDA/abagusetty/gpu4pyscf/dpctl/dpctl/tensor/_ctors.py", line 159, in _asarray_from_usm_ndarray
raise ValueError("asarray(..., copy=False) is not possible")
ValueError: asarray(..., copy=False) is not possible
Metadata
Metadata
Assignees
Labels
No labels