From: 이한종/동작제어Lab(SR)/Engineer/삼성전자 Date: Wed, 5 Sep 2018 05:06:58 +0000 (+0900) Subject: [neurun] Use Index as key for unordered_map (#2594) X-Git-Tag: 0.2~87 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=83783e697ed3fb73388f7860319fac7cf3f39d8a;p=platform%2Fcore%2Fml%2Fnnfw.git [neurun] Use Index as key for unordered_map (#2594) 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 --- diff --git a/runtimes/neurun/src/backend/acl_cl/TensorBuilder.cc b/runtimes/neurun/src/backend/acl_cl/TensorBuilder.cc index 880ff2d..33a7249 100644 --- a/runtimes/neurun/src/backend/acl_cl/TensorBuilder.cc +++ b/runtimes/neurun/src/backend/acl_cl/TensorBuilder.cc @@ -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(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 diff --git a/runtimes/neurun/src/backend/acl_cl/TensorBuilder.h b/runtimes/neurun/src/backend/acl_cl/TensorBuilder.h index e3c8664..b1b5dc1 100644 --- a/runtimes/neurun/src/backend/acl_cl/TensorBuilder.h +++ b/runtimes/neurun/src/backend/acl_cl/TensorBuilder.h @@ -31,7 +31,7 @@ public: private: std::unordered_set _inds; - std::unordered_map> _tensors; + std::unordered_map> _tensors; }; } // namespace acl_cl diff --git a/runtimes/neurun/src/backend/cpu/TensorBuilder.cc b/runtimes/neurun/src/backend/cpu/TensorBuilder.cc index 3b7fa80..b368261 100644 --- a/runtimes/neurun/src/backend/cpu/TensorBuilder.cc +++ b/runtimes/neurun/src/backend/cpu/TensorBuilder.cc @@ -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(tensor)); - _tensors[ind.asInt()] = tensor; + _tensors[ind] = tensor; } } @@ -49,7 +49,7 @@ void TensorBuilder::allocate(void) std::shared_ptr TensorBuilder::at(const ::neurun::graph::operand::Index &ind) { - return _tensors.at(ind.asInt()); + return _tensors.at(ind); } } // namespace cpu diff --git a/runtimes/neurun/src/backend/cpu/TensorBuilder.h b/runtimes/neurun/src/backend/cpu/TensorBuilder.h index 37f3581..d05f03f 100644 --- a/runtimes/neurun/src/backend/cpu/TensorBuilder.h +++ b/runtimes/neurun/src/backend/cpu/TensorBuilder.h @@ -31,7 +31,7 @@ public: private: std::unordered_set _inds; - std::unordered_map> _tensors; + std::unordered_map> _tensors; }; } // namespace cpu