Skip to content

fix: add a optimization barrier to prevent folding#2367

Open
avik-pal wants to merge 1 commit intomainfrom
ap/convert_all_constants
Open

fix: add a optimization barrier to prevent folding#2367
avik-pal wants to merge 1 commit intomainfrom
ap/convert_all_constants

Conversation

@avik-pal
Copy link
Copy Markdown
Collaborator

No description provided.

auto newConstant =
stablehlo::ConstantOp::create(rewriter, op.getLoc(), splatAttr);
// Insert a optimization barrier to prevent the constant from being folded
auto barrier = stablehlo::OptimizationBarrierOp::create(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can you explain why we want this?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This is effectively a "this large constant makes the file too big to load, so lets do an illegal transform to make it readable". Once we remove the large non-splatted constant there is now a chance that the new constant gets folded.

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.

2 participants