-
Notifications
You must be signed in to change notification settings - Fork 4
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
Type promotion #110
Comments
Took a look at NEP 50 examples, #125 Basically, array/array operations are OK, but mixing arrays and python scalars breaks down:
This is not entirely unexpected because we just wrap python scalars into 0D tensors and only deal with tensors. |
Note that we cannot implement without casting one way or another to 0D tensors, since NumPy accepts Python scalars almost everywhere, while PyTorch just accepts scalars on dunder methods. As such, it's impossible to implement I think we can deal with this at the decorator level tho. The idea here would be to process scalars after all the array-likes have been wrapped. Then, compute the @rgommers where was this behaviour implemented in NumPy? We can probably adapt the logic from that PR to our wrapper. |
It's hard to point at a single place. This was the main PR: numpy/numpy#21626. I think we're in pretty decent shape though - some of these details may still change for NumPy 2.0, and it's still behind a switch. The key thing was to not emulate numpy's current set of casting rules. If the above are the only exceptions, we can probably punt on those "scalar + below-default-precision-arrays" cases now. |
Let's just add a point to the list of things that are not quite the same as in NumPy then |
Done in gh-140 |
Ralf has insisted over and over that we implement NEP 50. I am not sure where our typecasting is at at the moment wrt. to NEP 50 though. Having a look at NEP 50, I see that in principle we should be mostly good, as one of the desiderata in NEP 50 is
neither of which we do. That being said, we should have a look at the examples in NEP 50 and see how well we're currently doing though.
The text was updated successfully, but these errors were encountered: