@@ -623,3 +623,37 @@ def test_asarray_support_for_usm_ndarray_protocol(usm_type):
623
623
assert x .dtype == y3 .dtype
624
624
assert y3 .usm_data .reference_obj is None
625
625
assert dpt .all (x [dpt .newaxis , :] == y3 )
626
+
627
+
628
+ @pytest .mark .parametrize ("dt" , [dpt .float16 , dpt .float64 , dpt .complex128 ])
629
+ def test_asarray_to_device_with_unsupported_dtype (dt ):
630
+ if dt == dpt .float64 or dt == dpt .complex128 :
631
+ aspect = "fp64"
632
+ else :
633
+ aspect = "fp16"
634
+ try :
635
+ d0 = dpctl .select_device_with_aspects (aspect )
636
+ except dpctl .SyclDeviceCreationError :
637
+ pytest .skip ("No device with aspect for test" )
638
+
639
+ d1 = None
640
+ try :
641
+ d1 = dpctl .select_device_with_aspects ("cpu" , excluded_aspects = [aspect ])
642
+ except dpctl .SyclDeviceCreationError :
643
+ pass
644
+ try :
645
+ d1 = dpctl .select_device_with_aspects ("gpu" , excluded_aspects = [aspect ])
646
+ except dpctl .SyclDeviceCreationError :
647
+ pass
648
+ try :
649
+ d1 = dpctl .select_device_with_aspects (
650
+ "accelerator" , excluded_aspects = [aspect ]
651
+ )
652
+ except dpctl .SyclDeviceCreationError :
653
+ pass
654
+ if d1 is None :
655
+ pytest .skip ("No device with missing aspect for test" )
656
+
657
+ x = dpt .ones (10 , dtype = dt , device = d0 )
658
+ y = dpt .asarray (x , device = d1 )
659
+ assert y .sycl_device == d1
0 commit comments