@@ -601,6 +601,14 @@ def test_tofrom_numpy(shape, dtype, usm_type):
601601@pytest .mark .parametrize ("src_usm_type" , ["device" , "shared" , "host" ])
602602@pytest .mark .parametrize ("dst_usm_type" , ["device" , "shared" , "host" ])
603603def 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+ )
604612 Xnp = (
605613 np .random .randint (- 10 , 10 , size = 2 * 3 * 4 )
606614 .astype (dtype )
@@ -649,6 +657,12 @@ def test_setitem_same_dtype(dtype, src_usm_type, dst_usm_type):
649657)
650658@pytest .mark .parametrize ("usm_type" , ["device" , "shared" , "host" ])
651659def 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" )
652666 X = dpt .usm_ndarray ((6 , 6 ), dtype = dtype , buffer = usm_type )
653667 for i in range (X .size ):
654668 X [np .unravel_index (i , X .shape )] = np .asarray (i , dtype = dtype )
@@ -673,13 +687,22 @@ def test_setitem_errors():
673687 X [:] = Y [None , :, 0 ]
674688
675689
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 )
680703 Z [::2 ] = X
681704 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 ))
683706
684707
685708def test_shape_setter ():
@@ -804,8 +827,8 @@ def test_to_device_migration():
804827def test_astype ():
805828 X = dpt .empty ((5 , 5 ), dtype = "i4" )
806829 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 " ))
809832 Y = dpt .astype (X [::2 , ::- 1 ], "f2" , order = "K" )
810833 assert np .allclose (dpt .to_numpy (Y ), np .full (Y .shape , 7 , dtype = "f2" ))
811834 Y = dpt .astype (X [::2 , ::- 1 ], "i4" , order = "K" , copy = False )
@@ -946,7 +969,15 @@ def test_zeros(dtype):
946969 _all_dtypes ,
947970)
948971def 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 )
950981 assert np .array_equal (dpt .asnumpy (X ), np .ones (10 , dtype = dtype ))
951982
952983
@@ -955,7 +986,15 @@ def test_ones(dtype):
955986 _all_dtypes ,
956987)
957988def 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 )
959998 assert np .array_equal (dpt .asnumpy (X ), np .full (10 , 4 , dtype = dtype ))
960999
9611000
@@ -976,6 +1015,10 @@ def test_arange(dt):
9761015 except dpctl .SyclQueueCreationError :
9771016 pytest .skip ("Queue could not be created" )
9781017
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+ )
9791022 X = dpt .arange (0 , 123 , dtype = dt , sycl_queue = q )
9801023 dt = np .dtype (dt )
9811024 if np .issubdtype (dt , np .integer ):
@@ -1093,6 +1136,10 @@ def test_ones_like(dt, usm_kind):
10931136 q = dpctl .SyclQueue ()
10941137 except dpctl .SyclQueueCreationError :
10951138 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+ )
10961143
10971144 X = dpt .empty ((4 , 5 ), dtype = dt , usm_type = usm_kind , sycl_queue = q )
10981145 Y = dpt .ones_like (X )
@@ -1129,6 +1176,11 @@ def test_full_like(dt, usm_kind):
11291176 except dpctl .SyclQueueCreationError :
11301177 pytest .skip ("Queue could not be created" )
11311178
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+
11321184 fill_v = np .dtype (dt ).type (1 )
11331185 X = dpt .empty ((4 , 5 ), dtype = dt , usm_type = usm_kind , sycl_queue = q )
11341186 Y = dpt .full_like (X , fill_v )
0 commit comments