Skip to content

[REFACTOR][TIR] Phaseout BufferRealize#18763

Merged
tlopex merged 1 commit intoapache:mainfrom
tqchen:buffer-realize
Feb 12, 2026
Merged

[REFACTOR][TIR] Phaseout BufferRealize#18763
tlopex merged 1 commit intoapache:mainfrom
tqchen:buffer-realize

Conversation

@tqchen
Copy link
Member

@tqchen tqchen commented Feb 12, 2026

This PR Phases out BufferRealize which is a legacy node in TE schedule and no longer needed here.

@gemini-code-assist
Copy link
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 by removing the BufferRealize node from the TensorIR (TIR) schedule. This change streamlines the IR representation by eliminating a legacy construct that is no longer required, simplifying the codebase and reducing maintenance overhead. The removal impacts core IR definitions, various IR processing utilities, and associated transformation passes and tests, aligning the system with a more modern and efficient IR design.

Highlights

  • Removal of BufferRealize Node: The BufferRealize node, identified as a legacy component in the TensorIR (TIR) schedule, has been completely phased out from the codebase. This involves removing its C++ and Python definitions, as well as all related helper functions and constants.
  • Updated IR Builder and Functors: All references to BufferRealize have been removed from TIR's IR builder, statement visitors, and mutators across both C++ and Python implementations. This ensures that the IR processing pipeline no longer recognizes or attempts to handle this deprecated node type.
  • Elimination of InjectRollingBuffer Pass: The InjectRollingBuffer transformation pass, which was dependent on BufferRealize, has been removed entirely. This includes its C++ implementation file and associated Python bindings and tests.
  • Test Suite Refinement: Numerous test cases that either directly tested BufferRealize functionality or included it in their IR structures have been updated or removed to reflect its deprecation and removal, ensuring the test suite remains consistent with the current IR design.

🧠 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
  • include/tvm/script/ir_builder/tir/frame.h
    • Removed RealizeFrameNode and RealizeFrame class definitions.
  • include/tvm/script/ir_builder/tir/ir.h
    • Removed the Realize function declaration.
  • include/tvm/tir/stmt.h
    • Removed BufferRealizeNode and BufferRealize class definitions.
    • Removed realize_scope and rolling_buffer_scope constants.
  • include/tvm/tir/stmt_functor.h
    • Removed VisitStmt_(const BufferRealizeNode* op) from StmtFunctor, StmtVisitor, and StmtMutator.
  • python/tvm/script/ir_builder/tir/frame.py
    • Removed the RealizeFrame class definition.
  • python/tvm/script/ir_builder/tir/ir.py
    • Removed the realize function and its import.
  • python/tvm/script/parser/core/evaluator.py
    • Removed 'realize' from the list of attributes to be ignored during evaluation.
  • python/tvm/tir/init.py
    • Removed the import for BufferRealize.
  • python/tvm/tir/functor.py
    • Removed BufferRealize from imports.
    • Removed f_visit_buffer_realize and visit_buffer_realize_ methods from PyStmtExprVisitor and PyStmtExprMutator.
  • python/tvm/tir/stmt.py
    • Removed the BufferRealize class definition.
  • python/tvm/tir/transform/transform.py
    • Removed the InjectRollingBuffer function.
  • src/relax/transform/dataflow_inplace.cc
    • Removed the VisitStmt_(const tir::BufferRealizeNode* op) method.
  • src/s_tir/analysis/sblock_buffer_access_lca_detector.cc
    • Removed the VisitStmt_(const BufferRealizeNode* op) method.
  • src/s_tir/transform/plan_update_buffer_allocation_location.cc
    • Removed the VisitStmt_(const BufferRealizeNode* op) method.
  • src/script/ir_builder/tir/frame.cc
    • Removed RealizeFrameNode::RegisterReflection() and RealizeFrameNode::ExitWithScope().
  • src/script/ir_builder/tir/ir.cc
    • Removed the Realize function definition and its FFI registration.
  • src/script/printer/tir/stmt.cc
    • Removed the DocsifyBufferRealize function and its dispatch registration.
  • src/tir/backend/adreno/texture_flatten.cc
    • Removed the VisitStmt_(const BufferRealizeNode* op) method.
  • src/tir/ir/py_functor.cc
    • Removed f_visit_buffer_realize and related dispatch logic from PyStmtExprVisitorNode and PyStmtExprMutatorNode.
  • src/tir/ir/stmt.cc
    • Removed BufferRealizeNode::RegisterReflection() and the BufferRealize constructor/registration.
  • src/tir/ir/stmt_functor.cc
    • Removed the VisitStmt_(const BufferRealizeNode* op) method from StmtVisitor and StmtMutator.
  • src/tir/ir/tir_visitor_with_path.cc
    • Removed the VisitStmt_(const BufferRealizeNode* op) method.
  • src/tir/ir/tir_visitor_with_path.h
    • Removed the declaration for VisitStmt_(const BufferRealizeNode* op).
  • src/tir/transform/inject_rolling_buffer.cc
    • Removed the entire file, eliminating the InjectRollingBuffer pass.
  • src/tir/transform/unsupported_dtype_legalize.cc
    • Removed the VisitStmt_(const BufferRealizeNode* op) method from ComputeLegalizer and StorageLegalizer.
  • tests/python/contrib/test_hexagon/test_2d_physical_buffers.py
    • Removed tvm.tir.BufferRealize from the extract_buffers function.
  • tests/python/tir-analysis/test_tir_analysis_verify_well_formed.py
    • Removed test cases related to T.realize.
  • tests/python/tir-base/test_tir_nodes.py
    • Removed the test case for tvm.tir.BufferRealize.
  • tests/python/tir-transform/test_tir_transform_inject_rolling_buffer.py
    • Removed the entire file, eliminating tests for the InjectRollingBuffer pass.
  • tests/python/tvmscript/test_tvmscript_error_report.py
    • Adjusted error line numbers and removed references to T.realize and realize_scope.
  • tests/python/tvmscript/test_tvmscript_ir_builder_tir.py
    • Removed the test_ir_builder_tir_realize function.
  • tests/python/tvmscript/test_tvmscript_printer_tir.py
    • Removed the test_buffer_realize function.
  • tests/python/tvmscript/test_tvmscript_roundtrip.py
    • Removed opt_gemm_normalize and opt_conv_tensorcore_normalize functions and their references from test parameters.
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.

Copy link
Contributor

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

Choose a reason for hiding this comment

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

Code Review

This pull request is a large-scale refactoring that phases out the legacy BufferRealize node from TIR. The changes are extensive, touching C++ headers, implementation files, Python bindings, and tests. My review of the changes confirms that the removal is consistent and thorough. All references to BufferRealize, RealizeFrame, and related attributes like realize_scope and rolling_buffer_scope have been correctly removed across the codebase. The InjectRollingBuffer transform, which depended on these legacy nodes, has also been correctly removed along with its tests. The test suite has been appropriately updated to reflect these removals. Overall, this is a clean and well-executed refactoring that improves the codebase by removing obsolete components. I have no further comments.

This PR Phases out BufferRealize which is a legacy node in
TE schedule and no longer needed here.
@tlopex tlopex merged commit 6e08d90 into apache:main Feb 12, 2026
9 checks passed
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