[TIR] Update symbolic index term order in loop fusion#18406
[TIR] Update symbolic index term order in loop fusion#18406wrongtest-intellif wants to merge 2 commits intoapache:mainfrom
Conversation
Summary of ChangesHello @wrongtest-intellif, 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 refines the symbolic index term ordering within the loop fusion mechanism of the TIR schedule. The adjustment aims to simplify generated expressions, particularly in symbolic contexts, which previously led to complex expression trees and hindered analysis like region estimation. By ensuring that stride terms maintain an order consistent with the fused loops, the change improves the efficiency and clarity of the intermediate representation, making subsequent lowering steps more robust. 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 addresses a symbolic simplification issue within the fuse primitive in TIR. The changes modify the order of multiplication for calculating the fused loop extent and the strides for substituted loop variables. By making the order of terms consistent with the fused loop order, the resulting expression trees for loop variable bindings become simpler, which aids downstream analysis and simplification passes, especially with symbolic shapes. A new test case is added to verify this fix for a 2D tiling scenario, confirming that the generated code is now simpler as expected. The changes are logical, well-contained, and effectively solve the described problem.
6988cee to
dae0bd4
Compare
This change just keep stride terms order the same with fused loop order in
fuseprimitive. In symbolic circumstances, previous form suffer from simplification issues and would make the expression tree much complex in following lowering steps.Take [M, N] tiling as an example, the previous binding form after
would be like (i_0_j_0_fused in
[0, ceildiv(M, 64) * ceildiv(N, 16)]instead of more simple version
This is because unfortunately we do not know
ceildiv(N, 16) * ceildiv(M, 64) == ceildiv(M, 64) * ceildiv(N, 16)in rule based simplifications. And then certain analysis (for example, region estimation) may fail to give concise estimations, due to complex dynamic expression trees.