masahi commented on a change in pull request #7368:
URL: https://github.com/apache/tvm/pull/7368#discussion_r566530421



##########
File path: src/relay/transforms/dynamic_to_static.cc
##########
@@ -32,29 +32,57 @@
 namespace tvm {
 namespace relay {
 
+Expr PrepareInput(const Expr& expr) {
+  // TODO(mbrookhart): Rewrite this to use increment type inference
+  // when that feature is available
+  auto mod = IRModule::FromExpr(expr);
+  // Perform FoldConstant->InferType twice due to nested control
+  // flow/dynamic rank issues in certain object models
+  mod = transform::FoldConstant()(mod);
+  mod = transform::InferType()(mod);
+  mod = transform::FoldConstant()(mod);
+  mod = transform::InferType()(mod);
+  if (expr.as<FunctionNode>()) {
+    return mod->Lookup("main");
+  } else {
+    return mod->Lookup("main").as<FunctionNode>()->body;
+  }
+}
+
+std::vector<Expr> PrepareArgs(const CallNode* call_node) {
+  std::vector<Expr> args;
+  for (auto arg : call_node->args) {
+    args.emplace_back(PrepareInput(arg));

Review comment:
       maybe skip `PrepareInput` if the arg is already a constant? 




----------------------------------------------------------------
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.

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


Reply via email to