FrozenGene commented on issue #4340: [CodeGen] Add build config option disable_assert to control whether to generate assert URL: https://github.com/apache/incubator-tvm/pull/4340#issuecomment-554183342 > Actually, it would be great if we can do it at an earlier point, and add a pass to remove assert. This will allow the same pass to work for both LLVM and C backend @tqchen I tried to implement one IRPass (like SkipAssert) to remove assert in `BuildStmt` https://github.com/apache/incubator-tvm/blob/master/src/codegen/build_module.cc#L389. However, I find that during `lower` https://github.com/apache/incubator-tvm/blob/master/src/codegen/build_module.cc#L444, we will still produce AssertStmt internally. Do you have any good suggestion? For CodeGenC, one way could be like CodeGenCPU: ```c void CodeGenC::VisitStmt_(const AssertStmt* op) { if (!BuildConfig::Current()->disable_assert) { std::string cond = PrintExpr(op->condition); PrintIndent(); if (const auto* str = op->message.as<StringImm>()) { // GLOG style check stream << "CHECK(" << cond << ") << \"" << str->value << "\";\n"; } else { stream << "assert(" << cond << ");\n"; } this->PrintStmt(op->body); } } ```
---------------------------------------------------------------- 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: [email protected] With regards, Apache Git Services
