Skip to content
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

Torch/Paddle adaptive_max_pool2d #21247

Merged
merged 2 commits into from
Aug 4, 2023
Merged

Torch/Paddle adaptive_max_pool2d #21247

merged 2 commits into from
Aug 4, 2023

Conversation

jshepherd01
Copy link
Contributor

Closes #21224

Adds adaptive_max_pool2d to the torch frontend, and also to Ivy's functional API (under the experimental folder). The only other frontend (as far as I could tell from a quick Google) to have an implementation of adaptive_max_pool2d is paddle, so I added it to that frontend as well, along with those two backends.

to torch frontend, ivy experimental API, and torch and paddle
experimental backends. Also adds unit tests and makes a small
optimisation to ivy.adaptive_avg_pool2d.
Paddle's implementation of adaptive_max_pool2d is not numerically
stable, for some reason, with very large numbers so I had to put a
minimum and maximum value in the test cases.
@github-actions
Copy link
Contributor

github-actions bot commented Aug 3, 2023

Thanks for contributing to Ivy! 😊👏
Here are some of the important points from our Contributing Guidelines 📝:
1. Feel free to ignore the run_tests (1), run_tests (2), … jobs, and only look at the display_test_results job. 👀 It contains the following two sections:
- Combined Test Results: This shows the results of all the ivy tests that ran on the PR. ✔️
- New Failures Introduced: This lists the tests that are passing on master, but fail on the PR Fork. Please try to make sure that there are no such tests. 💪
2. The lint / Check formatting / check-formatting tests check for the formatting of your code. 📜 If it fails, please check the exact error message in the logs and fix the same. ⚠️🔧
3. Finally, the test-docstrings / run-docstring-tests check for the changes made in docstrings of the functions. This may be skipped, as well. 📚
Happy coding! 🎉👨‍💻

@ivy-leaves ivy-leaves added Array API Conform to the Array API Standard, created by The Consortium for Python Data API Standards Ivy API Experimental Run CI for testing API experimental/New feature or request PaddlePaddle Backend Developing the Paddle Paddle Backend. Paddle Frontend Developing the Paddle Frontend, checklist triggered by commenting add_frontend_checklist PyTorch Frontend Developing the PyTorch Frontend, checklist triggered by commenting add_frontend_checklist Ivy Functional API labels Aug 3, 2023
@jshepherd01 jshepherd01 merged commit 951f116 into ivy-llc:master Aug 4, 2023
482 of 932 checks passed
@jshepherd01 jshepherd01 deleted the torch_adaptive_max_pool2d branch August 4, 2023 10:09
@Daniel4078
Copy link
Contributor

Well, you should implement the backend of this function for all the other frameworks in the experimental module as now all the relevant tests are failing left and right. In addition, I suppose adaptive_max_pool2d should not be placed in the experimental module in the first place and you should either implement it compositionally using existing ivy functions or ask ivy members to create the missing ivy.adaptive_max_pool2d function with complete backend support for you to use.

@jshepherd01
Copy link
Contributor Author

@Daniel4078 What happened to prompt this comment? This PR is over a month old.

To address your concerns:

Well, you should implement the backend of this function for all the other frameworks in the experimental module as now all the relevant tests are failing left and right.

I implemented it as a mixed function so that it works for all backends. At the time that I merged this, the tests for it were passing both locally and in the CI.

In addition, I suppose adaptive_max_pool2d should not be placed in the experimental module in the first place

On what basis? My understanding was that new functions always go into experimental first and then get moved into core later on, once they've been there for a while and are known to be stable.

and you should either implement it compositionally using existing ivy functions or ask ivy members to create the missing ivy.adaptive_max_pool2d function with complete backend support for you to use.

I am an ivy member, so I created the missing function myself

@Daniel4078
Copy link
Contributor

@Daniel4078 What happened to prompt this comment? This PR is over a month old.

To address your concerns:

Well, you should implement the backend of this function for all the other frameworks in the experimental module as now all the relevant tests are failing left and right.

I implemented it as a mixed function so that it works for all backends. At the time that I merged this, the tests for it were passing both locally and in the CI.

In addition, I suppose adaptive_max_pool2d should not be placed in the experimental module in the first place

On what basis? My understanding was that new functions always go into experimental first and then get moved into core later on, once they've been there for a while and are known to be stable.

and you should either implement it compositionally using existing ivy functions or ask ivy members to create the missing ivy.adaptive_max_pool2d function with complete backend support for you to use.

I am an ivy member, so I created the missing function myself

Oh, thank you for your notice, then can you please look that the failing tests of your function as you probably know what went wrong better than me. like adaptive_max_pool2d was failuring for multiple errors like AssertionError: the results from backend jax and ground truth framework torch do not match: [[[0.]]]!=[[[1.]]] for the one in experimental while there is another test with similar name torch_adaptive_max_pool2d suffers from AssertionError: returned dtype = float32, ground-truth returned dtype = bfloat16 in jax backend and RuntimeError: "adaptive_max_pool2d" not implemented for 'Half' for jax backend at the same time

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Array API Conform to the Array API Standard, created by The Consortium for Python Data API Standards Ivy API Experimental Run CI for testing API experimental/New feature or request Ivy Functional API Paddle Frontend Developing the Paddle Frontend, checklist triggered by commenting add_frontend_checklist PaddlePaddle Backend Developing the Paddle Paddle Backend. PyTorch Frontend Developing the PyTorch Frontend, checklist triggered by commenting add_frontend_checklist
Projects
None yet
Development

Successfully merging this pull request may close these issues.

torch.nn.functional.adaptive_max_pool2d
4 participants