Skip to content

Conversation

@lyfne123
Copy link
Contributor

  • 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
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @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 (Custom1, Custom2, and Identity pass) and standardizing the naming of the XPlatform strategy to PTOAS. These changes aim to simplify the codebase, improve maintainability, and provide clearer, more meaningful optimization pipelines for users. The Default strategy has also been updated to include a comprehensive set of core passes, ensuring a more robust baseline.

Highlights

  • Streamlined Optimization Strategies: Removed Custom1 and Custom2 optimization strategies, simplifying the pass management system.
  • Removed Identity Pass: The Identity pass, previously used for testing, has been completely removed from the codebase, including its C++ implementation, Python bindings, and documentation.
  • Renamed XPlatform to PTOAS: The XPlatform optimization strategy has been renamed to PTOAS (PTO assembly optimization), improving clarity and consistency.
  • Updated Default Strategy: The Default optimization strategy now includes a standard set of passes: InitMemRef, MemoryReuse, InsertSync, and AddAlloc.
  • Documentation and Test Alignment: All relevant documentation and unit tests have been updated to reflect the removal of Custom1/Custom2 and Identity pass, and the renaming of XPlatform to PTOAS.

🧠 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 Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a 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):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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.

Suggested change
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):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For consistency with the PTOAS enum, it would be better to name this test function test_pass_manager_get_strategy_ptoas.

Suggested change
def test_pass_manager_get_strategy_ptoa(self):
def test_pass_manager_get_strategy_ptoas(self):

Comment on lines +89 to +100
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"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

To maintain consistency with the PTOAS enum name, it's better to use pm_ptoas for the variable name.

Suggested change
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):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For consistency with the PTOAS enum, it would be better to name this test function test_run_passes_on_program_with_ptoas_strategy.

Suggested change
def test_run_passes_on_program_with_ptoa_strategy(self):
def test_run_passes_on_program_with_ptoas_strategy(self):

@lyfne123 lyfne123 merged commit 8e71317 into hw-native-sys:main Jan 31, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant