Skip to content

Commit 542def4

Browse files
Merge pull request #1526 from IntelPython/improve-order-processing-in-elementwise-common
Treatment of order="A" changed
2 parents 89266a7 + f146db2 commit 542def4

File tree

1 file changed

+14
-19
lines changed

1 file changed

+14
-19
lines changed

dpctl/tensor/_elementwise_common.py

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -687,25 +687,26 @@ def __call__(self, o1, o2, out=None, order="K"):
687687
else:
688688
src2 = dpt.asarray(o2, dtype=o2_dtype, sycl_queue=exec_q)
689689

690+
if order == "A":
691+
order = (
692+
"F"
693+
if all(
694+
arr.flags.f_contiguous
695+
for arr in (
696+
src1,
697+
src2,
698+
)
699+
)
700+
else "C"
701+
)
702+
690703
if buf1_dt is None and buf2_dt is None:
691704
if out is None:
692705
if order == "K":
693706
out = _empty_like_pair_orderK(
694707
src1, src2, res_dt, res_shape, res_usm_type, exec_q
695708
)
696709
else:
697-
if order == "A":
698-
order = (
699-
"F"
700-
if all(
701-
arr.flags.f_contiguous
702-
for arr in (
703-
src1,
704-
src2,
705-
)
706-
)
707-
else "C"
708-
)
709710
out = dpt.empty(
710711
res_shape,
711712
dtype=res_dt,
@@ -736,8 +737,6 @@ def __call__(self, o1, o2, out=None, order="K"):
736737
if order == "K":
737738
buf2 = _empty_like_orderK(src2, buf2_dt)
738739
else:
739-
if order == "A":
740-
order = "F" if src1.flags.f_contiguous else "C"
741740
buf2 = dpt.empty_like(src2, dtype=buf2_dt, order=order)
742741
ht_copy_ev, copy_ev = ti._copy_usm_ndarray_into_usm_ndarray(
743742
src=src2, dst=buf2, sycl_queue=exec_q
@@ -783,8 +782,6 @@ def __call__(self, o1, o2, out=None, order="K"):
783782
if order == "K":
784783
buf1 = _empty_like_orderK(src1, buf1_dt)
785784
else:
786-
if order == "A":
787-
order = "F" if src1.flags.f_contiguous else "C"
788785
buf1 = dpt.empty_like(src1, dtype=buf1_dt, order=order)
789786
ht_copy_ev, copy_ev = ti._copy_usm_ndarray_into_usm_ndarray(
790787
src=src1, dst=buf1, sycl_queue=exec_q
@@ -827,13 +824,11 @@ def __call__(self, o1, o2, out=None, order="K"):
827824
ht_binary_ev.wait()
828825
return out
829826

830-
if order in ["K", "A"]:
827+
if order == "K":
831828
if src1.flags.f_contiguous and src2.flags.f_contiguous:
832829
order = "F"
833830
elif src1.flags.c_contiguous and src2.flags.c_contiguous:
834831
order = "C"
835-
else:
836-
order = "C" if order == "A" else "K"
837832
if order == "K":
838833
buf1 = _empty_like_orderK(src1, buf1_dt)
839834
else:

0 commit comments

Comments
 (0)