33# SPDX-License-Identifier: Apache-2.0
44
55import copy
6+ import logging
67
78import dpnp
89import numpy as np
@@ -56,6 +57,7 @@ def _fill_ufunc_db_with_dpnp_ufuncs(ufunc_db):
5657 # variable is passed by value
5758 from numba .np .ufunc_db import _ufunc_db
5859
60+ failed_dpnpop_types_lst = []
5961 for ufuncop in dpnpdecl .supported_ufuncs :
6062 if ufuncop == "erf" :
6163 op = getattr (dpnp , "erf" )
@@ -72,20 +74,38 @@ def _fill_ufunc_db_with_dpnp_ufuncs(ufunc_db):
7274 "d->d" : mathimpl .lower_ocl_impl [("erf" , (_unary_d_d ))],
7375 }
7476 else :
75- op = getattr (dpnp , ufuncop )
77+ dpnpop = getattr (dpnp , ufuncop )
7678 npop = getattr (np , ufuncop )
77- op .nin = npop .nin
78- op .nout = npop .nout
79- op .nargs = npop .nargs
80- op .types = npop .types
81- op .is_dpnp_ufunc = True
79+ if not hasattr (dpnpop , "nin" ):
80+ dpnpop .nin = npop .nin
81+ if not hasattr (dpnpop , "nout" ):
82+ dpnpop .nout = npop .nout
83+ dpnpop .nargs = dpnpop .nin + dpnpop .nout
84+ try :
85+ dpnpop .types
86+ except ValueError :
87+ failed_dpnpop_types_lst .append (ufuncop )
88+ except AttributeError :
89+ dpnpop .types = npop .types
90+
91+ dpnpop .is_dpnp_ufunc = True
8292 cp = copy .copy (_ufunc_db [npop ])
83- ufunc_db .update ({op : cp })
84- for key in list (ufunc_db [op ].keys ()):
93+ ufunc_db .update ({dpnpop : cp })
94+ for key in list (ufunc_db [dpnpop ].keys ()):
8595 if (
8696 "FF->" in key
8797 or "DD->" in key
8898 or "F->" in key
8999 or "D->" in key
90100 ):
91- ufunc_db [op ].pop (key )
101+ ufunc_db [dpnpop ].pop (key )
102+
103+ if failed_dpnpop_types_lst :
104+ try :
105+ getattr (dpnp , failed_dpnpop_types_lst [0 ]).types
106+ except ValueError :
107+ ops = " " .join (failed_dpnpop_types_lst )
108+ logging .exception (
109+ "The types attribute for the following dpnp ops could not be "
110+ f"determined: { ops } "
111+ )
0 commit comments