[Relax][PyTorch] Add support for decomposed operators and fix IR of ops tests(4)#18414
Conversation
Summary of ChangesHello @tlopex, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly advances the PyTorch frontend's capability to handle and verify decomposed operators within its intermediate representation (IR). By enabling decomposition testing and refining the expected IR for numerous operations such as Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request updates several tests in test_frontend_from_exported_program.py to use decomposed PyTorch operators by enabling run_ep_decomposition. The expected Relax IR is updated to reflect the decomposed operator implementations. The changes for operators like std, take, one_hot, and various zeros/ones ops are correct and align with the goal of the PR. I have one suggestion to improve the consistency of the expected IR for zero-creation operators in the tests.
| ) -> R.Tuple(R.Tensor((5,), dtype="float32")): | ||
| with R.dataflow(): | ||
| lv: R.Tensor((5,), dtype="float32") = R.zeros_like(inp_0, dtype="void") | ||
| lv: R.Tensor((5,), dtype="float32") = R.zeros(R.shape([5]), dtype="float32") |
There was a problem hiding this comment.
For consistency with other tests for zero-creation operators like test_zeros, it would be better to use R.full here. torch.empty_like is decomposed to aten.zeros, and in other tests torch.zeros is decomposed to aten.full which is then translated to R.full. Using R.full directly would make the expected IR more canonical and consistent across these tests.
| lv: R.Tensor((5,), dtype="float32") = R.zeros(R.shape([5]), dtype="float32") | |
| lv: R.Tensor((5,), dtype="float32") = R.full(R.shape([5]), R.const(0.0, "float32"), dtype="float32") |
|
cc @mshr-h |
This pr fixes ops like
prod,var,std,take,flip,unflattenand so on