diff --git a/lite/src/mge/network_impl.cpp b/lite/src/mge/network_impl.cpp index 6e5ef95a6cb390cee2d6ee9b30482f86dd210b3a..1d35e07cb3a7675bde50f09e563968c28c9b0f9b 100644 --- a/lite/src/mge/network_impl.cpp +++ b/lite/src/mge/network_impl.cpp @@ -436,6 +436,10 @@ void NetworkImplDft::start() const { void NetworkImplDft::forward() { start(); + if (m_load_config.comp_graph && + m_user_config->options.comp_node_seq_record_level == 2) { + m_load_config.comp_graph.reset(); + } LITE_ASSERT(m_execute_func, "forward must be called after network loaded."); m_execute_func->execute(); } diff --git a/lite/test/test_network_options.cpp b/lite/test/test_network_options.cpp index 5f2832d3f088c445d3554bf55cb074dcb6212e80..51276709309a8ceed516756d9b1655519ea1a499 100644 --- a/lite/test/test_network_options.cpp +++ b/lite/test/test_network_options.cpp @@ -89,6 +89,23 @@ TEST(TestNetWorkOptions, const_shape) { compare_lite_tensor(output_tensor, result_mgb); } +TEST(TestNetWorkOptions, record2) { + Config config; + std::string model_path = "./shufflenet.mge"; + + config.options.var_sanity_check_first_run = false; + config.options.const_shape = true; + config.options.comp_node_seq_record_level = 2; + std::shared_ptr network = std::make_shared(config); + + network->load_model(model_path); + + for (int i = 0; i < 3; i++) { + network->forward(); + network->wait(); + } +} + TEST(TestNetWorkOptions, NCHW44) { Config config; auto tensor = get_input_data("./input_data.npy"); diff --git a/src/core/impl/graph/cg_impl.cpp b/src/core/impl/graph/cg_impl.cpp index 900cce4982891e488b1d329595816a68fcd23d04..1822b318a0e74192813e163e91bcde8cab907fd4 100644 --- a/src/core/impl/graph/cg_impl.cpp +++ b/src/core/impl/graph/cg_impl.cpp @@ -126,7 +126,7 @@ ComputingGraph::ComputingGraph() { void ComputingGraph::assert_destroy(std::shared_ptr& ptr) { mgb_assert( - ptr.use_count() == 1, "unexpected use_count: %zu", size_t(ptr.use_count())); + ptr.use_count() <= 2, "unexpected use_count: %zu", size_t(ptr.use_count())); ptr.reset(); }