99)
1010
1111import dpnp
12+ import dpnp .backend .extensions .vm ._vm_impl as vmi
1213from dpnp .dpnp_utils import map_dtype_to_device
1314
1415from .helper import (
2021 get_float_dtypes ,
2122 has_support_aspect16 ,
2223 has_support_aspect64 ,
24+ is_cuda_device ,
25+ is_gpu_device ,
2326)
2427
2528# full list of umaths
2629umaths = [i for i in dir (numpy ) if isinstance (getattr (numpy , i ), numpy .ufunc )]
2730
28- types = {
29- "d" : numpy .float64 ,
30- "f" : numpy .float32 ,
31- "l" : numpy .int64 ,
32- "i" : numpy .int32 ,
33- }
34-
35- supported_types = "fli"
31+ supported_types = "?bBhHiIlLkK"
32+ if has_support_aspect16 ():
33+ supported_types += "e"
34+ supported_types += "fF"
3635if has_support_aspect64 ():
37- supported_types += "d "
36+ supported_types += "dD "
3837
3938
4039def check_types (args_str ):
@@ -55,7 +54,7 @@ def shaped_arange(shape, xp=numpy, dtype=numpy.float32):
5554def get_args (args_str , sh , xp = numpy ):
5655 args = []
5756 for s in args_str :
58- args .append (shaped_arange (shape = sh , xp = xp , dtype = types [ s ] ))
57+ args .append (shaped_arange (shape = sh , xp = xp , dtype = numpy . dtype ( s ) ))
5958 return tuple (args )
6059
6160
@@ -75,6 +74,7 @@ def get_id(val):
7574 return val .__str__ ()
7675
7776
77+ @pytest .mark .filterwarnings ("ignore:overflow encountered:RuntimeWarning" )
7878@pytest .mark .usefixtures ("suppress_divide_invalid_numpy_warnings" )
7979@pytest .mark .parametrize ("test_cases" , test_cases , ids = get_id )
8080def test_umaths (test_cases ):
@@ -91,7 +91,7 @@ def test_umaths(test_cases):
9191 iargs = get_args (args_str , sh , xp = dpnp )
9292
9393 if umath == "reciprocal" :
94- if args [0 ].dtype in [ numpy . int32 , numpy .int64 ] :
94+ if numpy . issubdtype ( args [0 ].dtype , numpy .integer ) :
9595 pytest .skip (
9696 "For integer input array, numpy.reciprocal returns zero."
9797 )
@@ -102,11 +102,32 @@ def test_umaths(test_cases):
102102 and numpy .dtype ("l" ) != numpy .int64
103103 ):
104104 pytest .skip ("numpy.ldexp doesn't have a loop for the input types" )
105+ elif (
106+ umath == "floor_divide"
107+ and args [0 ].dtype in [dpnp .float16 , dpnp .float32 ]
108+ and is_gpu_device ()
109+ ):
110+ pytest .skip ("dpctl-1652" )
111+ elif umath in ["ceil" , "floor" , "trunc" ] and args [0 ].dtype == dpnp .bool :
112+ pytest .skip ("dpctl-2030" )
113+ elif (
114+ umath == "tan"
115+ and dpnp .issubdtype (args [0 ].dtype , dpnp .complexfloating )
116+ and not (vmi ._is_available () and has_support_aspect64 ())
117+ ):
118+ pytest .skip ("dpctl-2031" )
119+ elif umath in ["divmod" , "frexp" ]:
120+ pytest .skip ("Not implemented umath" )
121+ elif umath == "modf" :
122+ if args [0 ].dtype == dpnp .float16 :
123+ pytest .skip ("dpnp.modf is not supported with dpnp.float16" )
124+ elif is_cuda_device ():
125+ pytest .skip ("dpnp.modf is not supported on CUDA device" )
105126
106127 expected = getattr (numpy , umath )(* args )
107128 result = getattr (dpnp , umath )(* iargs )
108-
109- assert_allclose ( result , expected , rtol = 1e-6 )
129+ for x , y in zip ( result , expected ):
130+ assert_dtype_allclose ( x , y )
110131
111132
112133class TestArctan2 :
0 commit comments