inspecting ufunc objects

0 views
Skip to first unread message

Dustin Moore

unread,
Jun 9, 2017, 1:56:36 PM6/9/17
to Numba Public Discussion - Public
Is there a way to inspect a ufunc produced by the @vectorize decorator to figure out what module or source code file contained the original Python that was compiled?

I did a dir() on a ufunc from Numba and the attributes were
['__call__', '__class__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__name__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', 'accumulate', 'at', 'identity', 'nargs', 'nin', 'nout', 'ntypes', 'outer', 'reduce', 'reduceat', 'signature', 'types']

and I couldn't find any of them that would be useful. A __module__ would be really useful.

Thanks, 

Dustin Moore

Jim Pivarski

unread,
Jun 9, 2017, 2:04:34 PM6/9/17
to numba...@continuum.io
There is (I'm away from my computer right now, so I can't test it): look for an "overloads" dictionary, one for each signature, and in its values, "library.get_llvm_str()". For the Python source, there is an attribute holding the original function, which you can use Python's inspect module on.

Jim




--
You received this message because you are subscribed to the Google Groups "Numba Public Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to numba-users+unsubscribe@continuum.io.
To post to this group, send email to numba...@continuum.io.
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/numba-users/086ff741-c72a-4873-aa89-f78e91303323%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Dustin Moore

unread,
Jun 9, 2017, 7:36:12 PM6/9/17
to Numba Public Discussion - Public
That seems to work for @jit functions. 

When I look at a @vectorize ufunc, I get "AttributeError: 'numpy.ufunc' object has no attribute 'overloads'".

Thanks,


On Friday, June 9, 2017 at 11:04:34 AM UTC-7, Jim Pivarski wrote:
There is (I'm away from my computer right now, so I can't test it): look for an "overloads" dictionary, one for each signature, and in its values, "library.get_llvm_str()". For the Python source, there is an attribute holding the original function, which you can use Python's inspect module on.

Jim



On Jun 9, 2017 12:56 PM, "Dustin Moore" <moo...@secac.com> wrote:
Is there a way to inspect a ufunc produced by the @vectorize decorator to figure out what module or source code file contained the original Python that was compiled?

I did a dir() on a ufunc from Numba and the attributes were
['__call__', '__class__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__name__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', 'accumulate', 'at', 'identity', 'nargs', 'nin', 'nout', 'ntypes', 'outer', 'reduce', 'reduceat', 'signature', 'types']

and I couldn't find any of them that would be useful. A __module__ would be really useful.

Thanks, 

Dustin Moore

--
You received this message because you are subscribed to the Google Groups "Numba Public Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to numba-users...@continuum.io.

Jim Pivarski

unread,
Jun 9, 2017, 7:57:22 PM6/9/17
to numba...@continuum.io
Somewhere in the ufunc is something called a CPUDispatcher, that's what you're looking for.




To unsubscribe from this group and stop receiving emails from it, send an email to numba-users+unsubscribe@continuum.io.

To post to this group, send email to numba...@continuum.io.

Dustin Moore

unread,
Jun 10, 2017, 10:23:53 AM6/10/17
to Numba Public Discussion - Public
I did inspect.getmembers() on a numba ufunc and I don't see any objects that could contain a CPUDispatcher. When I looked at the numba source code it seems like the CPUDispatcher might be a numba module level variable that isn't associated with a particular ufunc. 

Thanks,
Reply all
Reply to author
Forward
0 new messages