diff --git a/src/operator/subgraph/build_subgraph.cc b/src/operator/subgraph/build_subgraph.cc index 413395c3b74f..54bafdb1f449 100644 --- a/src/operator/subgraph/build_subgraph.cc +++ b/src/operator/subgraph/build_subgraph.cc @@ -226,9 +226,7 @@ bool LabelSubgraph(const nnvm::Graph& g, SubgraphSelectorV2Ptr subgraph_selector std::stack s; s.push(descendant); size_t count = 0; - while (!s.empty()) { - CHECK_LT(count, indexed_graph.num_nodes()) << "Finding ancestor failed. There is probably" - " a loop in the graph"; + while (!s.empty() && count < indexed_graph.num_nodes()) { ++count; const nnvm::Node* top = s.top(); s.pop(); @@ -276,10 +274,6 @@ bool LabelSubgraph(const nnvm::Graph& g, SubgraphSelectorV2Ptr subgraph_selector if (excluded_node_id != -1) { CHECK_LT(excluded_node_id, static_cast(simple_nodes.size())); - CHECK_NE(excluded_node_id, static_cast(snid)) - << "A cycle is found in the computational graph between nodes " - << simple_nodes[excluded_node_id]->node->attrs.name << " and " - << simple_nodes[snid]->node->attrs.name; excluded_nodes->insert(simple_nodes[excluded_node_id].get()); ResetNodeLabels(g, simple_nodes, subgraph_nodes); return false;