-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
Completed Max_unpool1d implementation #22938
Conversation
Thanks for contributing to Ivy! 😊👏 |
If you are working on an open task, please edit the PR description to link to the issue you've created. For more information, please check ToDo List Issues Guide. Thank you 🤗 |
my implementation is close to torch 2.0.1+cu118 version I don't know why gpu version of torch.max_unpool1d is different from the cpu version @AnnaTz |
I get this error when I run the test locally:
It seems the failure happens when running on cpu, so I don't understand what you mean exactly. |
Yeah, I will show you one example. |
you can see here that's torch cuda max_unpool output from the same input above which is different from the cpu version @AnnaTz |
Yeah, that's a catch I tried before to remove the repeated indices but it was not useful also the tests were giving me errors |
What kind of errors? I think you should be able to force the indices to not include identical values. We should at least know if that's the only problem (if the test passes for all other cases) before we decide what to do about it. |
output mismatch errors with torch backend if tried to exclude the repeated indices, as you can see so I didn't add the excluding part to the implementation . |
I tried as many tests as I could but the only errors that appeared to me were output mismatching errors with of course torch backend . |
Also I didn't complete the paddle backend implementation cuz the paddle function was giving me errors also and when I tried it on colab with |
I'm inclined to say we will need a compositional implementation for this 💀 |
->I'm inclined to say we will need a compositional implementation for this 💀 |
Do you mean compositional implementation using ivy API instead of backend specific API, wouldn't that affect the performance 😕 |
We need the ivy function to work consistently for all backends in all cases. The native torch function does not work as expected in the repeated indices case, and the paddle function is not implemented in some versions and giving errors in others. So, we need an ivy function implementation to cover these. |
Also, about that, according to what @vedpatwardhan has told me, I think the implementation we have for the numpy, jax and tensorflow backends could be replaced by an ivy composition. It seems that we are doing the exact same operations in all these backends, so it would be better to avoid code repetition. |
if we want we can ignore the torch max_unpool1d backend implementation and consider custom torch implementation like jax and numpy case. |
But I agree with you in order to reduce the code repetition we need compositional implementation |
We should not completely ignore the native torch function, because in the cases it does work it will be faster than a composition. Hence, we need to convert |
I think it will be quite simple since you have already implemented the backend functions compositionally. I think you will mainly copy that and replace native calls with ivy calls. |
sorry I didn't mean to edit your comment so sorry @AnnaTz 😄 |
it's done @AnnaTz |
indices: ivy.Array, | ||
kernel_size: Union[Tuple[int], int], | ||
strides: Union[int, Tuple[int]] = None, | ||
padding: Union[int, Tuple[int]] = 0, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, please remove the docs/demos
changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I remove them there will be conflicts with the main branch
if padding > (kernel_size[0] // 2): | ||
padding = 0 | ||
|
||
values, indices = torch.nn.functional.max_pool1d( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sherry30 are we allowed to use native functions in testing?
output[indices] = values | ||
if revert: | ||
output = output.permute_dims([0, 2, 1]) | ||
return output | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code looks good overall. The only thing remaining is to add the partial torch backend.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you mean by partial torch backend? I did not get what you meant here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Description
Completed max_unpool1d function implementation I didn't add paddle backend implementation cuz paddle.max_unpool1d had some errors related paddle itself