Skip to content

[REFACTOR][TEST] Migrate tir-transform tests from TE to TVMScript#18805

Merged
tqchen merged 4 commits into
apache:mainfrom
tqchen:migrate-te-tir-transform
Feb 21, 2026
Merged

[REFACTOR][TEST] Migrate tir-transform tests from TE to TVMScript#18805
tqchen merged 4 commits into
apache:mainfrom
tqchen:migrate-te-tir-transform

Conversation

@tqchen

@tqchen tqchen commented Feb 21, 2026

Copy link
Copy Markdown
Member

This PR migrates te.var/te.compute usage to direct tvm.tir.Var
and PrimFunc construction in tir-transform test files.

This PR migrates te.var/te.compute usage to direct tvm.tir.Var
and PrimFunc construction in tir-transform test files.
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @tqchen, 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 undertakes a significant refactoring effort within the tir-transform test suite. The core change involves transitioning from the older tvm.te (Tensor Expression) API to the more modern tvm.tir (Tensor IR) API for defining variables and constructing primitive functions. This modernization ensures that the tests are consistent with the latest TVM infrastructure, making them more robust and easier to maintain in the long run.

Highlights

  • API Migration: Migrated te.var and te.compute usage to tvm.tir.Var and PrimFunc construction across several tir-transform test files.
  • Dependency Cleanup: Removed tvm.te and tvm.topi imports from the refactored test files, streamlining dependencies.
  • Test Modernization: Updated test setups to align with the current tvm.tir infrastructure, improving consistency and maintainability of the test suite.

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

Changelog
  • tests/python/tir-transform/test_tir_transform_common_subexpr_elim.py
    • Removed tvm.te and tvm.topi imports.
    • Replaced te.var calls with tvm.tir.Var with explicit int32 dtype.
  • tests/python/tir-transform/test_tir_transform_lower_intrin.py
    • Removed tvm.te import.
    • Refactored check_value function to use tvm.tir.decl_buffer and tvm.tir.PrimFunc for test setup instead of te.placeholder and te.compute.
    • Replaced te.var calls with tvm.tir.Var with explicit dtypes.
  • tests/python/tir-transform/test_tir_transform_prim_func_pass.py
    • Removed tvm.te import.
    • Replaced te.var calls with tvm.tir.Var with explicit int32 dtype.
  • tests/python/tir-transform/test_tir_transform_remove_no_op.py
    • Removed tvm.te import.
    • Replaced te.var calls with tvm.tir.Var with explicit int32 dtype.
Activity
  • No specific activity has been recorded for this pull request yet.
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.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

The pull request successfully refactors several TIR transform tests to use tvm.tir.Var and manual PrimFunc construction instead of the legacy te.var and te.compute APIs. This aligns with the goal of migrating TIR tests towards TVMScript and direct TIR construction, which improves maintainability and reduces dependency on the TE stack for TIR-level testing. However, in tests/python/tir-transform/test_tir_transform_lower_intrin.py, the removal of the te import while maintaining references to tvm.te in the test functions will cause runtime AttributeError failures. These references should be updated to tvm.tir to complete the migration.

Comment thread tests/python/tir-transform/test_tir_transform_lower_intrin.py
Fix leftover tvm.te.floordiv/floormod/max calls that should use tvm.tir.
@tqchen

tqchen commented Feb 21, 2026

Copy link
Copy Markdown
Member Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

The pull request successfully refactors several TIR transform tests to remove dependencies on the legacy tvm.te (Tensor Expression) API, moving towards direct tvm.tir construction and TVMScript-style testing. This is a positive change for the long-term maintainability of the TIR codebase. The refactoring of the check_value helper in test_tir_transform_lower_intrin.py correctly implements the manual construction of a PrimFunc with explicit buffer loading and storing, replacing the previous te.compute logic. The changes are consistent across all modified files and follow TVM's modern TIR testing practices.

This PR migrates test files in arith/, tir-base/, tir-analysis/, and ir/
to use direct TIR construction (tvm.tir.Var, tvm.tir.floordiv, etc.)
instead of TE sugar (te.var, tvm.te.floordiv, etc.).
This commit fixes black formatting errors reported by lint CI.
@tqchen

tqchen commented Feb 21, 2026

Copy link
Copy Markdown
Member Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

The pull request successfully refactors multiple test files to remove dependencies on the te (Tensor Expression) namespace, favoring direct tvm.tir usage and TVMScript. This aligns with the ongoing effort to modernize TVM's testing infrastructure. The changes are consistent across the arithmetic, IR, and TIR analysis/transform modules, and the logic of the tests remains intact. The refactoring of the check_value helper in test_tir_transform_lower_intrin.py is particularly noteworthy as it replaces high-level te.compute with explicit TIR constructs (nested Let bindings and manual loop construction), providing better isolation for testing TIR transformations. No significant issues or regressions were identified during the review.

@tqchen tqchen merged commit c0828bc into apache:main Feb 21, 2026
9 checks passed
AshwiniBokka pushed a commit to AshwiniBokka/tvm that referenced this pull request Feb 22, 2026
…ache#18805)

This PR migrates te.var/te.compute usage to direct tvm.tir.Var
and PrimFunc construction in tir-transform test files.
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