@@ -298,25 +298,25 @@ def _clip_none(x, val, out, order, _binary_fn):
298298 else :
299299 val_ary = dpt .asarray (val , dtype = val_dtype , sycl_queue = exec_q )
300300
301+ if order == "A" :
302+ order = (
303+ "F"
304+ if all (
305+ arr .flags .f_contiguous
306+ for arr in (
307+ x ,
308+ val_ary ,
309+ )
310+ )
311+ else "C"
312+ )
301313 if val_dtype == res_dt :
302314 if out is None :
303315 if order == "K" :
304316 out = _empty_like_pair_orderK (
305317 x , val_ary , res_dt , res_shape , res_usm_type , exec_q
306318 )
307319 else :
308- if order == "A" :
309- order = (
310- "F"
311- if all (
312- arr .flags .f_contiguous
313- for arr in (
314- x ,
315- val_ary ,
316- )
317- )
318- else "C"
319- )
320320 out = dpt .empty (
321321 res_shape ,
322322 dtype = res_dt ,
@@ -347,8 +347,6 @@ def _clip_none(x, val, out, order, _binary_fn):
347347 if order == "K" :
348348 buf = _empty_like_orderK (val_ary , res_dt )
349349 else :
350- if order == "A" :
351- order = "F" if x .flags .f_contiguous else "C"
352350 buf = dpt .empty_like (val_ary , dtype = res_dt , order = order )
353351 ht_copy_ev , copy_ev = ti ._copy_usm_ndarray_into_usm_ndarray (
354352 src = val_ary , dst = buf , sycl_queue = exec_q
@@ -473,8 +471,6 @@ def clip(x, /, min=None, max=None, out=None, order="K"):
473471 if order == "K" :
474472 out = _empty_like_orderK (x , x .dtype )
475473 else :
476- if order == "A" :
477- order = "F" if x .flags .f_contiguous else "C"
478474 out = dpt .empty_like (x , order = order )
479475
480476 ht_copy_ev , copy_ev = ti ._copy_usm_ndarray_into_usm_ndarray (
@@ -659,6 +655,19 @@ def clip(x, /, min=None, max=None, out=None, order="K"):
659655 else :
660656 a_max = dpt .asarray (max , dtype = max_dtype , sycl_queue = exec_q )
661657
658+ if order == "A" :
659+ order = (
660+ "F"
661+ if all (
662+ arr .flags .f_contiguous
663+ for arr in (
664+ x ,
665+ a_min ,
666+ a_max ,
667+ )
668+ )
669+ else "C"
670+ )
662671 if buf1_dt is None and buf2_dt is None :
663672 if out is None :
664673 if order == "K" :
@@ -672,19 +681,6 @@ def clip(x, /, min=None, max=None, out=None, order="K"):
672681 exec_q ,
673682 )
674683 else :
675- if order == "A" :
676- order = (
677- "F"
678- if all (
679- arr .flags .f_contiguous
680- for arr in (
681- x ,
682- a_min ,
683- a_max ,
684- )
685- )
686- else "C"
687- )
688684 out = dpt .empty (
689685 res_shape ,
690686 dtype = res_dt ,
@@ -718,18 +714,6 @@ def clip(x, /, min=None, max=None, out=None, order="K"):
718714 if order == "K" :
719715 buf2 = _empty_like_orderK (a_max , buf2_dt )
720716 else :
721- if order == "A" :
722- order = (
723- "F"
724- if all (
725- arr .flags .f_contiguous
726- for arr in (
727- x ,
728- a_min ,
729- )
730- )
731- else "C"
732- )
733717 buf2 = dpt .empty_like (a_max , dtype = buf2_dt , order = order )
734718 ht_copy_ev , copy_ev = ti ._copy_usm_ndarray_into_usm_ndarray (
735719 src = a_max , dst = buf2 , sycl_queue = exec_q
@@ -784,18 +768,6 @@ def clip(x, /, min=None, max=None, out=None, order="K"):
784768 if order == "K" :
785769 buf1 = _empty_like_orderK (a_min , buf1_dt )
786770 else :
787- if order == "A" :
788- order = (
789- "F"
790- if all (
791- arr .flags .f_contiguous
792- for arr in (
793- x ,
794- a_max ,
795- )
796- )
797- else "C"
798- )
799771 buf1 = dpt .empty_like (a_min , dtype = buf1_dt , order = order )
800772 ht_copy_ev , copy_ev = ti ._copy_usm_ndarray_into_usm_ndarray (
801773 src = a_min , dst = buf1 , sycl_queue = exec_q
@@ -846,7 +818,7 @@ def clip(x, /, min=None, max=None, out=None, order="K"):
846818 ht_binary_ev .wait ()
847819 return out
848820
849- if order in [ "K" , "A" ] :
821+ if order == "K" :
850822 if (
851823 x .flags .f_contiguous
852824 and a_min .flags .f_contiguous
@@ -859,8 +831,6 @@ def clip(x, /, min=None, max=None, out=None, order="K"):
859831 and a_max .flags .c_contiguous
860832 ):
861833 order = "C"
862- else :
863- order = "C" if order == "A" else "K"
864834 if order == "K" :
865835 buf1 = _empty_like_orderK (a_min , buf1_dt )
866836 else :
0 commit comments