Closed
Description
import dpctl.tensor as dpt
import time
a = dpt.zeros(10**7)
a.sycl_queue.wait()
begin = time.time()
a_ = dpt.astype(a, a.dtype, copy=False, order="C")
a_.sycl_queue.wait()
end = time.time()
print("astype time:", end - begin)
print("a is a_", a is a_)
a.sycl_queue.wait()
begin = time.time()
a__ = dpt.asarray(a, dtype=a.dtype)
a__.sycl_queue.wait()
end = time.time()
print("asarray time:", end - begin)
print("a is a__", a is a__)
Output:
astype time: 0.02135610580444336
a is a_ False
asarray time: 8.7738037109375e-05
a is a__ True
The problem is here
dpctl/dpctl/tensor/_copy_utils.py
Line 676 in 73112fd
c_contig = usm_ary.flags.c_contiguous # = True for 1d contiguous array
f_contig = usm_ary.flags.f_contiguous # Also = **True** for 1d contiguous array
needs_copy = copy or not ary_dtype == target_dtype
if not needs_copy and (order != "K"):
needs_copy = (c_contig and order not in ["A", "C"]) or ( # = False since c_contig == True and order == "C"
f_contig and order not in ["A", "F"] # = **True** since f_contig == True and order == "C"
)
Metadata
Metadata
Assignees
Labels
No labels