slyubomirsky commented on code in PR #14394:
URL: https://github.com/apache/tvm/pull/14394#discussion_r1152690354
##########
src/relax/transform/run_codegen.cc:
##########
@@ -102,7 +102,13 @@ class CodeGenRunner : ExprMutator {
func = (*RemoveFuncAttrFunc)(func, tvm::attr::kGlobalSymbol);
func = (*RemoveFuncAttrFunc)(func, attr::kCodegen);
builder_->UpdateFunction(gvar, func);
- return create_call_dps_packed(new_func, func->ret_struct_info);
+ // preserve the purity: if the func was originally pure, wrap
call_pure
+ bool purity = GetStructInfoAs<FuncStructInfoNode>(gvar)->purity;
+ auto ret = create_call_dps_packed(new_func, func->ret_struct_info);
+ if (purity) {
+ return WrapCallPure(ret);
+ }
+ return ret;
Review Comment:
This is another case where being clear about staging might make some of this
reasoning unnecessary. We do codegen before doing the VM build in
`test_codegen_dnnl.py`, so I wasn't sure if I should have eliminated dataflow
blocks. The fusion passes seem to rely on having dataflow blocks, so I can't
trivially get rid of purity checking and `call_pure` before fusion (unless we
also disable checking purity from the well-formed check--we could consider
having a third, internal-only annotation, that disables all purity checks, even
inside dataflow blocks).
--
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]