You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
At the moment I am trying to use cp.vectorize to improve the performance over np.vectorize. However the function that I am trying to vectorize accepts an array like argument that I want to be consistent for each function call, so I dont want to vectorize over this argument, here is a minimal working example:
import numpy as np
from bisect import bisect_left
def myfunc(a,b):
return bisect_left(a, b)
vfunc = np.vectorize(myfunc, excluded = ['a'])
vfunc(a= np.array([1,2,3,4]),b=np.array([1.5,2.5]))
In other words, I would like the following code to work as expected:
import cupy as cp
from bisect import bisect_left
def myfunc(a,b):
return bisect_left(a, b)
vfunc = cp.vectorize(myfunc, excluded = ['a'])
vfunc(a= cp.array([1,2,3,4]),b=cp.array([1.5,2.5]))
Note that help(cp.vectorize) produces the following output:
Help on class vectorize in module cupy._functional.vectorize:
class vectorize(builtins.object)
| vectorize(pyfunc, otypes=None, doc=None, excluded=None, cache=False, signature=None)
|
| Generalized function class.
|
| .. seealso:: :class:numpy.vectorize
|
| Methods defined here:
|
| call(self, *args)
| Call self as a function.
|
| init(self, pyfunc, otypes=None, doc=None, excluded=None, cache=False, signature=None)
| Args:
| pyfunc (callable): The target python function.
| otypes (str or list of dtypes, optional): The output data type.
| doc (str or None): The docstring for the function.
| excluded: Currently not supported.
| cache: Currently Ignored.
| signature: Currently not supported.
I would like to request that the excluded option be implemented.
In the meantime, I tried to workaround this by vectorizing a function with arbitrary number of arguments *args, but cp.vectorize does not support this either:
import cupy as cp
from bisect import bisect_left
def myfunc(b, *a):
return bisect_left(a, b)
testlist = [4,5,6,7,8]
vfunc = cp.vectorize(myfunc)
vfunc(cp.array([1,2,3,4]),*testlist)
Output:
NotImplementedError: *args is not supported currently.
Any other potential workarounds would be greatly appreciated!
Additional Information
No response
The text was updated successfully, but these errors were encountered:
Description
At the moment I am trying to use cp.vectorize to improve the performance over np.vectorize. However the function that I am trying to vectorize accepts an array like argument that I want to be consistent for each function call, so I dont want to vectorize over this argument, here is a minimal working example:
In other words, I would like the following code to work as expected:
Note that
help(cp.vectorize)
produces the following output:I would like to request that the
excluded
option be implemented.In the meantime, I tried to workaround this by vectorizing a function with arbitrary number of arguments *args, but cp.vectorize does not support this either:
Output:
Any other potential workarounds would be greatly appreciated!
Additional Information
No response
The text was updated successfully, but these errors were encountered: