@@ -601,6 +601,14 @@ def test_tofrom_numpy(shape, dtype, usm_type):
601
601
@pytest .mark .parametrize ("src_usm_type" , ["device" , "shared" , "host" ])
602
602
@pytest .mark .parametrize ("dst_usm_type" , ["device" , "shared" , "host" ])
603
603
def test_setitem_same_dtype (dtype , src_usm_type , dst_usm_type ):
604
+ try :
605
+ q = dpctl .SyclQueue ()
606
+ except dpctl .SyclQueueCreationError :
607
+ pytest .skip ("Could not create default SyclQueue." )
608
+ if q .sycl_device .has_aspect_fp64 is False and dtype in ["f8" , "c16" ]:
609
+ pytest .skip (
610
+ "Device does not support double precision floating point types."
611
+ )
604
612
Xnp = (
605
613
np .random .randint (- 10 , 10 , size = 2 * 3 * 4 )
606
614
.astype (dtype )
@@ -649,6 +657,12 @@ def test_setitem_same_dtype(dtype, src_usm_type, dst_usm_type):
649
657
)
650
658
@pytest .mark .parametrize ("usm_type" , ["device" , "shared" , "host" ])
651
659
def test_setitem_scalar (dtype , usm_type ):
660
+ try :
661
+ q = dpctl .SyclQueue ()
662
+ except dpctl .SyclQueueCreationError :
663
+ pytest .skip ("Could not create default SyclQueue" )
664
+ if q .sycl_device .has_aspect_fp64 is False and dtype in ["f8" , "c16" ]:
665
+ pytest .skip ("Device does not support double precision floating type" )
652
666
X = dpt .usm_ndarray ((6 , 6 ), dtype = dtype , buffer = usm_type )
653
667
for i in range (X .size ):
654
668
X [np .unravel_index (i , X .shape )] = np .asarray (i , dtype = dtype )
@@ -673,13 +687,22 @@ def test_setitem_errors():
673
687
X [:] = Y [None , :, 0 ]
674
688
675
689
676
- def test_setitem_different_dtypes ():
677
- X = dpt .from_numpy (np .ones (10 , "f4" ))
678
- Y = dpt .from_numpy (np .zeros (10 , "f4" ))
679
- Z = dpt .usm_ndarray ((20 ,), "d" )
690
+ @pytest .mark .parametrize ("src_dt,dst_dt" , [("i4" , "i8" ), ("f4" , "f8" )])
691
+ def test_setitem_different_dtypes (src_dt , dst_dt ):
692
+ try :
693
+ q = dpctl .SyclQueue ()
694
+ except dpctl .SyclQueueCreationError :
695
+ pytest .skip ("Default queue could not be created" )
696
+ if dst_dt == "f8" and q .sycl_device .has_aspect_fp64 is False :
697
+ pytest .skip (
698
+ "Device does not support double precision floating point type"
699
+ )
700
+ X = dpt .from_numpy (np .ones (10 , src_dt ), sycl_queue = q )
701
+ Y = dpt .from_numpy (np .zeros (10 , src_dt ), sycl_queue = q )
702
+ Z = dpt .empty ((20 ,), dtype = dst_dt , sycl_queue = q )
680
703
Z [::2 ] = X
681
704
Z [1 ::2 ] = Y
682
- assert np .allclose (dpt .asnumpy (Z ), np .tile (np .array ([1 , 0 ], "d" ), 10 ))
705
+ assert np .allclose (dpt .asnumpy (Z ), np .tile (np .array ([1 , 0 ], Z . dtype ), 10 ))
683
706
684
707
685
708
def test_shape_setter ():
@@ -804,8 +827,8 @@ def test_to_device_migration():
804
827
def test_astype ():
805
828
X = dpt .empty ((5 , 5 ), dtype = "i4" )
806
829
X [:] = np .full ((5 , 5 ), 7 , dtype = "i4" )
807
- Y = dpt .astype (X , "c16 " , order = "C" )
808
- assert np .allclose (dpt .to_numpy (Y ), np .full ((5 , 5 ), 7 , dtype = "c16 " ))
830
+ Y = dpt .astype (X , "c8 " , order = "C" )
831
+ assert np .allclose (dpt .to_numpy (Y ), np .full ((5 , 5 ), 7 , dtype = "c8 " ))
809
832
Y = dpt .astype (X [::2 , ::- 1 ], "f2" , order = "K" )
810
833
assert np .allclose (dpt .to_numpy (Y ), np .full (Y .shape , 7 , dtype = "f2" ))
811
834
Y = dpt .astype (X [::2 , ::- 1 ], "i4" , order = "K" , copy = False )
@@ -946,7 +969,15 @@ def test_zeros(dtype):
946
969
_all_dtypes ,
947
970
)
948
971
def test_ones (dtype ):
949
- X = dpt .ones (10 , dtype = dtype )
972
+ try :
973
+ q = dpctl .SyclQueue ()
974
+ except dpctl .SyclQueueCreationError :
975
+ pytest .skip ("Could not created default queue" )
976
+ if dtype in ["f8" , "c16" ] and q .sycl_device .has_aspect_fp64 is False :
977
+ pytest .skip (
978
+ "Device does not support double precision floating point type"
979
+ )
980
+ X = dpt .ones (10 , dtype = dtype , sycl_queue = q )
950
981
assert np .array_equal (dpt .asnumpy (X ), np .ones (10 , dtype = dtype ))
951
982
952
983
@@ -955,7 +986,15 @@ def test_ones(dtype):
955
986
_all_dtypes ,
956
987
)
957
988
def test_full (dtype ):
958
- X = dpt .full (10 , 4 , dtype = dtype )
989
+ try :
990
+ q = dpctl .SyclQueue ()
991
+ except dpctl .SyclQueueCreationError :
992
+ pytest .skip ("Could not created default queue" )
993
+ if dtype in ["f8" , "c16" ] and q .sycl_device .has_aspect_fp64 is False :
994
+ pytest .skip (
995
+ "Device does not support double precision floating point type"
996
+ )
997
+ X = dpt .full (10 , 4 , dtype = dtype , sycl_queue = q )
959
998
assert np .array_equal (dpt .asnumpy (X ), np .full (10 , 4 , dtype = dtype ))
960
999
961
1000
@@ -976,6 +1015,10 @@ def test_arange(dt):
976
1015
except dpctl .SyclQueueCreationError :
977
1016
pytest .skip ("Queue could not be created" )
978
1017
1018
+ if dt in ["f8" , "c16" ] and q .sycl_device .has_aspect_fp64 is False :
1019
+ pytest .skip (
1020
+ "Device does not support double precision floating point type"
1021
+ )
979
1022
X = dpt .arange (0 , 123 , dtype = dt , sycl_queue = q )
980
1023
dt = np .dtype (dt )
981
1024
if np .issubdtype (dt , np .integer ):
@@ -1093,6 +1136,10 @@ def test_ones_like(dt, usm_kind):
1093
1136
q = dpctl .SyclQueue ()
1094
1137
except dpctl .SyclQueueCreationError :
1095
1138
pytest .skip ("Queue could not be created" )
1139
+ if dt in ["f8" , "c16" ] and q .sycl_device .has_aspect_fp64 is False :
1140
+ pytest .skip (
1141
+ "Device does not support double precision floating point type"
1142
+ )
1096
1143
1097
1144
X = dpt .empty ((4 , 5 ), dtype = dt , usm_type = usm_kind , sycl_queue = q )
1098
1145
Y = dpt .ones_like (X )
@@ -1129,6 +1176,11 @@ def test_full_like(dt, usm_kind):
1129
1176
except dpctl .SyclQueueCreationError :
1130
1177
pytest .skip ("Queue could not be created" )
1131
1178
1179
+ if dt in ["f8" , "c16" ] and q .sycl_device .has_aspect_fp64 is False :
1180
+ pytest .skip (
1181
+ "Device does not support double precision floating point type"
1182
+ )
1183
+
1132
1184
fill_v = np .dtype (dt ).type (1 )
1133
1185
X = dpt .empty ((4 , 5 ), dtype = dt , usm_type = usm_kind , sycl_queue = q )
1134
1186
Y = dpt .full_like (X , fill_v )
0 commit comments