You are viewing a plain text version of this content. The canonical link for it is here.
Posted to discuss-archive@tvm.apache.org by "tqchen (via GitHub)" <gi...@apache.org> on 2026/06/21 22:26:43 UTC
[PR] [REFACTOR][RELAX] Phase out Relax PrimType [tvm]
tqchen opened a new pull request, #19858:
URL: https://github.com/apache/tvm/pull/19858
Summary:
- Remove the Relax-specific PrimType node/API and use canonical ir.PrimType for dtype-only scalar types.
- Update parser, printer, analysis, op inference/legalization, and tests to avoid value-bearing PrimType semantics.
- Preserve scalar values where needed by reading PrimValue expressions directly instead of storing values in the type.
Validation:
- cmake --build build -j$(nproc)
- cmake --build build --target cpptest -j$(nproc)
- PYTHONPATH=python:.local/python LD_LIBRARY_PATH=/home/tqchen/miniforge3/lib:build python3 -m pytest tests/python/relax/test_type.py tests/python/relax/test_expr.py tests/python/relax/test_op_binary.py tests/python/relax/test_tvmscript_parser.py tests/python/relax/test_tvmscript_printer_relax.py tests/python/relax/test_analysis_type_analysis.py tests/python/relax/test_blockbuilder_core.py tests/python/relax/test_ast_printer.py tests/python/relax/test_op_manipulate.py tests/python/relax/test_op_index.py tests/python/tvmscript/test_tvmscript_parser_tir.py tests/python/tirx-base/test_tir_specialize.py -q
- LD_LIBRARY_PATH=/home/tqchen/miniforge3/lib:build ./cpptest --gtest_filter=NestedMsg.*
- pre-commit run --files $(git diff --name-only HEAD~1)
--
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: discuss-archive-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: discuss-archive-unsubscribe@tvm.apache.org
For additional commands, e-mail: discuss-archive-help@tvm.apache.org
Re: [PR] [REFACTOR][RELAX] Phase out Relax PrimType [tvm]
Posted by "tqchen (via GitHub)" <gi...@apache.org>.
tqchen merged PR #19858:
URL: https://github.com/apache/tvm/pull/19858
--
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: discuss-archive-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: discuss-archive-unsubscribe@tvm.apache.org
For additional commands, e-mail: discuss-archive-help@tvm.apache.org
Re: [PR] [REFACTOR][RELAX] Phase out Relax PrimType [tvm]
Posted by "gemini-code-assist[bot] (via GitHub)" <gi...@apache.org>.
gemini-code-assist[bot] commented on code in PR #19858:
URL: https://github.com/apache/tvm/pull/19858#discussion_r3449154937
##########
python/tvm/relax/transform/legalize_ops/index.py:
##########
@@ -36,11 +37,17 @@ def _take(bb: BlockBuilder, call: Call) -> Expr:
@register_legalize("relax.strided_slice")
def _strided_slice(bb: BlockBuilder, call: Call) -> Expr:
def _relax_tuple_to_tir(relax_tuple):
+ if isinstance(relax_tuple, Tuple):
+ output = []
+ for field in relax_tuple.fields:
+ assert isinstance(field, PrimValue)
+ output.append(field.value)
+ return output
+
output = []
for field in relax_tuple.ty.fields:
assert isinstance(field, PrimType)
- assert field.value is not None
- output.append(field.value)
+ return None
return output
Review Comment:

In `_relax_tuple_to_tir`, returning `None` inside the loop on the first iteration prevents the validation of subsequent fields in the tuple type. If a tuple type contains a mix of `PrimType` and other invalid types, the invalid types after the first element will not trigger the assertion.
We should validate all fields in the loop first, and then return `None` if the tuple is non-empty.
```suggestion
for field in relax_tuple.ty.fields:
assert isinstance(field, PrimType)
if relax_tuple.ty.fields:
return None
return []
```
--
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: discuss-archive-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: discuss-archive-unsubscribe@tvm.apache.org
For additional commands, e-mail: discuss-archive-help@tvm.apache.org