-
Notifications
You must be signed in to change notification settings - Fork 11
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
Interface and 'do' #10
Comments
Hi @jonas-eschle, thanks for the issue! Firstly note you can do: from autoray import numpy as np
x = np.random.uniform(size=(2, 3, 4), like='numpy')
y = np.cos(x) With regards to the
For example x = do('random.normal', size=(10), like='numpy')
do('fft.ifftshift', x)
# array([-1.03934721, 0.20498712, 2.19194394, 0.3072858 , -1.27799811,
# -1.41765394, -0.33233833, -0.24674171, 1.20681194, 0.86175232]) works even though we haven't listed anywhere all the fft routines numpy has. That being said however I wouldn't be against having explicit functions listed like tensordot = functools.partial(do, fn='tensordot')
... if people thought that was a improvement over the two above methods. |
I see, I was indeed not aware of the numpy interface, thanks for pointing me to it! I simply overlooked it What about the gradients? I have not seen anything mentioned here? Or control-flow in general, And is there a possibility to set the backend global (I didn't see this either, just in a context manager)? |
Gradient-wise, There's not any support for non-python control-flow since this is not something I have ever used. I suppose it's only necessary for dynamic computations where one is also compiling or taking the gradient? One could just translate them directly to python for Adding functions to set the backend permanently could easily be added - but are currently not there. |
I've added |
Ah good, many thanks!
Indeed, that would be helpful, but it's not urgent, as we also have abstracted this away currently.
Indeed, this is for any compiled computation where you want to have a while loop or vectorize or execute a function conditionally only. But it's a new level, and easier to wrap as there are only a few functions. So in general the library looks quite interesting. Is there any overview which numpy functions are actually supported? Also, just looked again at the README: I would very strongly encourage to advertise the numpy API! Having a numpy API with switchable backend that works well is a treasure! But the |
It really is any backend function that can be imported, so the entirety of
The idea is that it should find the correct function automatically most of the time, and then we just cover the remaining cases with explicit 'translations' which are very quick to add when they are needed.
It is in the readme, just a little down the page. It used to be more prominent and maybe should be made so again... |
Hi, this is an interesting, yet difficult library! While it seems intriguing, I wonder thought about the interface: why is there always a 'do'? Why does the library not just wrap the API directly? Writing
do("command")
seems quite cumbersome compared tocommand
.Is that API a future plan?
The text was updated successfully, but these errors were encountered: