Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

numba vectorize returning list/array #3101

Closed
1 of 2 tasks
cristipurdel opened this issue Jul 12, 2018 · 3 comments
Closed
1 of 2 tasks

numba vectorize returning list/array #3101

cristipurdel opened this issue Jul 12, 2018 · 3 comments

Comments

@cristipurdel
Copy link

Feature request

Reporting a bug

@cristipurdel
Copy link
Author

cristipurdel commented Jul 12, 2018

If my code is wrong, please correct it, otherwise make a request
I need this option not to run multiple times the vectorize function
Could not find any tutorials on how to do this, hopefully is also 'cuda' future proof
Using the latest numba 0.38

Found this linked and will cross-link
Can this be as feature implemented or it does not make sense?
https://groups.google.com/a/continuum.io/forum/#!msg/numba-users/4B2elGzEFw8/XfSMDZLuAgAJ

import numpy as np
import time
import pdb
from numba import vectorize

@vectorize(['float32(float32, float32)'], target='parallel')
def VectorPowv(a, b):
    x = a ** b
    y = a * b
    out = []
    out.append(x)
    out.append(y)
    return out

def main():  
    N = 20000000
    A = B = np.array(np.random.sample(N), dtype=np.float32)
    A = A[:,np.newaxis]
    B = B[:,np.newaxis]    
    pdb.set_trace() 
    start = time.time()
    C = VectorPowv(A, B)
    print("C[:5] = " + str(C[:5]))
    print("C[-5:] = " + str(C[-5:]))
    vector_add_time = time.time() - start    
    print("VectorPow took for % seconds" % vector_add_time)

if __name__=='__main__':
    main()
    

Traceback

dtypenums.append(np.dtype(signature.return_type.name).num)

TypeError: data type "pyobject" not understood

@stuartarchibald
Copy link
Contributor

Thanks for the report. What is mentioned on the mailing list is correct. If you want to mutate a number of arrays at once then perhaps try a gufunc via @guvectorize? http://numba.pydata.org/numba-doc/dev/user/vectorize.html#the-guvectorize-decorator, or just use a @jit function if you don't need all the ufunc mechanics.

@cristipurdel
Copy link
Author

It is working with guvectorize, but I would have wanted this to work with vectorize.
I find @jit a bit difficult to work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants