Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hello,
my goal is to work around pytorch/pytorch#34452 .
Currently, the last 2 lines fail
The patch lets this test pass. I also ran the testsuite, and it seems to work as well after as before the patch (one jax test fails because of a relative error 1.5295117e-07 > 1e-07 and the first tensorflow test runs forever, but the pytorch tests all pass, which seems the most relevant).
I don't claim that it is the one right way to do it (how do you detect "something that torch.as_tensor likes" more generally than ndarray? Just
try
?). Also, I guess eagerpy is not meant to allow interoperability between types from different backends. However, in some cases, I need to generate some indices, I can easily do it with whatever backend, but I don't know how to conveniently build them with "the same backend as the input", and I see that you already use np.arange to generate an index for a torch.tensor in onehot_like, so it looks acceptable.It does not solve the same issue with a list or whatever other iterable, but then I can just build a numpy array from those, I only need one way to do this (preferably not one as silly as
t[i,]
). I think currently the official way to do it may bet[t.from_numpy(i)]
.