From 868a6d558fcda35eb3abd14c7def7fda302b6aac Mon Sep 17 00:00:00 2001 From: chenfei Date: Tue, 20 Jul 2021 16:03:08 +0800 Subject: [PATCH] code clean of r1.3 --- mindspore/ccsrc/debug/debugger/proto_exporter.cc | 4 ++-- mindspore/ccsrc/debug/debugger/proto_exporter.h | 3 +-- mindspore/ccsrc/debug/env_config_parser.cc | 2 +- .../frontend/optimizer/auto_monad_eliminate.cc | 7 ++++--- .../ccsrc/pipeline/jit/parse/data_converter.cc | 1 + .../ccsrc/pipeline/jit/prim_bprop_optimizer.cc | 14 +++++++------- .../ccsrc/pipeline/jit/prim_bprop_optimizer.h | 3 ++- .../pipeline/jit/static_analysis/stack_frame.h | 2 +- mindspore/core/gvar/log_adapter_common.cc | 7 +++++-- mindspore/core/utils/ms_context.cc | 2 +- mindspore/core/utils/ms_context.h | 2 +- 11 files changed, 26 insertions(+), 21 deletions(-) diff --git a/mindspore/ccsrc/debug/debugger/proto_exporter.cc b/mindspore/ccsrc/debug/debugger/proto_exporter.cc index b3da0f7766e..90ba50569df 100644 --- a/mindspore/ccsrc/debug/debugger/proto_exporter.cc +++ b/mindspore/ccsrc/debug/debugger/proto_exporter.cc @@ -402,7 +402,7 @@ void DebuggerProtoExporter::ExportCNodes(const FuncGraphPtr &func_graph, debugge } auto cnode = node->cast(); if (cnode != func_graph->get_return()) { - ExportCNode(func_graph, cnode, &apply_map, const_map_ptr, graph_proto, dump_location); + ExportCNode(func_graph, cnode, &apply_map, const_map_ptr, graph_proto); } else { ExportFuncGraphOutput(func_graph, cnode, apply_map, const_map_ptr, graph_proto); } @@ -412,7 +412,7 @@ void DebuggerProtoExporter::ExportCNodes(const FuncGraphPtr &func_graph, debugge void DebuggerProtoExporter::ExportCNode(const FuncGraphPtr &func_graph, const CNodePtr &node, std::map *apply_map_ptr, std::map *const_map_ptr, - debugger::GraphProto *const graph_proto, LocDebugDumpMode dump_location) { + debugger::GraphProto *const graph_proto) { if (func_graph == nullptr || node == nullptr || apply_map_ptr == nullptr || const_map_ptr == nullptr || graph_proto == nullptr) { return; diff --git a/mindspore/ccsrc/debug/debugger/proto_exporter.h b/mindspore/ccsrc/debug/debugger/proto_exporter.h index a004abb7767..e5a92bfe72d 100644 --- a/mindspore/ccsrc/debug/debugger/proto_exporter.h +++ b/mindspore/ccsrc/debug/debugger/proto_exporter.h @@ -55,8 +55,7 @@ class DebuggerProtoExporter { void ExportCNodes(const FuncGraphPtr &func_graph, debugger::GraphProto *const graph_proto, std::map *const_map_ptr, LocDebugDumpMode dump_location = kDebugWholeStack); void ExportCNode(const FuncGraphPtr &func_graph, const CNodePtr &node, std::map *apply_map_ptr, - std::map *const_map_ptr, debugger::GraphProto *const graph_proto, - LocDebugDumpMode dump_location = kDebugWholeStack); + std::map *const_map_ptr, debugger::GraphProto *const graph_proto); void ExportFuncGraphOutput(const FuncGraphPtr &func_graph, const CNodePtr &ret_node, const std::map &apply_map, std::map *const_map_ptr, debugger::GraphProto *graph_proto); diff --git a/mindspore/ccsrc/debug/env_config_parser.cc b/mindspore/ccsrc/debug/env_config_parser.cc index d4d3c84bfa3..58f39ed9aad 100644 --- a/mindspore/ccsrc/debug/env_config_parser.cc +++ b/mindspore/ccsrc/debug/env_config_parser.cc @@ -237,7 +237,7 @@ void EnvConfigParser::ConfigToString() { cur_config.append(rdr_path_); cur_config.append(", rdr_enable: "); std::string rdr_enable_flag = rdr_enabled_ ? "1" : "0"; - cur_config.append(rdr_enable_flag); + (void)cur_config.append(rdr_enable_flag); MS_LOG(INFO) << cur_config; } } // namespace mindspore diff --git a/mindspore/ccsrc/frontend/optimizer/auto_monad_eliminate.cc b/mindspore/ccsrc/frontend/optimizer/auto_monad_eliminate.cc index fea7e113516..be4bbbb30ac 100644 --- a/mindspore/ccsrc/frontend/optimizer/auto_monad_eliminate.cc +++ b/mindspore/ccsrc/frontend/optimizer/auto_monad_eliminate.cc @@ -119,7 +119,7 @@ void DeleteLoadUserUpdateState(const FuncGraphManagerPtr &manager, const AnfNode const auto &update_state_cnode = load_user->cast(); constexpr size_t monad_index = 1; const auto &monad = update_state_cnode->input(monad_index); - manager->Replace(load_user, monad); + (void)manager->Replace(load_user, monad); } // Pattern2====================================== @@ -167,8 +167,9 @@ void ReplaceLoadUserMakeTuple(const FuncGraphManagerPtr &manager, const FuncGrap const auto &new_make_tuple = fg->NewCNode(new_make_tuple_inputs); // Set abstract for the MakeTuple node. abstract::AbstractBasePtrList element_abstracts; - std::transform(new_make_tuple_inputs.begin() + 1, new_make_tuple_inputs.end(), std::back_inserter(element_abstracts), - [](const AnfNodePtr &input) { return input->abstract(); }); + (void)std::transform(new_make_tuple_inputs.begin() + 1, new_make_tuple_inputs.end(), + std::back_inserter(element_abstracts), + [](const AnfNodePtr &input) { return input->abstract(); }); new_make_tuple->set_abstract(std::make_shared(element_abstracts)); manager->Replace(make_tuple, new_make_tuple); } diff --git a/mindspore/ccsrc/pipeline/jit/parse/data_converter.cc b/mindspore/ccsrc/pipeline/jit/parse/data_converter.cc index 949d04e00bd..1df7afcc866 100644 --- a/mindspore/ccsrc/pipeline/jit/parse/data_converter.cc +++ b/mindspore/ccsrc/pipeline/jit/parse/data_converter.cc @@ -109,6 +109,7 @@ class ByAttrDataConverter : public DataConverter { return convert_func(obj, use_sig); }), attr_name_(attr_name) {} + ~ByAttrDataConverter() override = default; bool Matched(const py::object &obj) override { return py::hasattr(obj, attr_name_); } private: diff --git a/mindspore/ccsrc/pipeline/jit/prim_bprop_optimizer.cc b/mindspore/ccsrc/pipeline/jit/prim_bprop_optimizer.cc index e3425820390..9ba03353ae3 100644 --- a/mindspore/ccsrc/pipeline/jit/prim_bprop_optimizer.cc +++ b/mindspore/ccsrc/pipeline/jit/prim_bprop_optimizer.cc @@ -30,7 +30,7 @@ void PrimBpropOptGraphLevel2Info::TryFreeArgsValue(const ValuePtrList &op_args, } ValuePtrList new_args(op_args); - new_args.emplace_back(out); + (void)new_args.emplace_back(out); TryFreeOneValue(new_args, args_value_using_info_); } @@ -128,7 +128,7 @@ void PrimBpropOptGraphLevel2Info::AalysisForTupleGetItem(const NodeUsersMap &nod << " TupleGetItem idx node:" << idx_node->ToString() << " idx Value :" << value_ptr; } - auto idx = value_ptr->cast()->value(); + auto idx = LongToSize(value_ptr->cast()->value()); arg_info->sub_using_info_[idx].using_flg_ = true; ArgInfoRefresh(cnode, &(arg_info->sub_using_info_[idx])); @@ -157,7 +157,7 @@ void PrimBpropOptGraphLevel2Info::ArgInfoRefresh(const std::shared_ptr } PrimBpropOptimizer &PrimBpropOptimizer::GetPrimBpropOptimizerInst() { - static PrimBpropOptimizer g_prim_bprop_opt; + static PrimBpropOptimizer g_prim_bprop_opt = PrimBpropOptimizer(); return g_prim_bprop_opt; } @@ -296,7 +296,7 @@ PrimBpropOptGraphLevel2InfoPtr PrimBpropOptimizer::PrimBpropOptStep2( return level_2_graph_info; } -FuncGraphPtr PrimBpropOptimizer::BpropGraphFinalOpt(const ResourcePtr &res) { +FuncGraphPtr PrimBpropOptimizer::BpropGraphFinalOpt(const ResourcePtr &res) const { MS_EXCEPTION_IF_NULL(res); auto after_opt_bg = BpropGraphFinalOptPass(res); return after_opt_bg; @@ -339,7 +339,7 @@ void PrimBpropOptimizer::ArgsToAbs(const PrimitivePtr &prim, const ValuePtrList arg_abs = arg_abs->PartialBroaden(); MS_LOG(DEBUG) << "Broaden for " << prim->ToString(); } - (*abs_list).emplace_back(arg_abs); + (void)abs_list->emplace_back(arg_abs); } } @@ -351,8 +351,8 @@ abstract::AbstractBasePtrList PrimBpropOptimizer::AddOutToAbsList(const ValuePtr abstract::AbstractBasePtrList new_abs_list(abs_list); auto out_abs = out->ToAbstract(); out_abs = out_abs->PartialBroaden(); - new_abs_list.emplace_back(out_abs); - new_abs_list.emplace_back(out_abs); + (void)new_abs_list.emplace_back(out_abs); + (void)new_abs_list.emplace_back(out_abs); return new_abs_list; } } // namespace pipeline diff --git a/mindspore/ccsrc/pipeline/jit/prim_bprop_optimizer.h b/mindspore/ccsrc/pipeline/jit/prim_bprop_optimizer.h index ec75a3f7988..be8a8410514 100644 --- a/mindspore/ccsrc/pipeline/jit/prim_bprop_optimizer.h +++ b/mindspore/ccsrc/pipeline/jit/prim_bprop_optimizer.h @@ -100,6 +100,7 @@ struct ParamUsingInfo { class PrimBpropOptGraphLevel2Info { public: explicit PrimBpropOptGraphLevel2Info(const FuncGraphPtr &func_graph) : opt_func_graph_(func_graph) {} + ~PrimBpropOptGraphLevel2Info() = default; const FuncGraphPtr &opt_func_graph() const { return opt_func_graph_; } @@ -143,7 +144,7 @@ class PrimBpropOptimizer { const ValuePtr &out); // do inline opt for final bprop graph - FuncGraphPtr BpropGraphFinalOpt(const ResourcePtr &res); + FuncGraphPtr BpropGraphFinalOpt(const ResourcePtr &res) const; private: PrimBpropOptimizer() = default; diff --git a/mindspore/ccsrc/pipeline/jit/static_analysis/stack_frame.h b/mindspore/ccsrc/pipeline/jit/static_analysis/stack_frame.h index 77fb3362149..2348ba132fa 100644 --- a/mindspore/ccsrc/pipeline/jit/static_analysis/stack_frame.h +++ b/mindspore/ccsrc/pipeline/jit/static_analysis/stack_frame.h @@ -90,7 +90,7 @@ class StackFrame : public Base { AnalysisContextPtr current_context() const { return current_context_; } AnalysisContextPtr parent_context() const { return parent_context_; } - AbstractBasePtrList &args_abs_list() { return args_abs_list_; } + const AbstractBasePtrList &args_abs_list() { return args_abs_list_; } void set_args_abs_list(const AbstractBasePtrList &&args_abs_list) { args_abs_list_ = args_abs_list; } std::string ToString() const override { diff --git a/mindspore/core/gvar/log_adapter_common.cc b/mindspore/core/gvar/log_adapter_common.cc index 24f69ff8207..68093f492cb 100644 --- a/mindspore/core/gvar/log_adapter_common.cc +++ b/mindspore/core/gvar/log_adapter_common.cc @@ -53,12 +53,15 @@ static const std::vector sub_module_names = { "GE", // SM_GE }; -const std::string GetSubModuleName(SubModuleId module_id) { return sub_module_names[module_id % NUM_SUBMODUES]; } +const std::string GetSubModuleName(SubModuleId module_id) { + return sub_module_names[static_cast(module_id % NUM_SUBMODUES)]; +} // export GetTimeString for all sub modules std::string GetTimeString() { #define BUFLEN 80 - char buf[BUFLEN] = {'\0'}; + char buf[BUFLEN]; + (void)memset(buf, '\0', BUFLEN); #if defined(_WIN32) || defined(_WIN64) time_t time_seconds = time(0); struct tm now_time; diff --git a/mindspore/core/utils/ms_context.cc b/mindspore/core/utils/ms_context.cc index 41eca0f48d5..ae4d047c4f6 100644 --- a/mindspore/core/utils/ms_context.cc +++ b/mindspore/core/utils/ms_context.cc @@ -113,7 +113,7 @@ bool MsContext::set_backend_policy(const std::string &policy) { } #ifdef ENABLE_TDTQUE -void MsContext::CreateTensorPrintThread(PrintThreadCrt ctr) { +void MsContext::CreateTensorPrintThread(const PrintThreadCrt &ctr) { uint32_t device_id = get_param(MS_CTX_DEVICE_ID); std::string kReceivePrefix = "TF_RECEIVE_"; std::string channel_name = "_npu_log"; diff --git a/mindspore/core/utils/ms_context.h b/mindspore/core/utils/ms_context.h index e4819332ffd..1eb49942cb3 100644 --- a/mindspore/core/utils/ms_context.h +++ b/mindspore/core/utils/ms_context.h @@ -149,7 +149,7 @@ class MsContext { bool set_backend_policy(const std::string &policy); #ifdef ENABLE_TDTQUE using PrintThreadCrt = std::function; - void CreateTensorPrintThread(PrintThreadCrt ctr); + void CreateTensorPrintThread(const PrintThreadCrt &ctr); void DestroyTensorPrintThread(); #endif static void device_seter(DeviceSeter device) { seter_ = device; }