From 1a807362b8eba5cef3d79e48b537e154cbb35488 Mon Sep 17 00:00:00 2001 From: liujunzhu Date: Fri, 18 Mar 2022 10:52:25 +0800 Subject: [PATCH] clean code --- .../cxx_api/model/model_converter_utils/multi_process.cc | 1 + .../device/ascend/hal/device/ascend_memory_adapter.h | 2 +- .../plugin/device/ascend/hal/device/ascend_memory_pool.cc | 2 +- .../plugin/device/ascend/hal/device/distribute/mpi_pycc.cc | 2 +- .../ascend/hal/device/executor/aicpu_ext_info_handle.cc | 7 ++++--- .../ascend/hal/device/executor/aicpu_ext_info_handle.h | 4 ++-- .../ascend/kernel/tbe/tbe_json/fusion_tbe_json_creator.h | 2 +- .../batchmatmul_dropoutdomaskv3_fusion_pass.h | 4 +++- .../buffer_fusion/depthwiseconv_eltwise_fusion_pass.h | 4 +++- .../plugin/device/ascend/optimizer/ir_fission/bn_split.h | 2 +- .../optimizer/ir_fusion/confusion_softmax_grad_rule.cc | 2 +- .../ascend/optimizer/ir_fusion/input_to_output_registry.h | 2 +- 12 files changed, 20 insertions(+), 14 deletions(-) diff --git a/mindspore/ccsrc/cxx_api/model/model_converter_utils/multi_process.cc b/mindspore/ccsrc/cxx_api/model/model_converter_utils/multi_process.cc index c9e0ac83686..4ef930f0224 100644 --- a/mindspore/ccsrc/cxx_api/model/model_converter_utils/multi_process.cc +++ b/mindspore/ccsrc/cxx_api/model/model_converter_utils/multi_process.cc @@ -201,6 +201,7 @@ Status MultiProcess::ReceiveMsg(const CreateBufferCall &create_buffer_call) { msg_len = receive_msg_->msg_total_len; msg_buffer = create_buffer_call(msg_len); } + MS_EXCEPTION_IF_NULL(msg_buffer); auto ret = memcpy_s(msg_buffer + cur_offset, msg_len - cur_offset, shmat_data_addr_, receive_msg_->msg_len); if (ret != EOK) { MS_LOG(INFO) << "memcpy_s failed, ret = " << ret; diff --git a/mindspore/ccsrc/plugin/device/ascend/hal/device/ascend_memory_adapter.h b/mindspore/ccsrc/plugin/device/ascend/hal/device/ascend_memory_adapter.h index f7c415b9c05..14b072f6163 100644 --- a/mindspore/ccsrc/plugin/device/ascend/hal/device/ascend_memory_adapter.h +++ b/mindspore/ccsrc/plugin/device/ascend/hal/device/ascend_memory_adapter.h @@ -39,7 +39,7 @@ class AscendMemAdapter { uint8_t *MallocStaticDevMem(size_t size, const std::string &tag = ""); uint8_t *MallocDynamicDevMem(size_t size, const std::string &tag = ""); - bool FreeStaticDevMem(void *devPtr) const { return true; } + bool FreeStaticDevMem(void *) const { return true; } void ResetDynamicMemory(); [[nodiscard]] uint64_t FreeDevMemSize() const { return static_mem_offset_ - max_dynamic_mem_offset_; } diff --git a/mindspore/ccsrc/plugin/device/ascend/hal/device/ascend_memory_pool.cc b/mindspore/ccsrc/plugin/device/ascend/hal/device/ascend_memory_pool.cc index d3d04d58ed6..37062ba6deb 100644 --- a/mindspore/ccsrc/plugin/device/ascend/hal/device/ascend_memory_pool.cc +++ b/mindspore/ccsrc/plugin/device/ascend/hal/device/ascend_memory_pool.cc @@ -41,7 +41,7 @@ void AscendMemoryPool::Init() { if (task_sink) { SetMemAllocUintSize(ASCEND_COMMON_POOL_ALLOC_UNIT_SIZE_FOR_GRAPH, ASCEND_COMMON_POOL_ALLOC_UNIT_SIZE_FOR_GRAPH); } else { - SetMemAllocUintSize(total_size * kCommonMemoryRatio, total_size * kPersistMemoryRatio); + SetMemAllocUintSize(FloatToSize(total_size * kCommonMemoryRatio), FloatToSize(total_size * kPersistMemoryRatio)); } } } diff --git a/mindspore/ccsrc/plugin/device/ascend/hal/device/distribute/mpi_pycc.cc b/mindspore/ccsrc/plugin/device/ascend/hal/device/distribute/mpi_pycc.cc index 79245001a56..3fed0d4a4f6 100644 --- a/mindspore/ccsrc/plugin/device/ascend/hal/device/distribute/mpi_pycc.cc +++ b/mindspore/ccsrc/plugin/device/ascend/hal/device/distribute/mpi_pycc.cc @@ -32,7 +32,7 @@ int MpiPycc::GetDeviceID() { return GetDeviceId(); } int MpiPycc::GetRankId(const std::string &group) { return GetRankIdByGroup(group); } int MpiPycc::GetRankSize(const std::string &group) { return GetGroupSize(group); } void MpiPycc::CreateGroup(const std::string &group, const std::vector &ranks) { - CreateCommForGroup(group, ranks); + (void)CreateCommForGroup(group, ranks); } // cppcheck-suppress syntaxError diff --git a/mindspore/ccsrc/plugin/device/ascend/hal/device/executor/aicpu_ext_info_handle.cc b/mindspore/ccsrc/plugin/device/ascend/hal/device/executor/aicpu_ext_info_handle.cc index 2fbadb62009..b4ca90cf5a8 100644 --- a/mindspore/ccsrc/plugin/device/ascend/hal/device/executor/aicpu_ext_info_handle.cc +++ b/mindspore/ccsrc/plugin/device/ascend/hal/device/executor/aicpu_ext_info_handle.cc @@ -99,7 +99,7 @@ bool AicpuExtInfoHandler::ParseExtShapeType(AicpuExtInfo *aicpu_ext_info) { auto type = reinterpret_cast(aicpu_ext_info->infoMsg); - if (*type != unknown_type_) { + if (*type != static_cast(unknown_type_)) { MS_LOG(ERROR) << "Node:" << node_name_ << " parse ext shape type failed as need:" << unknown_type_ << " but got:" << *type; return false; @@ -230,8 +230,9 @@ bool AicpuExtInfoHandler::UpdateShapeAndType(const std::vector &shape, return true; } -void AicpuExtInfoHandler::GetShapeAndType(NotNull shape_and_type, - NotNull *> shape, NotNull data_type) { +void AicpuExtInfoHandler::GetShapeAndType(const NotNull &shape_and_type, + const NotNull *> &shape, + const NotNull &data_type) { for (int64_t tmpDim : shape_and_type->dims) { if (tmpDim == kDimEndFlag) { break; diff --git a/mindspore/ccsrc/plugin/device/ascend/hal/device/executor/aicpu_ext_info_handle.h b/mindspore/ccsrc/plugin/device/ascend/hal/device/executor/aicpu_ext_info_handle.h index 76e3397e809..d86c7cfb896 100644 --- a/mindspore/ccsrc/plugin/device/ascend/hal/device/executor/aicpu_ext_info_handle.h +++ b/mindspore/ccsrc/plugin/device/ascend/hal/device/executor/aicpu_ext_info_handle.h @@ -69,8 +69,8 @@ class AicpuExtInfoHandler { [[nodiscard]] static bool UpdateShapeAndType(const std::vector &shape, NotNull shape_and_type); - static void GetShapeAndType(NotNull shape_and_type, NotNull *> shape, - NotNull data_type); + static void GetShapeAndType(const NotNull &shape_and_type, + const NotNull *> &shape, const NotNull &data_type); const std::string node_name_; const uint32_t input_num_; diff --git a/mindspore/ccsrc/plugin/device/ascend/kernel/tbe/tbe_json/fusion_tbe_json_creator.h b/mindspore/ccsrc/plugin/device/ascend/kernel/tbe/tbe_json/fusion_tbe_json_creator.h index bd060de3ad2..36567c1be94 100644 --- a/mindspore/ccsrc/plugin/device/ascend/kernel/tbe/tbe_json/fusion_tbe_json_creator.h +++ b/mindspore/ccsrc/plugin/device/ascend/kernel/tbe/tbe_json/fusion_tbe_json_creator.h @@ -23,7 +23,7 @@ namespace mindspore::kernel { using ANodeFusionDataTypeMap = std::map; class FusionBuildTbeJsonCreator : public TbeJsonCreator { public: - FusionBuildTbeJsonCreator() : optional_index_(0) {} + FusionBuildTbeJsonCreator() : TbeJsonCreator(), optional_index_(0) {} ~FusionBuildTbeJsonCreator() override = default; bool GenJson(const FusionScopeInfo &fusion_scope_info, nlohmann::json *fusion_json) override; diff --git a/mindspore/ccsrc/plugin/device/ascend/optimizer/buffer_fusion/batchmatmul_dropoutdomaskv3_fusion_pass.h b/mindspore/ccsrc/plugin/device/ascend/optimizer/buffer_fusion/batchmatmul_dropoutdomaskv3_fusion_pass.h index 8ad282e5695..80a0774e6ce 100644 --- a/mindspore/ccsrc/plugin/device/ascend/optimizer/buffer_fusion/batchmatmul_dropoutdomaskv3_fusion_pass.h +++ b/mindspore/ccsrc/plugin/device/ascend/optimizer/buffer_fusion/batchmatmul_dropoutdomaskv3_fusion_pass.h @@ -16,6 +16,8 @@ #ifndef MINDSPORE_CCSRC_BACKEND_OPTIMIZER_ASCEND_BUFFER_FUSION_PASS_BATCHMATMUL_DROPOUTDOMASKV3_FUSION_PASS_H_ #define MINDSPORE_CCSRC_BACKEND_OPTIMIZER_ASCEND_BUFFER_FUSION_PASS_BATCHMATMUL_DROPOUTDOMASKV3_FUSION_PASS_H_ +#include + #include "utils/hash_set.h" #include "plugin/device/ascend/optimizer/buffer_fusion/fusion_base_pass.h" #include "ir/anf.h" @@ -30,7 +32,7 @@ namespace opt { class BatchMatmulDropoutDoMaskV3FusionPass : public FusionBasePass { public: explicit BatchMatmulDropoutDoMaskV3FusionPass(FusionIdAllocatorPtr idAllocator) - : FusionBasePass("BatchMatmulDropoutDoMaskV3FusionPass", idAllocator) {} + : FusionBasePass("BatchMatmulDropoutDoMaskV3FusionPass", std::move(idAllocator)) {} ~BatchMatmulDropoutDoMaskV3FusionPass() override = default; void MatchSingleFusionPattern(const session::KernelGraph &kernel_graph, FusedNodeRecord *candidate_fusion) override; diff --git a/mindspore/ccsrc/plugin/device/ascend/optimizer/buffer_fusion/depthwiseconv_eltwise_fusion_pass.h b/mindspore/ccsrc/plugin/device/ascend/optimizer/buffer_fusion/depthwiseconv_eltwise_fusion_pass.h index 4631efbb5ee..4754c48c8c6 100644 --- a/mindspore/ccsrc/plugin/device/ascend/optimizer/buffer_fusion/depthwiseconv_eltwise_fusion_pass.h +++ b/mindspore/ccsrc/plugin/device/ascend/optimizer/buffer_fusion/depthwiseconv_eltwise_fusion_pass.h @@ -16,6 +16,8 @@ #ifndef MINDSPORE_CCSRC_BACKEND_OPTIMIZER_ASCEND_BUFFER_FUSION_PASS_DEPTHWISECONV_ELTWISE_FUSION_PASS_H_ #define MINDSPORE_CCSRC_BACKEND_OPTIMIZER_ASCEND_BUFFER_FUSION_PASS_DEPTHWISECONV_ELTWISE_FUSION_PASS_H_ +#include + #include "utils/hash_set.h" #include "plugin/device/ascend/optimizer/buffer_fusion/fusion_base_pass.h" #include "ir/anf.h" @@ -30,7 +32,7 @@ namespace opt { class DepthwiseConvEltwiseFusionPass : public FusionBasePass { public: explicit DepthwiseConvEltwiseFusionPass(FusionIdAllocatorPtr idAllocator) - : FusionBasePass("DepthwiseConvEltwiseFusionPass", idAllocator) {} + : FusionBasePass("DepthwiseConvEltwiseFusionPass", std::move(idAllocator)) {} ~DepthwiseConvEltwiseFusionPass() override = default; void MatchSingleFusionPattern(const session::KernelGraph &kernel_graph, FusedNodeRecord *candidate_fusion) override; diff --git a/mindspore/ccsrc/plugin/device/ascend/optimizer/ir_fission/bn_split.h b/mindspore/ccsrc/plugin/device/ascend/optimizer/ir_fission/bn_split.h index a169083d9dc..1f56910ce27 100644 --- a/mindspore/ccsrc/plugin/device/ascend/optimizer/ir_fission/bn_split.h +++ b/mindspore/ccsrc/plugin/device/ascend/optimizer/ir_fission/bn_split.h @@ -25,7 +25,7 @@ namespace mindspore { namespace opt { class BnSplit : public PatternProcessPass { public: - explicit BnSplit(string name = "bn_split", bool multigraph = true) : PatternProcessPass(name, multigraph) {} + explicit BnSplit(const string &name = "bn_split", bool multigraph = true) : PatternProcessPass(name, multigraph) {} ~BnSplit() override = default; const BaseRef DefinePattern() const override; const AnfNodePtr Process(const FuncGraphPtr &, const AnfNodePtr &, const EquivPtr &) const override; diff --git a/mindspore/ccsrc/plugin/device/ascend/optimizer/ir_fusion/confusion_softmax_grad_rule.cc b/mindspore/ccsrc/plugin/device/ascend/optimizer/ir_fusion/confusion_softmax_grad_rule.cc index 379a8be60cb..aae08420435 100644 --- a/mindspore/ccsrc/plugin/device/ascend/optimizer/ir_fusion/confusion_softmax_grad_rule.cc +++ b/mindspore/ccsrc/plugin/device/ascend/optimizer/ir_fusion/confusion_softmax_grad_rule.cc @@ -27,7 +27,7 @@ namespace mindspore { namespace opt { namespace { -bool NeedFusion(const AnfNodePtr &sum_anf, const AnfNodePtr &input0, const AnfNodePtr &input1) { +bool NeedFusion(const AnfNodePtr &sum_anf, const AnfNodePtr &input0, const AnfNodePtr &) { if (sum_anf == nullptr || !sum_anf->isa()) { MS_LOG(WARNING) << "Matched ReduceSum is not a CNode!"; return false; diff --git a/mindspore/ccsrc/plugin/device/ascend/optimizer/ir_fusion/input_to_output_registry.h b/mindspore/ccsrc/plugin/device/ascend/optimizer/ir_fusion/input_to_output_registry.h index c516ea07518..8d21623ce7a 100644 --- a/mindspore/ccsrc/plugin/device/ascend/optimizer/ir_fusion/input_to_output_registry.h +++ b/mindspore/ccsrc/plugin/device/ascend/optimizer/ir_fusion/input_to_output_registry.h @@ -49,7 +49,7 @@ class InputToOutputRegistry { void Register(const InputToOutputRegister ®); void Register( const std::string &op_name, const std::vector &input_indices, - const PreCheckFunc &pre_check_func = [](const CNodePtr &node) { return true; }); + const PreCheckFunc &pre_check_func = [](const CNodePtr &) { return true; }); bool GetRegisterByOpName(const std::string &op_name, InputToOutputRegister *reg) const; private: