diff --git a/mindspore/ccsrc/kernel/tbe/tbe_kernel_build.cc b/mindspore/ccsrc/kernel/tbe/tbe_kernel_build.cc index 161ca39383..73c5ff7970 100644 --- a/mindspore/ccsrc/kernel/tbe/tbe_kernel_build.cc +++ b/mindspore/ccsrc/kernel/tbe/tbe_kernel_build.cc @@ -174,7 +174,7 @@ bool TbeKernelJsonCreator::GenInputList(const shared_ptr &anf_node, siz input_list->emplace_back(input_desc_json); continue; } - MS_LOG(ERROR) << "input num" << *real_input_index << "is not match op inputs"; + MS_LOG(ERROR) << "input num: " << *real_input_index << " is not match op inputs"; return false; } if (op_name == "BatchNorm") { @@ -436,7 +436,7 @@ void TbeKernelJsonCreator::ParseAttrValue(const std::string &type, const mindspo MS_EXCEPTION_IF_NULL(value_type); auto value_type_str = value_type->ToString(); if (value_type_str == "float") { - float data = GetValue(value); + auto data = GetValue(value); attr_value.push_back(data); } else { attr_value = GetValue>(value); diff --git a/mindspore/ccsrc/kernel/tbe/tbe_kernel_select.cc b/mindspore/ccsrc/kernel/tbe/tbe_kernel_select.cc index 754425df1e..1cf1b85e9b 100644 --- a/mindspore/ccsrc/kernel/tbe/tbe_kernel_select.cc +++ b/mindspore/ccsrc/kernel/tbe/tbe_kernel_select.cc @@ -100,7 +100,7 @@ std::vector SplitStr(const std::string &string, const std::string & substr = string.substr(start, index - start); } (void)substr.erase(0, substr.find_first_not_of(' ')); - (void)substr.erase(substr.find_last_not_of(" ") + 1); + (void)substr.erase(substr.find_last_not_of(' ') + 1); auto iter = DYNAMIC_FORMAT_MAP.find(substr); if (iter != DYNAMIC_FORMAT_MAP.end()) { substr = iter->second; @@ -113,8 +113,8 @@ std::vector SplitStr(const std::string &string, const std::string & if (string.size() > start) { substr = string.substr(start); } - (void)substr.erase(0, substr.find_first_not_of(" ")); - (void)substr.erase(substr.find_last_not_of(" ") + 1); + (void)substr.erase(0, substr.find_first_not_of(' ')); + (void)substr.erase(substr.find_last_not_of(' ') + 1); auto iter = DYNAMIC_FORMAT_MAP.find(substr); if (iter != DYNAMIC_FORMAT_MAP.end()) { substr = iter->second; @@ -123,7 +123,7 @@ std::vector SplitStr(const std::string &string, const std::string & return result; } -void ConvertFormatDtype(const std::string &format, const std::string &dtype, const std::shared_ptr io_info) { +void ConvertFormatDtype(const std::string &format, const std::string &dtype, const std::shared_ptr &io_info) { MS_EXCEPTION_IF_NULL(io_info); std::vector format_vec = SplitStr(format, ","); std::vector dtype_vec = SplitStr(dtype, ","); @@ -201,7 +201,7 @@ void SetTidyInputsInfo(const std::shared_ptr &anf_node, MS_EXCEPTION_IF_NULL(inputs[i]); std::string param_type = inputs[i]->param_type(); if (i >= real_input_num) { - MS_LOG(INFO) << "Input index:" << i << "is out of real_input_num:" << real_input_num; + MS_LOG(INFO) << "Input index: " << i << " is out of real_input_num:" << real_input_num; continue; } auto type_id = AnfAlgo::GetPrevNodeOutputInferDataType(anf_node, i); @@ -239,7 +239,7 @@ void SetTidyOutputsInfo(const std::shared_ptr &anf_node, std::vector outputs_format; auto real_output_num = AnfAlgo::GetOutputTensorNum(anf_node); size_t output_idx = 0; - for (const auto output : outputs) { + for (const auto &output : outputs) { MS_EXCEPTION_IF_NULL(output); if (output_idx >= real_output_num) { continue; @@ -280,7 +280,7 @@ void GenTidyKernelBuildInfo(const std::shared_ptr &anf_node, } void ReplaceByDynamicFormatDtype(const CNodePtr &kernel_node, const std::shared_ptr &op_info_ptr, - const std::shared_ptr op_info_new_ptr) { + const std::shared_ptr &op_info_new_ptr) { std::vector> inputs_static = op_info_ptr->inputs_ptr(); std::vector> outputs_static = op_info_ptr->outputs_ptr(); std::vector> inputs_dyn; @@ -523,7 +523,7 @@ bool ParseMetadata(const CNodePtr &kernel_node, const std::shared_ptr 0) { + if (!outputs.empty()) { if (!SetKernelBuilderOutputInfo(outputs, j, real_output_num, builder)) { MS_LOG(ERROR) << "Parse kernel metadata, set outputs kernel builder info failed."; return false; @@ -532,7 +532,7 @@ bool ParseMetadata(const CNodePtr &kernel_node, const std::shared_ptrpush_back(builder->Build()); } - } else if (outputs.size() > 0) { + } else if (!outputs.empty()) { MS_EXCEPTION_IF_NULL(outputs[0]); size_t kernel_info_cnt = outputs[0]->dtypes().size(); for (size_t j = 0; j < kernel_info_cnt; j++) {