gemini-code-assist[bot] commented on PR #18886:
URL: https://github.com/apache/tvm/pull/18886#issuecomment-4015021735

   ## Summary of Changes
   
   Hello, I'm Gemini Code Assist[^1]! 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 revamps the Common Subexpression Elimination 
(CSE) pass within the TIR (Tensor IR) framework. The core change introduces a 
robust two-phase architecture, separating the analysis and planning of CSE 
opportunities from their mechanical application. This new design aims to 
improve the clarity, maintainability, and efficiency of the CSE pass by 
eliminating complex cascade loops and enabling more precise control over 
variable introduction and expression substitution.
   
   ### Highlights
   
   * **Two-Phase Architecture**: Rewrote TIR Common Subexpression Elimination 
(CSE) with a two-phase design: CSEPlanner (read-only visitor for plan 
generation) and CSERewriter (mechanical mutator for applying changes).
   * **Simplified Architecture**: Replaced interleaved analysis/mutation with 
clean CSEPlanner and CSERewriter classes.
   * **No Cascade Loop**: Implemented shallower-first processing with 
representation propagation, eliminating the need for cascade loops in CSE 
resolution.
   * **Incremental DAG Construction**: Computed expression depth, children, and 
consumed counts during a single bottom-up scan.
   * **No Single-Use Bindings**: Added consumed count tracking to prevent 
introducing CSE variables that would only be used once.
   * **Unified Insertion**: Handled all insertion contexts uniformly via 
VisitStmt and SeqStmt flattening.
   * **API Changes**: Renamed CommonSubexprElimTIR to CommonSubexprElim, 
removed enable_cse_tir and identify_equiv_terms parameters, and added T.bind as 
a lowercase alias for T.Bind.
   * **Code Refactoring**: Moved old CSE tools used by cache_index to 
cache_index_helpers.{cc,h} and removed the unused arith.detect_common_subexpr 
API.
   
   🧠 **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](https://codeassist.google/code-review/login) to enable Memory in your 
admin console.**
   
   <details>
   <summary><b>Changelog</b></summary>
   
   * **include/tvm/tir/transform.h**
       * The CommonSubexprElimTIR function was renamed to CommonSubexprElim.
       * The enable_cse_tir and identify_equiv_terms parameters were removed 
from the CommonSubexprElim function signature.
       * The documentation for the CommonSubexprElim pass was updated to 
reflect the use of Bind statements.
   * **python/tvm/arith/__init__.py**
       * The import of detect_common_subexpr was removed.
   * **python/tvm/arith/pattern.py**
       * The detect_common_subexpr function and its related PrimExpr import 
were removed.
   * **python/tvm/s_tir/backend/adreno/pipeline.py**
       * The call to tir.transform.CommonSubexprElimTIR was updated to 
tir.transform.CommonSubexprElim and its parameters were removed.
       * The CSE pass is now conditionally appended based on 
tir.disable_cse_tir.
   * **python/tvm/s_tir/pipeline.py**
       * The call to tir.transform.CommonSubexprElimTIR was updated to 
tir.transform.CommonSubexprElim and its parameters were removed.
       * The CSE pass is now conditionally appended based on 
tir.disable_cse_tir.
   * **python/tvm/script/ir_builder/tir/ir.py**
       * A lowercase alias bind was added for Bind.
       * The bind alias was added to the __all__ export list.
   * **python/tvm/tir/transform/transform.py**
       * The Python binding for CommonSubexprElimTIR was renamed to 
CommonSubexprElim.
       * The enable_cse_tir and identify_equiv_terms parameters were removed 
from the Python function signature.
   * **src/arith/detect_common_subexpr.cc**
       * This file, containing the old DetectCommonSubExpr implementation, was 
removed.
   * **src/s_tir/schedule/primitive/cache_index.cc**
       * The include path for common_subexpr_elim_tools.h was updated to 
cache_index_helpers.h.
   * **src/s_tir/schedule/primitive/cache_index_helpers.cc**
       * A new file was added, implementing analysis tools and utility 
functions for cache_index, extracted from the old common_subexpr_elim_tools.cc.
   * **src/tir/ir/transform.cc**
       * The tir.enable_equiv_terms_in_cse_tir pass configuration option was 
removed.
   * **src/tir/transform/common_subexpr_elim.cc**
       * The entire implementation of the CSE pass was rewritten to a two-phase 
architecture (CSEPlanner and CSERewriter).
       * The CommonSubexprElimTIR pass was renamed to CommonSubexprElim and its 
parameters were removed.
       * Detailed documentation was added for the new architecture, eligibility 
rules, and scope tree.
   * **src/tir/transform/common_subexpr_elim.h**
       * This header file, containing the old CommonSubexpressionEliminator 
class, was removed.
   * **src/tir/transform/common_subexpr_elim_tools.cc**
       * This file, containing the old CSE analysis tools, was removed. Its 
relevant parts were moved to cache_index_helpers.cc.
   * **src/tir/transform/common_subexpr_elim_tools.h**
       * The header file was renamed to 
src/s_tir/schedule/primitive/cache_index_helpers.h and its contents were 
adapted to serve as helpers for cache_index.
       * Removed UsesVarName class, PrintComputationTable, MaybeValue, 
PredicateIntroVarForComputation, and VectorMap utilities.
       * Updated include paths for support/ordered_map.h.
   * **tests/python/arith/test_arith_detect_cse.py**
       * This test file was removed.
   * **tests/python/tir-transform/test_tir_transform_common_subexpr_elim.py**
       * Existing tests were updated to use the new CommonSubexprElim pass 
without the removed parameters.
       * New test cases were added covering basic multi-level CSE, 
single-branch and both-branch if CSE, cascade CSE, no duplication scenarios, 
deterministic output, CSE inside and across for loops, handling of BufferLoad 
and Call expressions, nested if scope, multiple independent CSE candidates, if 
condition CSE, and preventing single-use bindings.
   </details>
   
   <details>
   <summary><b>Activity</b></summary>
   
   * The pull request introduces 15 new test cases covering various scenarios 
for the revamped CSE pass.
   * The build process successfully passed.
   * Ruff lint checks were successfully passed.
   </details>
   
   <details>
   <summary><b>Using Gemini Code Assist</b></summary>
   <br>
   
   The full guide for Gemini Code Assist can be found on our [documentation 
page](https://developers.google.com/gemini-code-assist/docs/review-github-code),
 here are some quick tips.
   
   <b>Invoking Gemini</b>
   
   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.
   
   <b>Customization</b>
   
   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](https://developers.google.com/gemini-code-assist/docs/customize-gemini-behavior-github).
   
   <b>Limitations & Feedback</b>
   
   Gemini Code Assist may make mistakes. Please leave feedback on any instances 
where its feedback is incorrect or counter productive. You can react with 
:thumbsup: and :thumbsdown: 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](https://google.qualtrics.com/jfe/form/SV_2cyuGuTWsEw84yG).
   
   <b>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](https://cloud.google.com/products/gemini/code-assist).</b>
   </details>
   
   
   [^1]: Review the [Privacy Notices](https://policies.google.com/privacy), 
[Generative AI Prohibited Use 
Policy](https://policies.google.com/terms/generative-ai/use-policy), [Terms of 
Service](https://policies.google.com/terms), and learn how to configure Gemini 
Code Assist in GitHub 
[here](https://developers.google.com/gemini-code-assist/docs/customize-gemini-behavior-github).
 Gemini can make mistakes, so double check it and [use code with 
caution](https://support.google.com/legal/answer/13505487).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to