Skip to content

feat: add CheckedOpRewritePattern & CheckedOpTraitRewritePattern #960

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

Merged
merged 9 commits into from
May 21, 2025

Conversation

avik-pal
Copy link
Collaborator

  • supportsDynamicShapes() -- opt in for patterns that support dynamic shapes. Once all patterns do we can switch the default
  • disablePatternAttrName() -- allows providing a UnitAttr to the enclosing funcOpInterface to disable patterns. defaults to "enzymexla.disable_hlo_opts"

@avik-pal avik-pal requested a review from wsmoses May 17, 2025 19:08
@avik-pal avik-pal marked this pull request as ready for review May 17, 2025 19:08
@avik-pal avik-pal force-pushed the ap/optimization_overrides branch from c9d0521 to a935b8a Compare May 18, 2025 04:20
@wsmoses wsmoses requested a review from ftynse May 18, 2025 07:27
Copy link
Member

@wsmoses wsmoses left a comment

Choose a reason for hiding this comment

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

didn't check all the patterns, but seems fine otherwise.

I'll note that it seems like a lot of the patterns already ought support dynamic, but we can follow up on that in a subsequent PR

if (res.failed())
return res;

if (!((Child *)this)->supportsDynamicShapes()) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't see much value in CRTP here. The classes already have a vtable and we get to patterns through a vitrual call. A couple more won't change much, and I don't think the pattern infra cost is dominated by virtual calls. Maintainability-wise, it will be easier without.

Also, it may be worth it to declare matchAndRewrite final.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@wsmoses what do you think?

Copy link
Member

Choose a reason for hiding this comment

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

I'm okay either way, slight pref to leave as CRTP for ease/perf [esp since we already have]

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

In that case we can probably merge. All the other comments should have been addressed

@avik-pal avik-pal merged commit 3ec588c into main May 21, 2025
10 checks passed
@avik-pal avik-pal deleted the ap/optimization_overrides branch May 21, 2025 15:06
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.

3 participants