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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]