diff --git a/taichi/analysis/verify.cpp b/taichi/analysis/verify.cpp index b643f58a8a968..a7493ccd90431 100644 --- a/taichi/analysis/verify.cpp +++ b/taichi/analysis/verify.cpp @@ -22,15 +22,18 @@ class IRVerifier : public BasicStmtVisitor { invoke_default_visitor = true; if (!root->is()) { visible_stmts.emplace_back(); - current_block = root->as()->parent; + current_block = nullptr; } else current_block = nullptr; } void basic_verify(Stmt *stmt) { - TI_ASSERT_INFO(stmt->parent == current_block, - "stmt({})->parent({}) != current_block({})", stmt->id, - fmt::ptr(stmt->parent), fmt::ptr(current_block)); + if (current_block != nullptr) { + // Temporary fix for root being OffloadedStmt + TI_ASSERT_INFO(stmt->parent == current_block, + "stmt({})->parent({}) != current_block({})", stmt->id, + fmt::ptr(stmt->parent), fmt::ptr(current_block)); + } for (auto &op : stmt->get_operands()) { if (op == nullptr) continue; @@ -110,9 +113,10 @@ class IRVerifier : public BasicStmtVisitor { namespace irpass::analysis { void verify(IRNode *root) { TI_AUTO_PROF; - if (!root->is()) { - TI_WARN("IR root is not a Block. Skipping verification."); - // TODO: support this case + if (!root->is() && !root->is()) { + TI_WARN( + "IR root is neither a Block nor an OffloadedStmt." + " Skipping verification."); } else { IRVerifier::run(root); }