From 9c7cea81c8407ace7db46d781df5123fce60bd66 Mon Sep 17 00:00:00 2001 From: tensor-tang Date: Fri, 5 Jan 2018 14:50:27 +0800 Subject: [PATCH] follow comments, use unique_ptr and remove unused file --- paddle/operators/tensor.save | Bin 466 -> 0 bytes paddle/platform/device_context.cc | 4 ++-- paddle/platform/device_context.h | 6 +++--- paddle/platform/mkldnn_helper.h | 9 +++++---- 4 files changed, 10 insertions(+), 9 deletions(-) delete mode 100644 paddle/operators/tensor.save diff --git a/paddle/operators/tensor.save b/paddle/operators/tensor.save deleted file mode 100644 index de6cd5a66a26e9e8f2bee245cf17ec190c5c1e05..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 466 zcmYMqg-%035CzbsSSj{!hvM$;?(XjY{|}rckWO+YlRGzr5b}tV{oT3spQrw!{M;)P zxznj6lVoBTo3Rxe1r!n+#iS`A7E39koC+#QsG^!0YN?~11{!IinHE}Uqn!@2bkapP zJ@nE?KLZRh#4sa_GR8O)OftnZGt4r_JPRzc#4;h9qTyn)VH{5c^Jr6wc#4|6v^2R$KeDcLNKi(h{!T(op_key)) { return; } - GetElementPool().emplace(op_key, value); + GetElementPool().emplace(op_key, std::move(value)); } template -const T MKLDNNDeviceContext::GetElement(const std::string& op_key) const { +const T& MKLDNNDeviceContext::GetElement(const std::string& op_key) const { auto it = GetElementPool().find(op_key); return it == GetElementPool().end() ? nullptr : it->second; } diff --git a/paddle/platform/device_context.h b/paddle/platform/device_context.h index 44f3ac1d392..21a5ed1835a 100644 --- a/paddle/platform/device_context.h +++ b/paddle/platform/device_context.h @@ -132,7 +132,7 @@ class MKLDNNDeviceContext : public CPUDeviceContext { /* \brief Get existed element: memory, primitive or primitive desc */ template - const T GetElement(const std::string& op_key) const; + const T& GetElement(const std::string& op_key) const; /* \brief Get element pool: memory, primitive or primitive desc pool */ template @@ -140,7 +140,7 @@ class MKLDNNDeviceContext : public CPUDeviceContext { GetElementPool() const; /* \brief Get the active engine */ - const MKLDNNEnginePtr GetEngine() const { return engine_; } + const MKLDNNEngine& engine() const { return *engine_; } /* \brief Submit primitive to pipeline */ void Submit(const MKLDNNPrimitivePtr& p) { pipeline_.push_back(*p); } @@ -163,7 +163,7 @@ class MKLDNNDeviceContext : public CPUDeviceContext { std::hash> primitive_desc_pool_; std::vector pipeline_; - std::unique_ptr stream_; + MKLDNNStreamPtr stream_; MKLDNNEnginePtr engine_; bool ready_; }; diff --git a/paddle/platform/mkldnn_helper.h b/paddle/platform/mkldnn_helper.h index 07a9c362c57..cd52a8b4c43 100644 --- a/paddle/platform/mkldnn_helper.h +++ b/paddle/platform/mkldnn_helper.h @@ -25,10 +25,11 @@ using MKLDNNMemory = mkldnn::memory; using MKLDNNPrimitive = mkldnn::primitive; using MKLDNNPrimitiveDesc = mkldnn::handle; -typedef std::shared_ptr MKLDNNEnginePtr; -typedef std::shared_ptr MKLDNNMemoryPtr; -typedef std::shared_ptr MKLDNNPrimitivePtr; -typedef std::shared_ptr MKLDNNPrimitiveDescPtr; +typedef std::unique_ptr MKLDNNStreamPtr; +typedef std::unique_ptr MKLDNNEnginePtr; +typedef std::unique_ptr MKLDNNMemoryPtr; +typedef std::unique_ptr MKLDNNPrimitivePtr; +typedef std::unique_ptr MKLDNNPrimitiveDescPtr; } // namespace platform } // namespace paddle -- GitLab