From 2d16316c55d1f24712ff33f24834336823712e41 Mon Sep 17 00:00:00 2001 From: lizhenyu Date: Mon, 15 Jun 2020 11:57:13 +0800 Subject: [PATCH] fix code review warnings --- mindspore/ccsrc/device/gpu/gpu_device_address.cc | 2 -- mindspore/ccsrc/device/gpu/gpu_kernel_build.cc | 2 -- .../ccsrc/pre_activate/mem_reuse/mem_swap_manager.cc | 12 +++++++----- .../ccsrc/pre_activate/mem_reuse/mem_swap_manager.h | 9 +++++---- 4 files changed, 12 insertions(+), 13 deletions(-) diff --git a/mindspore/ccsrc/device/gpu/gpu_device_address.cc b/mindspore/ccsrc/device/gpu/gpu_device_address.cc index c6c34e33f6..24097f3637 100644 --- a/mindspore/ccsrc/device/gpu/gpu_device_address.cc +++ b/mindspore/ccsrc/device/gpu/gpu_device_address.cc @@ -15,9 +15,7 @@ */ #include "device/gpu/gpu_device_address.h" - #include - #include "device/gpu/gpu_device_manager.h" #include "utils/log_adapter.h" #include "utils/context/ms_context.h" diff --git a/mindspore/ccsrc/device/gpu/gpu_kernel_build.cc b/mindspore/ccsrc/device/gpu/gpu_kernel_build.cc index f9d2cb878f..9efa5d0d1a 100644 --- a/mindspore/ccsrc/device/gpu/gpu_kernel_build.cc +++ b/mindspore/ccsrc/device/gpu/gpu_kernel_build.cc @@ -20,12 +20,10 @@ #include "kernel/akg/gpu/akg_gpu_kernel_build.h" #include "kernel/gpu/gpu_kernel_factory.h" #include "operator/ops.h" -#include "pybind11/stl.h" #include "session/anf_runtime_algorithm.h" namespace mindspore { namespace device { namespace gpu { -namespace py = pybind11; void GpuBuild(const KernelGraphPtr &kernel_graph) { kernel::KernelMeta *bin_map = kernel::KernelMeta::GetInstance(); bin_map->Initialize(); diff --git a/mindspore/ccsrc/pre_activate/mem_reuse/mem_swap_manager.cc b/mindspore/ccsrc/pre_activate/mem_reuse/mem_swap_manager.cc index c41eacc334..d81364edfb 100644 --- a/mindspore/ccsrc/pre_activate/mem_reuse/mem_swap_manager.cc +++ b/mindspore/ccsrc/pre_activate/mem_reuse/mem_swap_manager.cc @@ -28,7 +28,7 @@ void MemSwapManager::Init(const mindspore::session::KernelGraph *kernel_graph) { size_t kernel_index = 0; for (const auto &kernel : execution_order_) { // parse topo order of kernel - kernel_execution_info_.emplace(kernel.get(), kernel_index++); + (void)kernel_execution_info_.emplace(kernel.get(), kernel_index++); // parse tensor info auto kernel_mod = AnfAlgo::GetKernelMod(kernel); MS_EXCEPTION_IF_NULL(kernel_mod); @@ -144,7 +144,7 @@ void MemSwapManager::AddSwapInfo() { } void MemSwapManager::AddMemSwapTask(SwapKind swap_kind, const DeviceAddressPtr &device_address, - const HostAddress &host_address) { + const HostAddress &host_address) const { if (swap_kind == SwapKind::kDeviceToHost) { mem_copy_manager_->AddMemSwapOutTask(device_address, host_address); } else if (swap_kind == SwapKind::kHostToDevice) { @@ -152,9 +152,11 @@ void MemSwapManager::AddMemSwapTask(SwapKind swap_kind, const DeviceAddressPtr & } } -bool MemSwapManager::SyncMemCopyStream(SwapKind swap_kind) { return mem_copy_manager_->SyncMemCopyStream(swap_kind); } +bool MemSwapManager::SyncMemCopyStream(SwapKind swap_kind) const { + return mem_copy_manager_->SyncMemCopyStream(swap_kind); +} -DeviceAddressPtr MemSwapManager::UpdateSwapQueue(SwapKind swap_kind) { +DeviceAddressPtr MemSwapManager::UpdateSwapQueue(SwapKind swap_kind) const { if (swap_kind == SwapKind::kDeviceToHost) { return mem_copy_manager_->UpdateSwapOutQueue(); } else { @@ -298,7 +300,7 @@ void MemSwapManager::ReleaseHostPinnedMem() { host_addrs_list_.clear(); } -void MemSwapManager::ClearSwapQueue() { mem_copy_manager_->ClearSwapQueue(); } +void MemSwapManager::ClearSwapQueue() const { mem_copy_manager_->ClearSwapQueue(); } void MemSwapManager::ResetSwapInfo() { ClearSwapQueue(); diff --git a/mindspore/ccsrc/pre_activate/mem_reuse/mem_swap_manager.h b/mindspore/ccsrc/pre_activate/mem_reuse/mem_swap_manager.h index c19930000e..7e2823d27c 100644 --- a/mindspore/ccsrc/pre_activate/mem_reuse/mem_swap_manager.h +++ b/mindspore/ccsrc/pre_activate/mem_reuse/mem_swap_manager.h @@ -44,11 +44,12 @@ class MemSwapManager { void Init(const mindspore::session::KernelGraph *kernel_graph); - void AddMemSwapTask(SwapKind swap_kind, const DeviceAddressPtr &device_address, const HostAddress &host_address); + void AddMemSwapTask(SwapKind swap_kind, const DeviceAddressPtr &device_address, + const HostAddress &host_address) const; - bool SyncMemCopyStream(SwapKind swap_kind); + bool SyncMemCopyStream(SwapKind swap_kind) const; - DeviceAddressPtr UpdateSwapQueue(SwapKind swap_kind); + DeviceAddressPtr UpdateSwapQueue(SwapKind swap_kind) const; // retreat to find a workable swap scheme bool RetreatSwapInfo(); @@ -83,7 +84,7 @@ class MemSwapManager { void ReleaseHostPinnedMem(); - void ClearSwapQueue(); + void ClearSwapQueue() const; private: void AddSwapInfo();