Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions dpctl/tensor/_copy_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -672,9 +672,9 @@ def astype(
f_contig = usm_ary.flags.f_contiguous
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 (
f_contig and order not in ["A", "F"]
)
needs_copy = (
c_contig and not f_contig and order not in ["A", "C"]
Comment thread
oleksandr-pavlyk marked this conversation as resolved.
) or (not c_contig and f_contig and order not in ["A", "F"])
if not needs_copy:
return usm_ary
copy_order = "C"
Expand Down
11 changes: 11 additions & 0 deletions dpctl/tests/test_usm_ndarray_ctor.py
Original file line number Diff line number Diff line change
Expand Up @@ -1435,6 +1435,17 @@ def test_astype_device():
assert r.sycl_queue == q2


def test_astype_gh_1926():
get_queue_or_skip()

x = dpt.ones(10_000)
Comment thread
oleksandr-pavlyk marked this conversation as resolved.
Outdated
x_ = dpt.astype(x, x.dtype, copy=False, order="C")
assert x is x_

x__ = dpt.astype(x, x.dtype, copy=False, order="F")
assert x is x__


def test_copy():
try:
X = dpt.usm_ndarray((5, 5), "i4")[2:4, 1:4]
Expand Down