Skip to content

'CUDAUFuncDispatcher' object has no attribute '__name__' #8272

Description

@s-m-e

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'

Activity

  1. stuartarchibald commented on Jul 25, 2022

    @stuartarchibald
    Contributor

    Thanks for the report. @testhound / @gmarkall please could you take a look at this as it's CUDA target, many thanks.

  2. testhound commented on Aug 1, 2022

    @testhound
    Contributor

    @stuartarchibald created a PR to address this issue: #8297

  3. stuartarchibald commented on Aug 8, 2022

    @stuartarchibald
    Contributor

    @testhound many thanks, closing as #8297 is merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions