Cannot determine ufunc class when targetting parallel or cuda

97 views
Skip to first unread message

Ismael Browne

unread,
Sep 23, 2020, 6:48:38 PM9/23/20
to Numba Public Discussion - Public
I'm learning how to use numba, and so im trying to optimize and make this block of code run faster:

from numba import vectorize,njit
import numpy as np

@vectorize("i2(i8)",target="parallel")
def collatz_step_counter(n):
    count=0
    while n!=1:
        if n%2==0:
            n/=2
        else:
            n=(3*n+1)/2
            count+=1
        count+=1
    return count

@njit
def max_collatz_steps(num,want_data=False):
    max_steps=0
    max_input=0
    lis=np.arange(1,num+1,2,dtype=np.int64)
    lis=collatz_step_counter(lis)
    max_steps=max(lis)
    max_input=2*lis.argmax()+1
    return max_input,max_steps

max_collatz_steps(1000000)
But when I put the @njit decorator on max_collatz_steps, it gives me one of two errors:

-If for the first function I write target="parallel", it gives me this error:
TypingError: cannot determine Numba type of <class 'numpy.ufunc'>

-Instead, if I write target="cuda", it gives me this error:
TypingError: cannot determine Numba type of <class 'numba.cuda.dispatcher.CUDAUFuncDispatcher'>

When I write target="cpu", it works fine.
Thanks in advance.

Valentin Haenel

unread,
Sep 24, 2020, 6:05:23 AM9/24/20
to numba...@continuum.io
Dear Ismael,

thank you for asking about this issue on the Numba mailinglist. This mailinglist is slowly being retired and so I have copied the issue over to our issue tracker here:

https://github.com/numba/numba/issues/6280

Also,  I can confirm that I observe the behavior you describe.

Best wishes,

V-


--
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.
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/numba-users/f9464d69-d8f9-494d-b2fd-470a2ca4c694n%40continuum.io.
Reply all
Reply to author
Forward
0 new messages