[onert] Refine DynamicTensorManager impl (#3990)
authorHanjoung Lee <hanjoung.lee@samsung.com>
Wed, 26 Aug 2020 06:24:04 +0000 (15:24 +0900)
committerGitHub <noreply@github.com>
Wed, 26 Aug 2020 06:24:04 +0000 (15:24 +0900)
- Refine `planDealloc` to be one-liner
- Remove comments that are no longer valid

ONE-DCO-1.0-Signed-off-by: Hanjoung Lee <hanjoung.lee@samsung.com>

runtime/onert/core/src/backend/controlflow/DynamicTensorManager.cc
runtime/onert/core/src/backend/controlflow/DynamicTensorManager.h
runtime/onert/core/src/backend/cpu_common/DynamicTensorManager.cc

index e838a32..1288e4c 100644 (file)
@@ -108,17 +108,7 @@ void DynamicTensorManager::buildTensor(const ir::OperandIndex &ind,
 
 void DynamicTensorManager::planDealloc(ir::OperationIndex op_ind, ir::OperandIndex operand_ind)
 {
-  auto find = _dealloc_tensor_map.find(op_ind);
-  if (find != _dealloc_tensor_map.end())
-  {
-    auto &input_set = find->second;
-    input_set.emplace(operand_ind);
-  }
-  else
-  {
-    _dealloc_tensor_map.emplace(
-        std::make_pair(op_ind, std::unordered_set<ir::OperandIndex>{operand_ind}));
-  }
+  _dealloc_tensor_map[op_ind].emplace(operand_ind);
 }
 
 void DynamicTensorManager::deallocInput(ir::OperationIndex op_ind)
index c8b57a4..dbe388b 100644 (file)
@@ -58,7 +58,6 @@ private:
    * @todo  DynamicMemoryManager is not optimized. Optimized one is needed
    */
   std::shared_ptr<cpu_common::DynamicMemoryManager> _dynamic_mem_mgr;
-  // TODO Refactoring : Merge two TensorRegistries into one
   const std::shared_ptr<TensorRegistry> _tensors;
 
   // contains list of dynamic tensor index, which can be deallocated after running operation
index cb27d75..f7ce3d0 100644 (file)
@@ -95,17 +95,7 @@ void DynamicTensorManager::buildTensor(const ir::OperandIndex &ind,
 
 void DynamicTensorManager::planDealloc(ir::OperationIndex op_ind, ir::OperandIndex operand_ind)
 {
-  auto find = _dealloc_tensor_map.find(op_ind);
-  if (find != _dealloc_tensor_map.end())
-  {
-    auto &input_set = find->second;
-    input_set.emplace(operand_ind);
-  }
-  else
-  {
-    _dealloc_tensor_map.emplace(
-        std::make_pair(op_ind, std::unordered_set<ir::OperandIndex>{operand_ind}));
-  }
+  _dealloc_tensor_map[op_ind].emplace(operand_ind);
 }
 
 void DynamicTensorManager::deallocInput(ir::OperationIndex op_ind)