[neurun] Use Index as key for unordered_map (#2594)
author이한종/동작제어Lab(SR)/Engineer/삼성전자 <hanjoung.lee@samsung.com>
Wed, 5 Sep 2018 05:06:58 +0000 (14:06 +0900)
committer박세희/동작제어Lab(SR)/Principal Engineer/삼성전자 <saehie.park@samsung.com>
Wed, 5 Sep 2018 05:06:58 +0000 (14:06 +0900)
This commit revises `unordered_map`s to use `graph::Index` as key
which used `int` as key because hash function was not exist.

Related PR : #2590

Signed-off-by: Hanjoung Lee <hanjoung.lee@samsung.com>
runtimes/neurun/src/backend/acl_cl/TensorBuilder.cc
runtimes/neurun/src/backend/acl_cl/TensorBuilder.h
runtimes/neurun/src/backend/cpu/TensorBuilder.cc
runtimes/neurun/src/backend/cpu/TensorBuilder.h

index 880ff2d..33a7249 100644 (file)
@@ -37,7 +37,7 @@ void TensorBuilder::prepare(codegen::Plan &plan,
     auto tensor = std::make_shared<::arm_compute::CLTensor>();
     tensor->allocator()->init(tensor_info_ctx.at(ind.asInt()));
     plan.operands().set(ind, std::make_shared<operand::Object>(tensor));
-    _tensors[ind.asInt()] = tensor;
+    _tensors[ind] = tensor;
   }
 }
 
@@ -55,7 +55,7 @@ void TensorBuilder::allocate(void)
 std::shared_ptr<::arm_compute::CLTensor>
 TensorBuilder::at(const ::neurun::graph::operand::Index &ind)
 {
-  return _tensors.at(ind.asInt());
+  return _tensors.at(ind);
 }
 
 } // namespace acl_cl
index e3c8664..b1b5dc1 100644 (file)
@@ -31,7 +31,7 @@ public:
 
 private:
   std::unordered_set<graph::operand::Index> _inds;
-  std::unordered_map<int, std::shared_ptr<::arm_compute::CLTensor>> _tensors;
+  std::unordered_map<graph::operand::Index, std::shared_ptr<::arm_compute::CLTensor>> _tensors;
 };
 
 } // namespace acl_cl
index 3b7fa80..b368261 100644 (file)
@@ -35,7 +35,7 @@ void TensorBuilder::prepare(codegen::Plan &plan,
     // TODO Fix allocation here. When Tensor object is created the memory for tensor is also
     //      allocated, and this must be fixed.
     plan.operands().set(ind, std::make_shared<operand::Object>(tensor));
-    _tensors[ind.asInt()] = tensor;
+    _tensors[ind] = tensor;
   }
 }
 
@@ -49,7 +49,7 @@ void TensorBuilder::allocate(void)
 
 std::shared_ptr<operand::Tensor> TensorBuilder::at(const ::neurun::graph::operand::Index &ind)
 {
-  return _tensors.at(ind.asInt());
+  return _tensors.at(ind);
 }
 
 } // namespace cpu
index 37f3581..d05f03f 100644 (file)
@@ -31,7 +31,7 @@ public:
 
 private:
   std::unordered_set<graph::operand::Index> _inds;
-  std::unordered_map<int, std::shared_ptr<operand::Tensor>> _tensors;
+  std::unordered_map<graph::operand::Index, std::shared_ptr<operand::Tensor>> _tensors;
 };
 
 } // namespace cpu