Skip to content

Commit

Permalink
Preserve purity in RunCodegen
Browse files Browse the repository at this point in the history
  • Loading branch information
slyubomirsky committed Apr 3, 2023
1 parent d55292f commit 1e34266
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 7 additions & 1 deletion src/relax/transform/run_codegen.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}
Expand Down
2 changes: 0 additions & 2 deletions tests/python/relax/test_codegen_dnnl.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,6 @@ def test_dnnl_offload():

seq = tvm.transform.Sequential(
[
relax.transform.ToNonDataflow(),
relax.transform.RemovePurityChecking(),
relax.transform.FuseOpsByPattern([("dnnl.conv2d_relu", pat)]),
relax.transform.MergeCompositeFunctions(),
relax.transform.RunCodegen(),
Expand Down

0 comments on commit 1e34266

Please sign in to comment.