You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by GitBox <gi...@apache.org> on 2022/05/31 18:04:18 UTC

[GitHub] [tvm] areusch commented on a diff in pull request #11498: Add utility that asserts that input IRModule is not mutated in a pass.

areusch commented on code in PR #11498:
URL: https://github.com/apache/tvm/pull/11498#discussion_r885933590


##########
src/ir/transform.cc:
##########
@@ -264,11 +267,31 @@ IRModule Pass::operator()(IRModule mod, const PassContext& pass_ctx) const {
                << " with opt level: " << pass_info->opt_level;
     return mod;
   }
-  auto ret = node->operator()(std::move(mod), pass_ctx);
+  IRModule ret;
+  if (pass_ctx->GetConfig<Bool>("testing.immutable_module", Bool(false)).value()) {
+    ret = Pass::AssertImmutableModule(mod, node, pass_ctx);
+  } else {
+    ret = node->operator()(std::move(mod), pass_ctx);
+  }
   pass_ctx.InstrumentAfterPass(ret, pass_info);
   return std::move(ret);
 }
 
+IRModule Pass::AssertImmutableModule(const IRModule& mod, const PassNode* node,

Review Comment:
   suggest not taking `const IRModule&`--instead take `IRModule`. right now this is basically re-implemeting the copy constructor rather than just using it



-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org