From 83783e697ed3fb73388f7860319fac7cf3f39d8a Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EC=9D=B4=ED=95=9C=EC=A2=85/=EB=8F=99=EC=9E=91=EC=A0=9C?= =?utf8?q?=EC=96=B4Lab=28SR=29/Engineer/=EC=82=BC=EC=84=B1=EC=A0=84?= =?utf8?q?=EC=9E=90?= Date: Wed, 5 Sep 2018 14:06:58 +0900 Subject: [PATCH] [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 --- runtimes/neurun/src/backend/acl_cl/TensorBuilder.cc | 4 ++-- runtimes/neurun/src/backend/acl_cl/TensorBuilder.h | 2 +- runtimes/neurun/src/backend/cpu/TensorBuilder.cc | 4 ++-- runtimes/neurun/src/backend/cpu/TensorBuilder.h | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) 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 -- 2.7.4