-
Notifications
You must be signed in to change notification settings - Fork 14
refactor(pass): Remove Custom1/Custom2 and identity pass; rename XPlatform to PTOAS #114
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
Conversation
lyfne123
commented
Jan 31, 2026
- Remove OptimizationStrategy.Custom1 and Custom2 and their pass configs
- Remove identity pass: delete identity_pass.cpp, Identity() from passes.h, identity binding from passes.cpp and passes.pyi, and from CMakeLists
- Rename XPlatform to PTOAS in pass_manager, tests, and docs
- Update test_pass_manager: use Default/PTOAS only; drop IdentityPass assertions
- Update 10-pass_manager.md and 12-pto_codegen.md for new strategies
…tform to PTOAS - Remove OptimizationStrategy.Custom1 and Custom2 and their pass configs - Remove identity pass: delete identity_pass.cpp, Identity() from passes.h, identity binding from passes.cpp and passes.pyi, and from CMakeLists - Rename XPlatform to PTOAS in pass_manager, tests, and docs - Update test_pass_manager: use Default/PTOAS only; drop IdentityPass assertions - Update 10-pass_manager.md and 12-pto_codegen.md for new strategies
Summary of ChangesHello @lyfne123, 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 refactors the pass management system by removing obsolete and test-specific optimization strategies ( Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request is a nice refactoring that simplifies the pass management system. It correctly removes the Custom1, Custom2, and identity passes, and consistently renames the XPlatform strategy to PTOAS across the codebase, including C++ sources, Python bindings, documentation, and tests. The change to make the Default strategy a full pipeline is also clearly implemented. The code is clean and the changes are well-contained. I've only found a minor naming inconsistency in some of the test files, which I've commented on. Overall, great work on improving the code's clarity and maintainability.
|
|
||
| ```python | ||
| def test_run_passes_on_program_with_custom2_strategy(self): | ||
| def test_run_passes_on_program_with_ptoa_strategy(self): |
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.
For consistency with the PTOAS enum, it would be better to name this test function test_run_passes_on_program_with_ptoas_strategy. I've noticed this ptoa vs ptoas inconsistency in a few places.
| def test_run_passes_on_program_with_ptoa_strategy(self): | |
| def test_run_passes_on_program_with_ptoas_strategy(self): |
| def test_pass_manager_get_strategy_custom1(self): | ||
| """Test getting Custom1 strategy PassManager.""" | ||
| pm = ir.PassManager.get_strategy(ir.OptimizationStrategy.Custom1) | ||
| def test_pass_manager_get_strategy_ptoa(self): |
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.
| pm_ptoa = ir.PassManager.get_strategy(ir.OptimizationStrategy.PTOAS) | ||
|
|
||
| # Should have different strategies | ||
| assert pm_custom1.strategy != pm_custom2.strategy | ||
| assert pm_default.strategy != pm_ptoa.strategy | ||
|
|
||
| # Should have different pass counts | ||
| assert len(pm_custom1.passes) < len(pm_custom2.passes) | ||
| # Default has 4 passes (InsertSync), PTOAS has 3 | ||
| assert len(pm_default.passes) == 4 | ||
| assert len(pm_ptoa.passes) == 3 | ||
|
|
||
| # Verify pass names are properly configured | ||
| assert pm_custom1.get_pass_names() == ["IdentityPass_1"] | ||
| assert pm_custom2.get_pass_names() == ["IdentityPass_1", "IdentityPass_2"] | ||
| assert pm_default.get_pass_names() == ["InitMemRef", "MemoryReuse", "InsertSync", "AddAlloc"] | ||
| assert pm_ptoa.get_pass_names() == ["InitMemRef", "MemoryReuse", "AddAlloc"] |
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.
To maintain consistency with the PTOAS enum name, it's better to use pm_ptoas for the variable name.
| pm_ptoa = ir.PassManager.get_strategy(ir.OptimizationStrategy.PTOAS) | |
| # Should have different strategies | |
| assert pm_custom1.strategy != pm_custom2.strategy | |
| assert pm_default.strategy != pm_ptoa.strategy | |
| # Should have different pass counts | |
| assert len(pm_custom1.passes) < len(pm_custom2.passes) | |
| # Default has 4 passes (InsertSync), PTOAS has 3 | |
| assert len(pm_default.passes) == 4 | |
| assert len(pm_ptoa.passes) == 3 | |
| # Verify pass names are properly configured | |
| assert pm_custom1.get_pass_names() == ["IdentityPass_1"] | |
| assert pm_custom2.get_pass_names() == ["IdentityPass_1", "IdentityPass_2"] | |
| assert pm_default.get_pass_names() == ["InitMemRef", "MemoryReuse", "InsertSync", "AddAlloc"] | |
| assert pm_ptoa.get_pass_names() == ["InitMemRef", "MemoryReuse", "AddAlloc"] | |
| pm_ptoas = ir.PassManager.get_strategy(ir.OptimizationStrategy.PTOAS) | |
| # Should have different strategies | |
| assert pm_default.strategy != pm_ptoas.strategy | |
| # Default has 4 passes (InsertSync), PTOAS has 3 | |
| assert len(pm_default.passes) == 4 | |
| assert len(pm_ptoas.passes) == 3 | |
| # Verify pass names are properly configured | |
| assert pm_default.get_pass_names() == ["InitMemRef", "MemoryReuse", "InsertSync", "AddAlloc"] | |
| assert pm_ptoas.get_pass_names() == ["InitMemRef", "MemoryReuse", "AddAlloc"] |
|
|
||
| def test_run_passes_on_program_with_custom2_strategy(self): | ||
| """Test running PassManager with Custom2 strategy on a Program.""" | ||
| def test_run_passes_on_program_with_ptoa_strategy(self): |
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.