[TVMScript][Bug] Add test case for missing symbolic bounds#16877
Merged
vinx13 merged 1 commit intoapache:mainfrom Apr 16, 2024
Merged
[TVMScript][Bug] Add test case for missing symbolic bounds#16877vinx13 merged 1 commit intoapache:mainfrom
vinx13 merged 1 commit intoapache:mainfrom
Conversation
Because Relax struct inference is performed while the function is being built, all constraints on symbolic variables that are used for simplifications must be provided to the analyzer. This is not currently the case, nor is there a clear way to fix this issue.
vinx13
approved these changes
Apr 16, 2024
Lunderberg
added a commit
to Lunderberg/tvm
that referenced
this pull request
Apr 28, 2024
As reported in apache#16877, shape inference performed during a Relax transformation may produce different results than shape inference performed during TVMScript parsing. While Relax transformations call `Analyzer::MarkGlobalNonNegValue` for each shape expression, this is not provided during TVMScript parsing. As a result, output shapes that are conditional on the sign of a variable may produce different results when simplifying. This commit provides a partial resolution for this issue. Where prior to this commit, the TVMScript parser generated a `tir.Var` for each symbolic variable, the TVMScript parser now provides a `tir.SizeVar` for symbolic variables that are defined in contexts that require a non-negative size.
yongwww
pushed a commit
to yongwww/tvm
that referenced
this pull request
Mar 17, 2025
As reported in apache#16877, shape inference performed during a Relax transformation may produce different results than shape inference performed during TVMScript parsing. While Relax transformations call `Analyzer::MarkGlobalNonNegValue` for each shape expression, this is not provided during TVMScript parsing. As a result, output shapes that are conditional on the sign of a variable may produce different results when simplifying. This commit provides a partial resolution for this issue. Where prior to this commit, the TVMScript parser generated a `tir.Var` for each symbolic variable, the TVMScript parser now provides a `tir.SizeVar` for symbolic variables that are defined in contexts that require a non-negative size.
yongwww
pushed a commit
to yongwww/tvm
that referenced
this pull request
Mar 17, 2025
As reported in apache#16877, shape inference performed during a Relax transformation may produce different results than shape inference performed during TVMScript parsing. While Relax transformations call `Analyzer::MarkGlobalNonNegValue` for each shape expression, this is not provided during TVMScript parsing. As a result, output shapes that are conditional on the sign of a variable may produce different results when simplifying. This commit provides a partial resolution for this issue. Where prior to this commit, the TVMScript parser generated a `tir.Var` for each symbolic variable, the TVMScript parser now provides a `tir.SizeVar` for symbolic variables that are defined in contexts that require a non-negative size.
yongwww
pushed a commit
to yongwww/tvm
that referenced
this pull request
Mar 17, 2025
As reported in apache#16877, shape inference performed during a Relax transformation may produce different results than shape inference performed during TVMScript parsing. While Relax transformations call `Analyzer::MarkGlobalNonNegValue` for each shape expression, this is not provided during TVMScript parsing. As a result, output shapes that are conditional on the sign of a variable may produce different results when simplifying. This commit provides a partial resolution for this issue. Where prior to this commit, the TVMScript parser generated a `tir.Var` for each symbolic variable, the TVMScript parser now provides a `tir.SizeVar` for symbolic variables that are defined in contexts that require a non-negative size.
tqchen
added a commit
to tqchen/tvm
that referenced
this pull request
Feb 26, 2026
TVMScript parser now uses `tir.SizeVar` (known non-negative) instead of `tir.Var` for symbolic variables defined in size contexts (R.Tensor shapes, R.Shape), while keeping `tir.Var` for R.Prim arguments. This aligns TVMScript parsing with Relax transformations that call `Analyzer::MarkGlobalNonNegValue`, fixing shape inference differences between parsing and transformation passes (Issue apache#16877).
tqchen
added a commit
to tqchen/tvm
that referenced
this pull request
Feb 26, 2026
TVMScript parser now uses `tir.SizeVar` (known non-negative) instead of `tir.Var` for symbolic variables defined in size contexts (R.Tensor shapes, R.Shape), while keeping `tir.Var` for R.Prim arguments. This aligns TVMScript parsing with Relax transformations that call `Analyzer::MarkGlobalNonNegValue`, fixing shape inference differences between parsing and transformation passes (Issue apache#16877).
tqchen
added a commit
to tqchen/tvm
that referenced
this pull request
Feb 27, 2026
TVMScript parser now uses `tir.SizeVar` (known non-negative) instead of `tir.Var` for symbolic variables defined in size contexts (R.Tensor shapes, R.Shape), while keeping `tir.Var` for R.Prim arguments. This aligns TVMScript parsing with Relax transformations that call `Analyzer::MarkGlobalNonNegValue`, fixing shape inference differences between parsing and transformation passes (Issue apache#16877).
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.
Because Relax struct inference is performed while the function is being built, all constraints on symbolic variables that are used for simplifications must be provided to the analyzer. This is not currently the case, nor is there a clear way to fix this issue.
This PR adds a failing unit test to document this limitation.