Issue
This might be a simple oversight, but anyway, I stumbled across this while testing and benchmarking:
import numba as nb
@nb.vectorize('f8(f8)', target = 'cpu')
def foo(x):
return x ** 2
@nb.vectorize('f8(f8)', target = 'cuda')
def bar(x):
return x ** 2
assert foo.__name__ == 'foo'
assert bar.__name__ == 'bar'
The second assertion, i.e. the one for bar, fails, causing AttributeError: 'CUDAUFuncDispatcher' object has no attribute '__name__'. For foo, the assert passes as expected. The difference: foo is compiled for target cpu, bar is compiled for target cuda. Otherwise, everything is identical. It would be useful if numba was consistent here.
Context
- CPython == 3.10.5 (Linux, x86_64)
- numba == 0.55.2
- llvmlite == 0.38.1
Workaround
Not sure how reliable this is, but the following appears to work:
def _name(func):
try:
return func.__name__
except AttributeError:
return list(func.functions.values())[0][1].py_func.__name__[13:]
assert _name(bar) == 'bar'
Issue
This might be a simple oversight, but anyway, I stumbled across this while testing and benchmarking:
The second assertion, i.e. the one for
bar, fails, causingAttributeError: 'CUDAUFuncDispatcher' object has no attribute '__name__'. Forfoo, the assert passes as expected. The difference:foois compiled for targetcpu,baris compiled for targetcuda. Otherwise, everything is identical. It would be useful ifnumbawas consistent here.Context
Workaround
Not sure how reliable this is, but the following appears to work: