[FIX][TIRx] Remap typed buffer expressions during specialization - #20090
Open
jinhongyii wants to merge 1 commit into
Open
[FIX][TIRx] Remap typed buffer expressions during specialization#20090jinhongyii wants to merge 1 commit into
jinhongyii wants to merge 1 commit into
Conversation
Contributor
Author
|
@tvm-bot rerun |
1 similar comment
Contributor
Author
|
@tvm-bot rerun |
jinhongyii
force-pushed
the
fix/tirx-specialize-typed-buffer-expr
branch
from
August 5, 2026 19:11
529d85a to
57e1600
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
TIRx buffers are represented by typed variables. When
PrimFunc.specializeremaps a buffer, every expression that refers to itsBufferVarmust be remapped as well.PrimFuncSpecializer::VisitExpr_(VarNode*)returned variables that were not in the scalar specialization map unchanged. This bypassed the baseStmtExprMutator, which is responsible for recognizing and remapping typed buffer variables. As a result, an alias buffer could retain the original data variable after specialization instead of referring to the specialized buffer.Example
Consider a buffer alias that shares
A.data:The specialized function should still preserve the alias:
Before this PR,
A_alias.datacould retain the pre-specializationBufferVar. After this PR, it is remapped to the specializedA.data.What changed
VarNodeexpressions to the baseStmtExprMutator.Tests
python -m pytest tests/python/tirx-base/test_tir_specialize.py -q(11 passed)pre-commit run --files src/tirx/ir/specialize.cc tests/python/tirx-base/test_tir_specialize.pyPorted from mlc-ai/tvm@14bf144.