Support of IfNode in graph runtime

When there is an IfNode in the model, it will raise if is not supported errror. I saw the error comes from src/relay/backend/graph_plan_memory.cc:

void VisitExpr_(const IfNode* op) final {                                                                                                                                                                                                                                                                                                                                              
  LOG(FATAL) << "if is not supported.";                                                                                                                                                                    
}  

Also in src/relay/backend/graph_runtime_codegen.cc:

std::vector<GraphNodeRef> VisitExpr_(const IfNode* op) override {
  throw std::invalid_argument("if not supported");
  return {};
}

Is it possible to implement these for IfNode? Any ideas are appreciated. Thanks.

IIUC, graph runtime doesn’t support control flow. Alternatively, VM is a solution for it.

Thanks @comaniac for your suggestion. I tried VM, but got segmentation fault when trying to run in VTA (just simulation). Struggle a while to debug, but does not figure it out. In addition, it seems VM does not support heterogenous execution.

So just wonder if there are lots of works to support IfNode in graph runtime.

Yeah I think graph runtime is not designed for complicated neural networks that involve control flow, but VM is

Thanks for the clarification.