From: 박종현/동작제어Lab(SR)/Staff Engineer/삼성전자 Date: Wed, 5 Dec 2018 23:38:45 +0000 (+0900) Subject: [coco] Deallocate a partial Op tree correctly (#2502) X-Git-Tag: nncc_backup~1188 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6441123fd0fd0103a45b8eef803af08357de1131;p=platform%2Fcore%2Fml%2Fnnfw.git [coco] Deallocate a partial Op tree correctly (#2502) The current implementation of destroy_all does not work for a partial Op tree. Signed-off-by: Jonghyun Park --- diff --git a/contrib/coco/core/src/IR/OpManager.cpp b/contrib/coco/core/src/IR/OpManager.cpp index ce94b2d..ad20375 100644 --- a/contrib/coco/core/src/IR/OpManager.cpp +++ b/contrib/coco/core/src/IR/OpManager.cpp @@ -62,7 +62,10 @@ void OpManager::destroy_all(Op *op) // Insert child op nodes for (uint32_t n = 0; n < cur->arity(); ++n) { - q.emplace(cur->arg(n)); + if (auto child = cur->arg(n)) + { + q.emplace(child); + } } // Destroy the current op node diff --git a/contrib/coco/core/src/IR/OpManager.test.cpp b/contrib/coco/core/src/IR/OpManager.test.cpp index 3afc2da..e9e97a5 100644 --- a/contrib/coco/core/src/IR/OpManager.test.cpp +++ b/contrib/coco/core/src/IR/OpManager.test.cpp @@ -87,3 +87,13 @@ TEST_F(OpManagerTest, destroy_all) ASSERT_EQ(mgr.size(), 0); } + +TEST_F(OpManagerTest, destroy_all_partial_tree) +{ + // Create a (partial) Op tree + auto conv_op = mgr.create(); + + mgr.destroy_all(conv_op); + + ASSERT_EQ(mgr.size(), 0); +}