-
Notifications
You must be signed in to change notification settings - Fork 916
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
Implement comprehensive set of ufuncs #256
Comments
One approach to this would be to combine the def __array_ufunc__(self, ufunc, method, *inputs, **kwargs):
if method == '__call__':
numba_gpu_ufunc = numba.gpu_vectorize(ufunc)
input_arrays = [input.to_gpu_array() if isinstance(pygdf.Series) else input for input in inputs]
data = numba_gpu_ufunc(*input_arrays, **kwargs)
return pygdf.Series(data, index=...)
else:
return NotImplemented Where I'm hoping that a function like cc @sklam is something like this possible? |
Even if possible, things like |
That being said, if we could do this for functionality first and optimize later that would be amazing. |
Here is a list of Numpy ufuncs In [1]: import numpy as np
In [2]: for x in dir(np):
...: if isinstance(getattr(np, x), np.ufunc):
...: print(x)
...:
abs
absolute
add
arccos
arccosh
arcsin
arcsinh
arctan
arctan2
arctanh
bitwise_and
bitwise_not
bitwise_or
bitwise_xor
cbrt
ceil
conj
conjugate
copysign
cos
cosh
deg2rad
degrees
divide
divmod
equal
exp
exp2
expm1
fabs
float_power
floor
floor_divide
fmax
fmin
fmod
frexp
gcd
greater
greater_equal
heaviside
hypot
invert
isfinite
isinf
isnan
isnat
lcm
ldexp
left_shift
less
less_equal
log
log10
log1p
log2
logaddexp
logaddexp2
logical_and
logical_not
logical_or
logical_xor
maximum
minimum
mod
modf
multiply
negative
nextafter
not_equal
positive
power
rad2deg
radians
reciprocal
remainder
right_shift
rint
sign
signbit
sin
sinh
spacing
sqrt
square
subtract
tan
tanh
true_divide
trunc |
I think that we should implement It sounds like the solution probably looks like the following: def __array_ufunc__(self, ufunc, method, *inputs, **kwargs):
if method == '__call__':
try:
func = getattr(pygdf, ufunc.__name__)
except AttributeError:
func = numba.gpu_vectorize(ufunc)
input_arrays = [input.to_gpu_array() if isinstance(pygdf.Series) else input for input in inputs]
data = func(*input_arrays, **kwargs)
return pygdf.Series(data, index=...)
else:
return NotImplemented (There are many things wrong with the above implementation. It's just there for demonstration. |
Roughly, this requires generating the scalar body of the ufunc (string templating is usually what we have to do) from the ufunc name and then wrapping with Another way to bootstrap could be with CuPy, which has implemented most of these functions with exact NumPy-like names and signatures. |
It looks like we could use this for |
Considering most of these are now implemented going to close this issue and encourage users to raise an issue for an individual function if it's not implemented already. |
There are a variety of ufuncs that are not yet implemented on pygdf. Operations like exp or round don't seem to be available. Some of these come through Numpy:
And some of them are methods:
The text was updated successfully, but these errors were encountered: