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/07/19 12:35:05 UTC
[PR] [CI] Bump tvm-ffi with compatible Python wrappers [tvm]
tqchen opened a new pull request, #20032:
URL: https://github.com/apache/tvm/pull/20032
## Summary
- bump tvm-ffi and include the device definition where its `DLDevice` traits are instantiated
- keep only the required Tensor wrapper layout fix and register `ir.Type` before reflected `Expr` fields can materialize a fallback wrapper
- preserve `BaseFunc.with_attr` callers by moving only method-private results, never the canonical `self` wrapper
## Rationale
The tvm-ffi lifetime update requires a replacement wrapper to fit the layout already registered for the same type index. `runtime.Tensor` replaces the core `ffi.Tensor` wrapper, so it must use empty slots. The ordinary TVM mixins are first-registered with their concrete descendants and may safely retain normal Python dictionaries; the additional mixin and explicit-dictionary slot changes are not required.
Object tying also means `BaseFuncCopy(self)` may return `self`. Passing that wrapper through `_move()` invalidates the caller. The first update now passes the alias as an lvalue, forcing native copy-on-write to create a private result. Only later dictionary updates move a result that is not `self` and has not escaped the method.
## Validation
- built an exact CPython 3.12 wheel from tvm-ffi `21e30c3b1d` and rebuilt TVM against it
- direct Type/function/detach regressions: 3 passed
- complete IR plus focused Relax coverage: 111 passed
- prior Relax failure set: 157 passed, 9 skipped
- runtime probe for `relax.Function`, `relax.ExternFunc`, and `tirx.PrimFunc`: original wrappers preserved; single- and multi-attribute results distinct and valid
- all touched-file pre-commit hooks passed
--
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] [CI] Bump tvm-ffi with compatible Python wrappers [tvm]
Posted by "tqchen (via GitHub)" <gi...@apache.org>.
tqchen commented on code in PR #20032:
URL: https://github.com/apache/tvm/pull/20032#discussion_r3610570245
##########
tests/python/relax/test_expr.py:
##########
@@ -243,11 +243,16 @@ def test_func():
seqe = rx.SeqExpr(blocks, x)
ret_ty = R.Tensor(dtype="float32", ndim=-1)
func = rx.Function([x], seqe, ret_ty)
- func = func.with_attr("global_symbol", "func")
- assert func.params[0] == x
- assert func.body == seqe
- assert func.ret_ty == ret_ty
- assert func.attrs["global_symbol"] == "func"
+ with_attr = func.with_attr("global_symbol", "func")
+ with_attrs = func.with_attr({"global_symbol": "func", "num_input": 1})
+
+ assert "global_symbol" not in func.attrs
Review Comment:
Thanks for checking this. For this concrete `relax.Function`, both `Function.__init__` and `Function.create_empty` explicitly normalize `attrs=None` to `tvm.ir.DictAttrs({})`. On the exact PR build, the new function reports `func.attrs == {}` and `func.attrs is None == False`; after `with_attr`, the original still reports `{}` and the result contains `global_symbol`. The committed focused test also passes as written, while `assert func.attrs is None` fails. I am therefore keeping the membership assertion because it verifies that the original defined attribute map remains unmodified.
--
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] [CI] Bump tvm-ffi with compatible Python wrappers [tvm]
Posted by "cyx-6 (via GitHub)" <gi...@apache.org>.
cyx-6 merged PR #20032:
URL: https://github.com/apache/tvm/pull/20032
--
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] [CI] Bump tvm-ffi with compatible Python wrappers [tvm]
Posted by "gemini-code-assist[bot] (via GitHub)" <gi...@apache.org>.
gemini-code-assist[bot] commented on code in PR #20032:
URL: https://github.com/apache/tvm/pull/20032#discussion_r3610559512
##########
tests/python/relax/test_expr.py:
##########
@@ -243,11 +243,16 @@ def test_func():
seqe = rx.SeqExpr(blocks, x)
ret_ty = R.Tensor(dtype="float32", ndim=-1)
func = rx.Function([x], seqe, ret_ty)
- func = func.with_attr("global_symbol", "func")
- assert func.params[0] == x
- assert func.body == seqe
- assert func.ret_ty == ret_ty
- assert func.attrs["global_symbol"] == "func"
+ with_attr = func.with_attr("global_symbol", "func")
+ with_attrs = func.with_attr({"global_symbol": "func", "num_input": 1})
+
+ assert "global_symbol" not in func.attrs
Review Comment:

If func is created without any attributes, func.attrs may be None (a null DictAttrs mapping to None in Python). Attempting to perform a membership test like 'global_symbol' not in func.attrs on None will raise a TypeError. Since the function is newly created and expected to have no attributes, it is safer and more robust to assert that func.attrs is None directly.
```suggestion
assert func.attrs is None
```
--
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