-
Notifications
You must be signed in to change notification settings - Fork 33
array_api_compat.numpy.asarray(torch.Tensor)
returns a torch.Tensor
#106
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
Comments
array_api_compat.numpy.asarray(torch.Tensor)
returns a `torch.Tensorarray_api_compat.numpy.asarray(torch.Tensor)
returns a torch.Tensor
Agreed, that is a bug. This line looks wrong:
|
FWIW, this bug seems to have been introduced in 1.5, and had the correct behaviour in Also is not limited to this case, for instance I ran into this for |
What is the expected behavior for |
If the input type is one of the types mentioned in the standard (in the type signature), it should convert that input type. Otherwise, generally for array-api-compat, any behavior outside of the standard should just pass through to the library function. So in this case, asarray() should indeed convert the input because normal |
Bisected it to this commit, which made that line apply to objects with |
Yeah, I messed up asarray. Sorry about that. I have a WIP branch fixing that ,and some other dask stuff. |
OK, I'll hold off on looking at this for now so I don't step on your toes. You may want to integrate the test from https://github.com/data-apis/array-api-compat/pull/109/files. It may also be necessary to update the copy logic generally similar to data-apis/array-api-strict#15. I don't know if the "check if a copy was made" trick can work for cupy and dask, but if it can we should use it. If there end up being too many library-specific checks in the |
should work? |
Looks like 94e42df works for cupy for me. Thanks! Unfortunately, did have to nuke my cuda install, but I'm pretty confident that's unrelated. |
will this fix be released in version 1.5.1 and if so when approximately? |
I'm hoping to get a release out before the end of the week. I want to fix a few other issues that have cropped up too. |
I just released 1.5.1 with this fix (and some others). |
By the way, this still won't work for something like |
This feels like a bug to me. My expectation is that
xp.asarray
converts to an array object in thexp
namespace if that operation is supported.The text was updated successfully, but these errors were encountered: