From b09d5a13b2972c0e394380e8e96b4530f41ab6fa Mon Sep 17 00:00:00 2001 From: lianliguang Date: Wed, 21 Apr 2021 17:31:37 +0800 Subject: [PATCH] clean review bot warning --- .../backend/kernel_compiler/common_utils.cc | 4 +- .../hccl/hccl_kernel_metadata.cc | 2 +- .../kernel_compiler/kernel_build_info.cc | 8 +- .../ascend/ascend_backend_optimization.cc | 2 +- ...nel.cc => change_axis_of_reduce_kernel.cc} | 206 +++++++++--------- ...ernel.h => change_axis_of_reduce_kernel.h} | 70 +++--- .../convert_unsupported_transnode_to_aicpu.h | 6 +- .../format_type/insert_transdata_for_runop.cc | 2 +- .../ascend/format_type/merge_cast_to_op.cc | 8 +- .../ccsrc/backend/optimizer/common/helper.cc | 6 +- .../convert_tuple_input_to_dynamic_input.cc | 6 +- .../backend/session/anf_runtime_algorithm.cc | 20 +- .../ccsrc/backend/session/kernel_graph.cc | 4 +- .../ccsrc/backend/session/kernel_graph.h | 2 +- .../ccsrc/backend/session/session_basic.cc | 2 +- .../operator/ops_front_infer_function.cc | 8 +- .../operator/ops_front_infer_function.h | 2 +- mindspore/ccsrc/pybind_api/ir/primitive_py.cc | 4 +- mindspore/core/abstract/prim_structures.cc | 2 +- mindspore/core/ops/bias_add.cc | 16 +- mindspore/core/ops/conv2d.cc | 17 +- .../core/ops/grad/conv2d_backprop_input.cc | 6 +- mindspore/core/ops/mat_mul.cc | 16 +- mindspore/core/ops/max_pool.cc | 2 +- mindspore/core/ops/merge.cc | 2 +- mindspore/core/ops/primitive_c.cc | 4 +- mindspore/core/ops/shape.cc | 8 +- mindspore/core/utils/check_convert_utils.cc | 2 +- mindspore/core/utils/tensor_construct_utils.h | 1 + 29 files changed, 222 insertions(+), 216 deletions(-) rename mindspore/ccsrc/backend/optimizer/ascend/format_type/{chang_axis_of_reduce_kernel.cc => change_axis_of_reduce_kernel.cc} (92%) rename mindspore/ccsrc/backend/optimizer/ascend/format_type/{chang_axis_of_reduce_kernel.h => change_axis_of_reduce_kernel.h} (91%) diff --git a/mindspore/ccsrc/backend/kernel_compiler/common_utils.cc b/mindspore/ccsrc/backend/kernel_compiler/common_utils.cc index aa95aea562..e231445f17 100644 --- a/mindspore/ccsrc/backend/kernel_compiler/common_utils.cc +++ b/mindspore/ccsrc/backend/kernel_compiler/common_utils.cc @@ -763,9 +763,9 @@ std::vector GetReduceAttrAxis(const CNodePtr &cnode) { } for (const auto &elem : axis_list) { if (elem < 0) { - axis.emplace_back(input_shape.size() + elem); + (void)axis.emplace_back(input_shape.size() + elem); } else { - axis.emplace_back(elem); + (void)axis.emplace_back(elem); } } AnfAlgo::SetNodeAttr(kAttrAxis, MakeValue(axis), cnode); diff --git a/mindspore/ccsrc/backend/kernel_compiler/hccl/hccl_kernel_metadata.cc b/mindspore/ccsrc/backend/kernel_compiler/hccl/hccl_kernel_metadata.cc index 736258505e..07ba16d1b4 100755 --- a/mindspore/ccsrc/backend/kernel_compiler/hccl/hccl_kernel_metadata.cc +++ b/mindspore/ccsrc/backend/kernel_compiler/hccl/hccl_kernel_metadata.cc @@ -65,7 +65,7 @@ void HcclMetadataInfo(const CNodePtr &kernel_node, std::vector inputs_type{}; size_t input_num = AnfAlgo::GetInputTensorNum(kernel_node); for (size_t input_index = 0; input_index < input_num; ++input_index) { - inputs_format.emplace_back(GetKernelFormat(kernel_node, input_index)); + (void)inputs_format.emplace_back(GetKernelFormat(kernel_node, input_index)); inputs_type.push_back(type); } std::vector outputs_format; diff --git a/mindspore/ccsrc/backend/kernel_compiler/kernel_build_info.cc b/mindspore/ccsrc/backend/kernel_compiler/kernel_build_info.cc index 16d5c7d909..860ae8cae3 100644 --- a/mindspore/ccsrc/backend/kernel_compiler/kernel_build_info.cc +++ b/mindspore/ccsrc/backend/kernel_compiler/kernel_build_info.cc @@ -209,8 +209,8 @@ void KernelBuildInfo::KernelBuildInfoBuilder::SetInputReshapeType(const std::str if (index >= kernel_build_info_->input_reshape_type_.size()) { MS_LOG(EXCEPTION) << "index outof range!"; } - std::copy(input_reshape_type.begin(), input_reshape_type.end(), - std::back_inserter(kernel_build_info_->input_reshape_type_[index])); + (void)std::copy(input_reshape_type.begin(), input_reshape_type.end(), + std::back_inserter(kernel_build_info_->input_reshape_type_[index])); } void KernelBuildInfo::KernelBuildInfoBuilder::SetOutputReshapeType(const std::string &output_reshape_type, @@ -218,8 +218,8 @@ void KernelBuildInfo::KernelBuildInfoBuilder::SetOutputReshapeType(const std::st if (index >= kernel_build_info_->output_reshape_type_.size()) { MS_LOG(EXCEPTION) << "index outof range!"; } - std::copy(output_reshape_type.begin(), output_reshape_type.end(), - std::back_inserter(kernel_build_info_->output_reshape_type_[index])); + (void)std::copy(output_reshape_type.begin(), output_reshape_type.end(), + std::back_inserter(kernel_build_info_->output_reshape_type_[index])); } void KernelBuildInfo::KernelBuildInfoBuilder::SetOutputDeviceType(const TypeId &output_device_type, size_t index) { diff --git a/mindspore/ccsrc/backend/optimizer/ascend/ascend_backend_optimization.cc b/mindspore/ccsrc/backend/optimizer/ascend/ascend_backend_optimization.cc index af4d80115f..8e2d502108 100644 --- a/mindspore/ccsrc/backend/optimizer/ascend/ascend_backend_optimization.cc +++ b/mindspore/ccsrc/backend/optimizer/ascend/ascend_backend_optimization.cc @@ -73,7 +73,7 @@ #include "backend/optimizer/ascend/format_type/insert_transpose_for_basiclstm_op.h" #include "backend/optimizer/ascend/format_type/insert_transpose_for_dyanmic_gru_v2.h" #include "backend/optimizer/ascend/format_type/rectify_do_mask_kernel_info.h" -#include "backend/optimizer/ascend/format_type/chang_axis_of_reduce_kernel.h" +#include "backend/optimizer/ascend/format_type/change_axis_of_reduce_kernel.h" #include "backend/optimizer/ascend/format_type/convert_cast_format.h" #include "backend/optimizer/pass/getitem_tuple.h" #include "backend/optimizer/pass/optimize_dependence.h" diff --git a/mindspore/ccsrc/backend/optimizer/ascend/format_type/chang_axis_of_reduce_kernel.cc b/mindspore/ccsrc/backend/optimizer/ascend/format_type/change_axis_of_reduce_kernel.cc similarity index 92% rename from mindspore/ccsrc/backend/optimizer/ascend/format_type/chang_axis_of_reduce_kernel.cc rename to mindspore/ccsrc/backend/optimizer/ascend/format_type/change_axis_of_reduce_kernel.cc index 2bd9ec1f6d..a447d6dd1e 100644 --- a/mindspore/ccsrc/backend/optimizer/ascend/format_type/chang_axis_of_reduce_kernel.cc +++ b/mindspore/ccsrc/backend/optimizer/ascend/format_type/change_axis_of_reduce_kernel.cc @@ -1,103 +1,103 @@ -/** - * Copyright 2019 Huawei Technologies Co., Ltd - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#include "backend/optimizer/ascend/format_type/chang_axis_of_reduce_kernel.h" - -#include -#include -#include -#include - -#include "utils/utils.h" -#include "backend/session/anf_runtime_algorithm.h" -#include "backend/kernel_compiler/common_utils.h" - -namespace mindspore { -namespace opt { -namespace { -using ConvertFunction = std::function; - -void ConvertReduceAttrFraczAnd6HD(const CNodePtr &cnode); -const size_t kAxis_H = 2; -const size_t kAxis_W = 3; -const size_t kAxis_6HD_H = 1; -const size_t kAxis_6HD_W = 2; -const std::map kReduceConvertMap = {{kOpFormat_FRAC_Z, ConvertReduceAttrFraczAnd6HD}, - {kOpFormat_C1HWNCoC0, ConvertReduceAttrFraczAnd6HD}}; -void SafeCheckFunction(const CNodePtr &cnode, const std::vector &reduce_axis) { - if (reduce_axis.empty()) { - MS_LOG(EXCEPTION) << "The node " << cnode->DebugString() << "'s reduce axis got a empty vector"; - } - if (AnfAlgo::GetInputTensorNum(cnode) != AnfAlgo::GetOutputTensorNum(cnode) && - AnfAlgo::GetInputTensorNum(cnode) != 1) { - MS_LOG(EXCEPTION) << "the kind of reduce node [" << cnode->DebugString() - << "] is not single input or single output "; - } - for (auto elem : reduce_axis) { - if (elem > 4) { - MS_LOG(INFO) << "reduce axis is larger than 4 dims reduce axis : [" << elem << "]"; - } - } -} - -void ConvertReduceAttrFraczAnd6HD(const CNodePtr &cnode) { - auto axis = kernel::GetReduceAttrAxis(cnode); - std::vector convert_axis; - SafeCheckFunction(cnode, axis); - auto format = AnfAlgo::GetInputFormat(cnode, 0); - if (format != kOpFormat_FRAC_Z && format != kOpFormat_C1HWNCoC0) { - MS_LOG(EXCEPTION) << "The node [" << cnode->DebugString() << "] format " << format - << " is not needed to change the axis"; - } - for (auto elem : axis) { - switch (elem) { - case kAxis_H: - convert_axis.emplace_back(kAxis_6HD_H); - break; - case kAxis_W: - convert_axis.emplace_back(kAxis_6HD_W); - break; - default: - MS_LOG(INFO) << "reduce axis is axis : [" << elem << "]" - << " but the format is not supported this reduce axis"; - } - } - AnfAlgo::SetNodeAttr(kAttrAxis, MakeValue(convert_axis), cnode); -} -} // namespace - -const BaseRef ChangeAxisOfReduceKernel::DefinePattern() const { - VarPtr X = std::make_shared(); - VarPtr Xs = std::make_shared(); - return VectorRef({X, Xs}); -} - -const AnfNodePtr ChangeAxisOfReduceKernel::Process(const FuncGraphPtr &, const AnfNodePtr &node, - const EquivPtr &) const { - if (node == nullptr || !node->isa() || !AnfAlgo::IsRealKernel(node)) { - return nullptr; - } - if (AnfAlgo::GetOpPattern(node) != kernel::kReducePattern) { - return nullptr; - } - auto convert_map = kReduceConvertMap.find(AnfAlgo::GetInputFormat(node, 0)); - if (convert_map == kReduceConvertMap.end()) { - return nullptr; - } - convert_map->second(node->cast()); - return nullptr; -} -} // namespace opt -} // namespace mindspore +/** + * Copyright 2019 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "backend/optimizer/ascend/format_type/change_axis_of_reduce_kernel.h" + +#include +#include +#include +#include + +#include "utils/utils.h" +#include "backend/session/anf_runtime_algorithm.h" +#include "backend/kernel_compiler/common_utils.h" + +namespace mindspore { +namespace opt { +namespace { +using ConvertFunction = std::function; + +void ConvertReduceAttrFraczAnd6HD(const CNodePtr &cnode); +const size_t kAxis_H = 2; +const size_t kAxis_W = 3; +const size_t kAxis_6HD_H = 1; +const size_t kAxis_6HD_W = 2; +const std::map kReduceConvertMap = {{kOpFormat_FRAC_Z, ConvertReduceAttrFraczAnd6HD}, + {kOpFormat_C1HWNCoC0, ConvertReduceAttrFraczAnd6HD}}; +void SafeCheckFunction(const CNodePtr &cnode, const std::vector &reduce_axis) { + if (reduce_axis.empty()) { + MS_LOG(EXCEPTION) << "The node " << cnode->DebugString() << "'s reduce axis got a empty vector"; + } + if (AnfAlgo::GetInputTensorNum(cnode) != AnfAlgo::GetOutputTensorNum(cnode) && + AnfAlgo::GetInputTensorNum(cnode) != 1) { + MS_LOG(EXCEPTION) << "the kind of reduce node [" << cnode->DebugString() + << "] is not single input or single output "; + } + for (auto elem : reduce_axis) { + if (elem > 4) { + MS_LOG(INFO) << "reduce axis is larger than 4 dims reduce axis : [" << elem << "]"; + } + } +} + +void ConvertReduceAttrFraczAnd6HD(const CNodePtr &cnode) { + auto axis = kernel::GetReduceAttrAxis(cnode); + std::vector convert_axis; + SafeCheckFunction(cnode, axis); + auto format = AnfAlgo::GetInputFormat(cnode, 0); + if (format != kOpFormat_FRAC_Z && format != kOpFormat_C1HWNCoC0) { + MS_LOG(EXCEPTION) << "The node [" << cnode->DebugString() << "] format " << format + << " is not needed to change the axis"; + } + for (auto elem : axis) { + switch (elem) { + case kAxis_H: + (void)convert_axis.emplace_back(kAxis_6HD_H); + break; + case kAxis_W: + (void)convert_axis.emplace_back(kAxis_6HD_W); + break; + default: + MS_LOG(INFO) << "reduce axis is axis : [" << elem << "]" + << " but the format is not supported this reduce axis"; + } + } + AnfAlgo::SetNodeAttr(kAttrAxis, MakeValue(convert_axis), cnode); +} +} // namespace + +const BaseRef ChangeAxisOfReduceKernel::DefinePattern() const { + VarPtr X = std::make_shared(); + VarPtr Xs = std::make_shared(); + return VectorRef({X, Xs}); +} + +const AnfNodePtr ChangeAxisOfReduceKernel::Process(const FuncGraphPtr &, const AnfNodePtr &node, + const EquivPtr &) const { + if (node == nullptr || !node->isa() || !AnfAlgo::IsRealKernel(node)) { + return nullptr; + } + if (AnfAlgo::GetOpPattern(node) != kernel::kReducePattern) { + return nullptr; + } + auto convert_map = kReduceConvertMap.find(AnfAlgo::GetInputFormat(node, 0)); + if (convert_map == kReduceConvertMap.end()) { + return nullptr; + } + convert_map->second(node->cast()); + return nullptr; +} +} // namespace opt +} // namespace mindspore diff --git a/mindspore/ccsrc/backend/optimizer/ascend/format_type/chang_axis_of_reduce_kernel.h b/mindspore/ccsrc/backend/optimizer/ascend/format_type/change_axis_of_reduce_kernel.h similarity index 91% rename from mindspore/ccsrc/backend/optimizer/ascend/format_type/chang_axis_of_reduce_kernel.h rename to mindspore/ccsrc/backend/optimizer/ascend/format_type/change_axis_of_reduce_kernel.h index 4be8d3faf6..7f8af37b0e 100644 --- a/mindspore/ccsrc/backend/optimizer/ascend/format_type/chang_axis_of_reduce_kernel.h +++ b/mindspore/ccsrc/backend/optimizer/ascend/format_type/change_axis_of_reduce_kernel.h @@ -1,33 +1,37 @@ -/** - * Copyright 2019 Huawei Technologies Co., Ltd - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#ifndef MINDSPORE_CCSRC_BACKEND_OPTIMIZER_ASCEND_FORMAT_TYPE_CHANGE_AXIS_OF_REDUCE_KENRNEL_H_ -#define MINDSPORE_CCSRC_BACKEND_OPTIMIZER_ASCEND_FORMAT_TYPE_CHANGE_AXIS_OF_REDUCE_KENRNEL_H_ - -#include "backend/optimizer/common/optimizer.h" - -namespace mindspore { -namespace opt { -class ChangeAxisOfReduceKernel : public PatternProcessPass { - public: - explicit ChangeAxisOfReduceKernel(bool multigraph = true) - : PatternProcessPass("change_axis_of_reduce_kernel", multigraph) {} - ~ChangeAxisOfReduceKernel() override = default; - const BaseRef DefinePattern() const override; - const AnfNodePtr Process(const FuncGraphPtr &, const AnfNodePtr &, const EquivPtr &) const override; -}; -} // namespace opt -} // namespace mindspore -#endif // MINDSPORE_CCSRC_BACKEND_OPTIMIZER_ASCEND_FORMAT_TYPE_CHANGE_AXIS_OF_REDUCE_KENRNEL_H_ +/** + * Copyright 2019 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef MINDSPORE_CCSRC_BACKEND_OPTIMIZER_ASCEND_FORMAT_TYPE_CHANGE_AXIS_OF_REDUCE_KENRNEL_H_ +#define MINDSPORE_CCSRC_BACKEND_OPTIMIZER_ASCEND_FORMAT_TYPE_CHANGE_AXIS_OF_REDUCE_KENRNEL_H_ + +#include "backend/optimizer/common/optimizer.h" +#include "ir/anf.h" +#include "ir/func_graph.h" +#include "backend/optimizer/common/pattern_engine.h" +#include "base/base_ref.h" + +namespace mindspore { +namespace opt { +class ChangeAxisOfReduceKernel : public PatternProcessPass { + public: + explicit ChangeAxisOfReduceKernel(bool multigraph = true) + : PatternProcessPass("change_axis_of_reduce_kernel", multigraph) {} + ~ChangeAxisOfReduceKernel() override = default; + const BaseRef DefinePattern() const override; + const AnfNodePtr Process(const FuncGraphPtr &, const AnfNodePtr &, const EquivPtr &) const override; +}; +} // namespace opt +} // namespace mindspore +#endif // MINDSPORE_CCSRC_BACKEND_OPTIMIZER_ASCEND_FORMAT_TYPE_CHANGE_AXIS_OF_REDUCE_KENRNEL_H_ diff --git a/mindspore/ccsrc/backend/optimizer/ascend/format_type/convert_unsupported_transnode_to_aicpu.h b/mindspore/ccsrc/backend/optimizer/ascend/format_type/convert_unsupported_transnode_to_aicpu.h index e534a851ad..35e81f987f 100644 --- a/mindspore/ccsrc/backend/optimizer/ascend/format_type/convert_unsupported_transnode_to_aicpu.h +++ b/mindspore/ccsrc/backend/optimizer/ascend/format_type/convert_unsupported_transnode_to_aicpu.h @@ -13,11 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#ifndef MINDSPORE_CONVERT_UNSUPPORTED_NODE_TO_AICPU_H_ +#define MINDSPORE_CONVERT_UNSUPPORTED_NODE_TO_AICPU_H_ #include #include "backend/optimizer/common/optimizer.h" #include "backend/optimizer/ascend/ascend_helper.h" -#ifndef MINDSPORE_CONVERT_UNSUPPORTED_NODE_TO_AICPU_H -#define MINDSPORE_CONVERT_UNSUPPORTED_NODE_TO_AICPU_H namespace mindspore { namespace opt { class ConvertUnSupportNodeToAICPU : public PatternProcessPass { @@ -34,4 +34,4 @@ class ConvertUnSupportNodeToAICPU : public PatternProcessPass { }; } // namespace opt } // namespace mindspore -#endif // MINDSPORE_CONVERT_UNSUPPORTED_NODE_TO_AICPU_H +#endif // MINDSPORE_CONVERT_UNSUPPORTED_NODE_TO_AICPU_H_ diff --git a/mindspore/ccsrc/backend/optimizer/ascend/format_type/insert_transdata_for_runop.cc b/mindspore/ccsrc/backend/optimizer/ascend/format_type/insert_transdata_for_runop.cc index a4ad2fff95..9742e784d2 100644 --- a/mindspore/ccsrc/backend/optimizer/ascend/format_type/insert_transdata_for_runop.cc +++ b/mindspore/ccsrc/backend/optimizer/ascend/format_type/insert_transdata_for_runop.cc @@ -58,7 +58,7 @@ bool RunOpInsertTransData::Run(const FuncGraphPtr &graph) { auto new_node = kernel_graph->NewCNode(cnode); auto manager = kernel_graph->manager(); MS_EXCEPTION_IF_NULL(manager); - manager->Replace(cnode, new_node); + (void)manager->Replace(cnode, new_node); changed = true; } } diff --git a/mindspore/ccsrc/backend/optimizer/ascend/format_type/merge_cast_to_op.cc b/mindspore/ccsrc/backend/optimizer/ascend/format_type/merge_cast_to_op.cc index e9250248e4..ad0120ecd3 100644 --- a/mindspore/ccsrc/backend/optimizer/ascend/format_type/merge_cast_to_op.cc +++ b/mindspore/ccsrc/backend/optimizer/ascend/format_type/merge_cast_to_op.cc @@ -127,12 +127,12 @@ void ChangeNodeInferInfo(const CNodePtr &cnode, const CNodePtr &cast, const size size_t output_num = AnfAlgo::GetOutputTensorNum(cnode); for (size_t index = 0; index < output_num; ++index) { if (cast_index == index) { - shapes.emplace_back(cast_shape); - types.emplace_back(cast_dtype); + (void)shapes.emplace_back(cast_shape); + (void)types.emplace_back(cast_dtype); continue; } - shapes.emplace_back(AnfAlgo::GetOutputInferShape(cnode, index)); - types.emplace_back(AnfAlgo::GetOutputInferDataType(cnode, index)); + (void)shapes.emplace_back(AnfAlgo::GetOutputInferShape(cnode, index)); + (void)types.emplace_back(AnfAlgo::GetOutputInferDataType(cnode, index)); } AnfAlgo::SetOutputInferTypeAndShape(types, shapes, cnode.get()); } diff --git a/mindspore/ccsrc/backend/optimizer/common/helper.cc b/mindspore/ccsrc/backend/optimizer/common/helper.cc index 36e5ae14a9..46c7168687 100644 --- a/mindspore/ccsrc/backend/optimizer/common/helper.cc +++ b/mindspore/ccsrc/backend/optimizer/common/helper.cc @@ -765,7 +765,7 @@ AbstractBasePtrList RectifyAbstractFromDynamicInput(const PrimitivePtr &primitiv if (input_index >= input_abstract.size()) { MS_LOG(EXCEPTION) << " index " << input_index << " is out of range in input abstract " << input_abstract.size(); } - rectifyed_abs_list.emplace_back(input_abstract[input_index++]); + (void)rectifyed_abs_list.emplace_back(input_abstract[input_index++]); } else { if (item < 0) { MS_LOG(EXCEPTION) << " the dynamic input size check error the index should be -1 or positive number but got " @@ -777,9 +777,9 @@ AbstractBasePtrList RectifyAbstractFromDynamicInput(const PrimitivePtr &primitiv MS_LOG(EXCEPTION) << " index " << input_index << " is out of range in input abstract " << input_abstract.size(); } - dynamic_inputs_abs.emplace_back(input_abstract[input_index++]); + (void)dynamic_inputs_abs.emplace_back(input_abstract[input_index++]); } - rectifyed_abs_list.emplace_back(std::make_shared(dynamic_inputs_abs)); + (void)rectifyed_abs_list.emplace_back(std::make_shared(dynamic_inputs_abs)); } } return rectifyed_abs_list; diff --git a/mindspore/ccsrc/backend/optimizer/pass/convert_tuple_input_to_dynamic_input.cc b/mindspore/ccsrc/backend/optimizer/pass/convert_tuple_input_to_dynamic_input.cc index b00eafba04..fa361b4b91 100644 --- a/mindspore/ccsrc/backend/optimizer/pass/convert_tuple_input_to_dynamic_input.cc +++ b/mindspore/ccsrc/backend/optimizer/pass/convert_tuple_input_to_dynamic_input.cc @@ -44,13 +44,13 @@ int64_t SplitTupleInputs(const FuncGraphPtr &graph, const AnfNodePtr &tuple_inpu // using for graph kernel auto dyn_input_node = AnfAlgo::GetInputNode(make_tuple, j); MS_EXCEPTION_IF_NULL(dyn_input_node); - plant_inputs->emplace_back(dyn_input_node); + (void)plant_inputs->emplace_back(dyn_input_node); } return input_size; } for (size_t index = 0; index < input_size; ++index) { auto dyn_input_node = CreatTupleGetItemNode(graph, tuple_input, index); - plant_inputs->emplace_back(dyn_input_node); + (void)plant_inputs->emplace_back(dyn_input_node); } return input_size; } @@ -70,7 +70,7 @@ void ConvertMakeTupleInputToPlantInputs(const FuncGraphPtr &graph, const CNodePt auto input_node = AnfAlgo::GetInputNode(cnode_ptr, i); MS_EXCEPTION_IF_NULL(input_node); if (AnfAlgo::IsTupleOutput(input_node)) { - dyn_input_sizes.emplace_back(SplitTupleInputs(graph, input_node, &plant_inputs)); + (void)dyn_input_sizes.emplace_back(SplitTupleInputs(graph, input_node, &plant_inputs)); } else { dyn_input_sizes.push_back(-1); plant_inputs.push_back(input_node); diff --git a/mindspore/ccsrc/backend/session/anf_runtime_algorithm.cc b/mindspore/ccsrc/backend/session/anf_runtime_algorithm.cc index b06f2da35f..0c92cf1048 100644 --- a/mindspore/ccsrc/backend/session/anf_runtime_algorithm.cc +++ b/mindspore/ccsrc/backend/session/anf_runtime_algorithm.cc @@ -1429,23 +1429,23 @@ void AnfRuntimeAlgorithm::ReorderOptimizerExecList(NotNull }; if (trans_pose_func(node)) { - transpose_list.emplace_back(node); + (void)transpose_list.emplace_back(node); } else if (trans_data_func(node)) { - trans_list.emplace_back(node); + (void)trans_list.emplace_back(node); } else if (cast_func(node)) { - cast_list.emplace_back(node); + (void)cast_list.emplace_back(node); } else if (kOptOperatorSet.find(AnfAlgo::GetCNodeName(node)) != kOptOperatorSet.end()) { - all_opt_list.emplace_back(node); + (void)all_opt_list.emplace_back(node); } else { - non_opt_list.emplace_back(node); + (void)non_opt_list.emplace_back(node); } } node_list->clear(); - std::copy(non_opt_list.begin(), non_opt_list.end(), std::back_inserter(*node_list)); - std::copy(all_opt_list.begin(), all_opt_list.end(), std::back_inserter(*node_list)); - std::copy(transpose_list.begin(), transpose_list.end(), std::back_inserter(*node_list)); - std::copy(trans_list.begin(), trans_list.end(), std::back_inserter(*node_list)); - std::copy(cast_list.begin(), cast_list.end(), std::back_inserter(*node_list)); + (void)std::copy(non_opt_list.begin(), non_opt_list.end(), std::back_inserter(*node_list)); + (void)std::copy(all_opt_list.begin(), all_opt_list.end(), std::back_inserter(*node_list)); + (void)std::copy(transpose_list.begin(), transpose_list.end(), std::back_inserter(*node_list)); + (void)std::copy(trans_list.begin(), trans_list.end(), std::back_inserter(*node_list)); + (void)std::copy(cast_list.begin(), cast_list.end(), std::back_inserter(*node_list)); } void AnfRuntimeAlgorithm::ReorderPosteriorExecList(NotNull *> node_list) { diff --git a/mindspore/ccsrc/backend/session/kernel_graph.cc b/mindspore/ccsrc/backend/session/kernel_graph.cc index 951386b316..a187f0264e 100644 --- a/mindspore/ccsrc/backend/session/kernel_graph.cc +++ b/mindspore/ccsrc/backend/session/kernel_graph.cc @@ -158,7 +158,7 @@ bool NeedOptimizeCommOp(const AnfNodePtr &node, std::mapcast(); if (value_node == nullptr) { return nullptr; @@ -535,7 +535,7 @@ void KernelGraph::SetKernelInfoForNode(const AnfNodePtr &node) const { std::vector formats = {kOpFormat_DEFAULT}; if (node->isa()) { kernel_info->set_feature_map_flag(false); - types.emplace_back(kTypeUnknown); + (void)types.emplace_back(kTypeUnknown); auto value_node = node->cast(); SyncDeviceInfoToValueNode(value_node, &formats, &types); } diff --git a/mindspore/ccsrc/backend/session/kernel_graph.h b/mindspore/ccsrc/backend/session/kernel_graph.h index c742e86d30..26ebfed554 100644 --- a/mindspore/ccsrc/backend/session/kernel_graph.h +++ b/mindspore/ccsrc/backend/session/kernel_graph.h @@ -281,7 +281,7 @@ class KernelGraph : public FuncGraph { // remove value node form graph bool RemoveValueNodeFromGraph(const ValueNodePtr &value_node); void SetKernelInfoForNode(const AnfNodePtr &node) const; - AnfNodePtr MakeValueNode(const AnfNodePtr &node); + AnfNodePtr MakeValueNode(const AnfNodePtr &node) const; void VisitNodeDescendants(const AnfNodePtr &node, std::queue *visit_queue, std::unordered_set *visited_nodes, bool comm_first = true); // update node edge list diff --git a/mindspore/ccsrc/backend/session/session_basic.cc b/mindspore/ccsrc/backend/session/session_basic.cc index fd9de047ef..3885b79bbc 100644 --- a/mindspore/ccsrc/backend/session/session_basic.cc +++ b/mindspore/ccsrc/backend/session/session_basic.cc @@ -1795,7 +1795,7 @@ void SessionBasic::RunInfer(NotNull func_graph, const std::vector< MS_EXCEPTION_IF_NULL(input_node); auto abstract = input_node->abstract(); MS_EXCEPTION_IF_NULL(abstract); - input_abstracts.emplace_back(abstract); + (void)input_abstracts.emplace_back(abstract); } auto prim = AnfAlgo::GetCNodePrimitive(node); if (prim->isa()) { diff --git a/mindspore/ccsrc/frontend/operator/ops_front_infer_function.cc b/mindspore/ccsrc/frontend/operator/ops_front_infer_function.cc index b0c275354e..7fbb7b4b4c 100644 --- a/mindspore/ccsrc/frontend/operator/ops_front_infer_function.cc +++ b/mindspore/ccsrc/frontend/operator/ops_front_infer_function.cc @@ -187,7 +187,7 @@ AbstractBasePtr InferImplHasType(const AnalysisEnginePtr &, const PrimitivePtr & MS_LOG(EXCEPTION) << "Get the type from AbstractType value failed."; } - TypePtr mode_t = mode_v->cast(); + auto mode_t = mode_v->cast(); MS_EXCEPTION_IF_NULL(args_spec_list[0]); bool v = IsSubtype(args_spec_list[0], mode_t); return std::make_shared(std::make_shared(v), kBool); @@ -252,10 +252,10 @@ AbstractBasePtr InferImplBroadcastGradientArgs(const AnalysisEnginePtr &, const auto arg_x = CheckArg(op_name, args_spec_list, 0); auto arg_y = CheckArg(op_name, args_spec_list, 1); - ValueTuplePtr arg_x_value = arg_x->BuildValue()->cast(); + auto arg_x_value = arg_x->BuildValue()->cast(); MS_EXCEPTION_IF_NULL(arg_x_value); - ValueTuplePtr arg_y_value = arg_y->BuildValue()->cast(); + auto arg_y_value = arg_y->BuildValue()->cast(); MS_EXCEPTION_IF_NULL(arg_y_value); const std::vector x_shape = arg_x_value->value(); @@ -621,7 +621,7 @@ AbstractBasePtr InferImplMakeRecord(const AnalysisEnginePtr &, const PrimitivePt ValuePtr value_track = args_spec_list[0]->GetValueTrack(); MS_EXCEPTION_IF_NULL(value_track); - TypePtr type_ptr = value_track->cast(); + auto type_ptr = value_track->cast(); if (type_ptr == nullptr) { MS_LOG(EXCEPTION) << "Value type error, not Me type:" << value_track->ToString(); } diff --git a/mindspore/ccsrc/frontend/operator/ops_front_infer_function.h b/mindspore/ccsrc/frontend/operator/ops_front_infer_function.h index 6ddacd199d..c4ec7d6c7c 100644 --- a/mindspore/ccsrc/frontend/operator/ops_front_infer_function.h +++ b/mindspore/ccsrc/frontend/operator/ops_front_infer_function.h @@ -70,7 +70,7 @@ class RegisterFrontendPrimitiveEvalHelper { }; #define REGISTER_FRONTENT_PRIMITIVE_EVAL_IMPL(name, primitive, impl) \ - static auto helper_##name = RegisterFrontendPrimitiveEvalHelper(primitive, impl) + auto helper_##name = RegisterFrontendPrimitiveEvalHelper(primitive, impl) } // namespace abstract } // namespace mindspore diff --git a/mindspore/ccsrc/pybind_api/ir/primitive_py.cc b/mindspore/ccsrc/pybind_api/ir/primitive_py.cc index 9eed822f97..593b5ed0d4 100644 --- a/mindspore/ccsrc/pybind_api/ir/primitive_py.cc +++ b/mindspore/ccsrc/pybind_api/ir/primitive_py.cc @@ -51,7 +51,7 @@ void SyncData(const py::object &arg) { } if (py::isinstance(arg)) { auto tensor = py::cast(arg); - (void)tensor->data_sync(); + tensor->data_sync(); } } } // namespace @@ -234,7 +234,7 @@ BaseRef PrimitivePy::RunHookFunction(const VectorRef &args) const { obj = py_args[2]; } CheckHookConsistency(obj, py_args[2]); - hook_grad_.erase(cell_id); + (void)hook_grad_.erase(cell_id); } else { hook_grad_[cell_id] = py_args[2]; obj = py_args[2]; diff --git a/mindspore/core/abstract/prim_structures.cc b/mindspore/core/abstract/prim_structures.cc index 859a6d1f9e..c11ab65d60 100644 --- a/mindspore/core/abstract/prim_structures.cc +++ b/mindspore/core/abstract/prim_structures.cc @@ -57,7 +57,7 @@ AbstractBasePtr InferImplMakeDict(const AnalysisEnginePtr &, const PrimitivePtr MS_LOG(EXCEPTION) << op_name << " evaluator keys should be string, but got " << keyPtr->ToString(); } auto key_string = GetValue(keyPtr); - key_value.emplace_back(key_string, value_list[index]); + (void)key_value.emplace_back(key_string, value_list[index]); } return std::make_shared(key_value); } diff --git a/mindspore/core/ops/bias_add.cc b/mindspore/core/ops/bias_add.cc index 359d18093a..5cca0180d2 100644 --- a/mindspore/core/ops/bias_add.cc +++ b/mindspore/core/ops/bias_add.cc @@ -29,17 +29,17 @@ abstract::ShapePtr BiasAddInferShape(const PrimitivePtr &primitive, const std::v MS_EXCEPTION_IF_NULL(primitive); auto prim_name = primitive->name(); // check - CheckAndConvertUtils::CheckInteger("biasadd_infer", input_args.size(), kEqual, 2, prim_name); + (void)CheckAndConvertUtils::CheckInteger("biasadd_infer", input_args.size(), kEqual, 2, prim_name); auto x_shape = CheckAndConvertUtils::ConvertShapePtrToShape("x_shape", input_args[0]->BuildShape(), prim_name); auto b_shape = CheckAndConvertUtils::ConvertShapePtrToShape("b_shape", input_args[1]->BuildShape(), prim_name); - CheckAndConvertUtils::CheckInteger("x rank", x_shape.size(), kGreaterEqual, 2, prim_name); - CheckAndConvertUtils::CheckInteger("bias rank", b_shape.size(), kEqual, 1, prim_name); + (void)CheckAndConvertUtils::CheckInteger("x rank", x_shape.size(), kGreaterEqual, 2, prim_name); + (void)CheckAndConvertUtils::CheckInteger("bias rank", b_shape.size(), kEqual, 1, prim_name); auto format = Format(GetValue(primitive->GetAttr(kFormat))); auto x_channel = x_shape[1]; if (format != NCHW) { x_channel = x_shape[x_shape.size() - 1]; } - CheckAndConvertUtils::Check("b_shape[0]", b_shape[0], kEqual, "x_shape[1]", x_channel, prim_name); + (void)CheckAndConvertUtils::Check("b_shape[0]", b_shape[0], kEqual, "x_shape[1]", x_channel, prim_name); std::vector out_shape = x_shape; return std::make_shared(out_shape); @@ -48,20 +48,20 @@ abstract::ShapePtr BiasAddInferShape(const PrimitivePtr &primitive, const std::v TypePtr BiasAddInferType(const PrimitivePtr &prim, const std::vector &input_args) { MS_EXCEPTION_IF_NULL(prim); auto prim_name = prim->name(); - CheckAndConvertUtils::CheckInteger("biasadd_infer", input_args.size(), kEqual, 2, prim_name); + (void)CheckAndConvertUtils::CheckInteger("biasadd_infer", input_args.size(), kEqual, 2, prim_name); for (const auto &item : input_args) { MS_EXCEPTION_IF_NULL(item); } std::map types; - types.emplace("input_x", input_args[0]->BuildType()); - types.emplace("bias", input_args[1]->BuildType()); + (void)types.emplace("input_x", input_args[0]->BuildType()); + (void)types.emplace("bias", input_args[1]->BuildType()); auto infer_type = CheckAndConvertUtils::CheckTensorTypeSame(types, common_valid_types, prim->name()); return TypeIdToType(infer_type); } } // namespace void BiasAdd::set_format(const Format &format) { int64_t f = format; - this->AddAttr(kFormat, MakeValue(f)); + (void)this->AddAttr(kFormat, MakeValue(f)); } Format BiasAdd::get_format() const { auto value_ptr = GetAttr(kFormat); diff --git a/mindspore/core/ops/conv2d.cc b/mindspore/core/ops/conv2d.cc index 5e9f23065e..3e97762121 100644 --- a/mindspore/core/ops/conv2d.cc +++ b/mindspore/core/ops/conv2d.cc @@ -60,7 +60,7 @@ std::vector SetPadList(const PrimitivePtr &primitive, const std::vector pad_list[3] = pad_needed_h - pad_left; } else if (pad_mode == PAD) { auto pad = GetValue>(primitive->GetAttr(kPad)); - std::copy(pad.begin(), pad.end(), std::back_inserter(pad_list)); + (void)std::copy(pad.begin(), pad.end(), std::back_inserter(pad_list)); auto pad_top = pad[0]; auto pad_bottom = pad[1]; auto pad_right = pad[2]; @@ -71,8 +71,9 @@ std::vector SetPadList(const PrimitivePtr &primitive, const std::vector h_out = floor(h_out); w_out = floor(w_out); } - CheckAndConvertUtils::CheckInteger("pad_size", pad_list.size(), kEqual, 4, primitive->name()); - primitive->AddAttr(kPadList, MakeValue(CheckAndConvertUtils::CheckPositiveVector(kPad, pad_list, primitive->name()))); + (void)CheckAndConvertUtils::CheckInteger("pad_size", pad_list.size(), kEqual, 4, primitive->name()); + (void)primitive->AddAttr(kPadList, + MakeValue(CheckAndConvertUtils::CheckPositiveVector(kPad, pad_list, primitive->name()))); std::vector out_shape = {x_shape[0], out_channel, h_out, w_out}; return out_shape; } @@ -87,14 +88,14 @@ abstract::ShapePtr Conv2dInferShape(const PrimitivePtr &primitive, const std::ve x_shape = {x_shape[0], x_shape[3], x_shape[1], x_shape[2]}; w_shape = {w_shape[0], w_shape[3], w_shape[1], w_shape[2]}; } - CheckAndConvertUtils::CheckInteger("weight rank", w_shape.size(), kEqual, 4, prim_name); - CheckAndConvertUtils::CheckInteger("x rank", x_shape.size(), kEqual, 4, prim_name); + (void)CheckAndConvertUtils::CheckInteger("weight rank", w_shape.size(), kEqual, 4, prim_name); + (void)CheckAndConvertUtils::CheckInteger("x rank", x_shape.size(), kEqual, 4, prim_name); CheckAndConvertUtils::Check("x_shape[1] / group", x_shape[1] / GetValue(primitive->GetAttr(kGroup)), kEqual, "w_shape[1]", w_shape[1], prim_name); auto out_channel = GetValue(primitive->GetAttr(kOutChannel)); CheckAndConvertUtils::Check("out_channel", out_channel, kEqual, "w_shape[0]", w_shape[0], prim_name); std::vector temp_w; - std::copy(w_shape.begin() + 2, w_shape.end(), std::back_inserter(temp_w)); + (void)std::copy(w_shape.begin() + 2, w_shape.end(), std::back_inserter(temp_w)); CheckAndConvertUtils::Check("kernel_size", GetValue>(primitive->GetAttr(kKernelSize)), kEqual, "w_shape[2:4]", temp_w, prim_name); auto out_shape = SetPadList(primitive, w_shape, x_shape, out_channel); @@ -112,8 +113,8 @@ TypePtr Conv2dInferType(const PrimitivePtr &prim, const std::vector valid_types = {kNumberTypeInt8, kNumberTypeInt32, kNumberTypeInt64, kNumberTypeFloat16, kNumberTypeFloat32}; std::map types; - types.emplace("x", input_args[0]->BuildType()); - types.emplace("w", input_args[1]->BuildType()); + (void)types.emplace("x", input_args[0]->BuildType()); + (void)types.emplace("w", input_args[1]->BuildType()); auto infer_type = CheckAndConvertUtils::CheckTensorTypeSame(types, valid_types, prim->name()); if (infer_type == kNumberTypeInt8) { return TypeIdToType(kNumberTypeInt32); diff --git a/mindspore/core/ops/grad/conv2d_backprop_input.cc b/mindspore/core/ops/grad/conv2d_backprop_input.cc index d12d2934f3..e7d0aaf19d 100644 --- a/mindspore/core/ops/grad/conv2d_backprop_input.cc +++ b/mindspore/core/ops/grad/conv2d_backprop_input.cc @@ -31,7 +31,7 @@ void SetPadList(const PrimitivePtr &primitive, const std::vector &dout_ auto pad_list = GetValue>(primitive->GetAttr(kPadList)); auto pad_mode = PadMode(GetValue(primitive->GetAttr(kPadMode))); if (std::all_of(pad_list.begin(), pad_list.end(), [](int64_t elem) -> bool { return elem != 0; })) { - primitive->AddAttr(kPadList, MakeValue(pad_list)); + (void)primitive->AddAttr(kPadList, MakeValue(pad_list)); } else if (pad_mode == SAME) { auto stride_h = stride[0]; auto stride_w = stride[1]; @@ -51,13 +51,13 @@ void SetPadList(const PrimitivePtr &primitive, const std::vector &dout_ } else if (pad_mode == PAD) { pad_list = GetValue>(primitive->GetAttr(kPad)); } - primitive->AddAttr(kPadList, MakeValue(pad_list)); + (void)primitive->AddAttr(kPadList, MakeValue(pad_list)); } AbstractBasePtr Conv2DBackpropInputInfer(const abstract::AnalysisEnginePtr &, const PrimitivePtr &primitive, const std::vector &input_args) { MS_EXCEPTION_IF_NULL(primitive); auto prim_name = primitive->name(); - CheckAndConvertUtils::CheckInteger("input number", input_args.size(), kEqual, 3, prim_name); + (void)CheckAndConvertUtils::CheckInteger("input number", input_args.size(), kEqual, 3, prim_name); for (const auto &item : input_args) { MS_EXCEPTION_IF_NULL(item); } diff --git a/mindspore/core/ops/mat_mul.cc b/mindspore/core/ops/mat_mul.cc index 0117868bdf..4c83f9b3c7 100644 --- a/mindspore/core/ops/mat_mul.cc +++ b/mindspore/core/ops/mat_mul.cc @@ -25,7 +25,7 @@ namespace { abstract::ShapePtr MatMulInferShape(const PrimitivePtr &primitive, const std::vector &input_args) { MS_EXCEPTION_IF_NULL(primitive); auto prim_name = primitive->name(); - CheckAndConvertUtils::CheckInteger("matmul_infer_input", input_args.size(), kEqual, 2, prim_name); + (void)CheckAndConvertUtils::CheckInteger("matmul_infer_input", input_args.size(), kEqual, 2, prim_name); auto x_shape = CheckAndConvertUtils::ConvertShapePtrToShape("x_shape", input_args[0]->BuildShape(), prim_name); auto w_shape = CheckAndConvertUtils::ConvertShapePtrToShape("w_shape", input_args[1]->BuildShape(), prim_name); auto trans_a = GetValue(primitive->GetAttr(kTransposeA)); @@ -44,9 +44,9 @@ abstract::ShapePtr MatMulInferShape(const PrimitivePtr &primitive, const std::ve out_m = w_shape[0]; w_C = w_shape[1]; } - CheckAndConvertUtils::CheckInteger("dim C is not equal", x_C, kEqual, w_C, prim_name); - primitive->AddAttr("transpose_x1", MakeValue(trans_a)); - primitive->AddAttr("transpose_x2", MakeValue(trans_b)); + (void)CheckAndConvertUtils::CheckInteger("dim C is not equal", x_C, kEqual, w_C, prim_name); + (void)primitive->AddAttr("transpose_x1", MakeValue(trans_a)); + (void)primitive->AddAttr("transpose_x2", MakeValue(trans_b)); std::vector out_shape = {out_n, out_m}; return std::make_shared(out_shape); } @@ -58,8 +58,8 @@ TypePtr MatMulInferType(const PrimitivePtr &prim, const std::vector valid_types = {kNumberTypeInt8, kNumberTypeInt16, kNumberTypeInt32, kNumberTypeInt64, kNumberTypeFloat16, kNumberTypeFloat32, kNumberTypeFloat64}; std::map types; - types.emplace("x", input_args[0]->BuildType()); - types.emplace("w", input_args[1]->BuildType()); + (void)types.emplace("x", input_args[0]->BuildType()); + (void)types.emplace("w", input_args[1]->BuildType()); auto infer_type = CheckAndConvertUtils::CheckTensorTypeSame(types, valid_types, prim->name()); if (infer_type == kNumberTypeInt8) { return std::make_shared(TypeIdToType(kNumberTypeInt32)); @@ -73,9 +73,9 @@ void MatMul::Init(bool transpose_a, bool transpose_b) { set_transpose_b(transpose_b); } -void MatMul::set_transpose_a(bool transpose_a) { AddAttr(kTransposeA, MakeValue(transpose_a)); } +void MatMul::set_transpose_a(bool transpose_a) { (void)AddAttr(kTransposeA, MakeValue(transpose_a)); } -void MatMul::set_transpose_b(bool transpose_b) { AddAttr(kTransposeB, MakeValue(transpose_b)); } +void MatMul::set_transpose_b(bool transpose_b) { (void)AddAttr(kTransposeB, MakeValue(transpose_b)); } bool MatMul::get_transpose_a() const { auto value_ptr = GetAttr(kTransposeA); diff --git a/mindspore/core/ops/max_pool.cc b/mindspore/core/ops/max_pool.cc index d09875324c..19c57e3a59 100644 --- a/mindspore/core/ops/max_pool.cc +++ b/mindspore/core/ops/max_pool.cc @@ -103,7 +103,7 @@ abstract::ShapePtr InferShape(const PrimitivePtr &primitive, const std::vector>(primitive->GetAttr(kKernelSize)); auto pad_mode_value = (primitive->GetAttr(kPadMode)); - PadMode pad_mode = PadMode(GetValue(pad_mode_value)); + auto pad_mode = PadMode(GetValue(pad_mode_value)); auto batch = in_shape[0]; auto channel = in_shape[1]; auto in_h = in_shape[2]; diff --git a/mindspore/core/ops/merge.cc b/mindspore/core/ops/merge.cc index 6cadf59246..4fd818847a 100644 --- a/mindspore/core/ops/merge.cc +++ b/mindspore/core/ops/merge.cc @@ -39,7 +39,7 @@ AbstractBasePtr MergeInfer(const abstract::AnalysisEnginePtr &, const PrimitiveP } std::set template_type = {kNumberTypeBool}; for (auto item : common_valid_types) { - template_type.insert(item); + (void)template_type.insert(item); } CheckAndConvertUtils::CheckScalarOrTensorTypesSame(args, template_type, op_name); std::vector in_shape0 = inputs_shape[0]->cast()->shape(); diff --git a/mindspore/core/ops/primitive_c.cc b/mindspore/core/ops/primitive_c.cc index 645c8d8805..2cb27c7ed5 100644 --- a/mindspore/core/ops/primitive_c.cc +++ b/mindspore/core/ops/primitive_c.cc @@ -22,8 +22,8 @@ namespace mindspore { namespace ops { void PrimitiveC::InitIOName(const std::vector &inputs_name, const std::vector &outputs_name) { - this->AddAttr("input_names", MakeValue(inputs_name)); - this->AddAttr("output_names", MakeValue(outputs_name)); + (void)this->AddAttr("input_names", MakeValue(inputs_name)); + (void)this->AddAttr("output_names", MakeValue(outputs_name)); } AbstractBasePtr PrimitiveC::Infer(const AbstractBasePtrList &abstract_list) { diff --git a/mindspore/core/ops/shape.cc b/mindspore/core/ops/shape.cc index 5fbbe02fd7..499fa27fe3 100644 --- a/mindspore/core/ops/shape.cc +++ b/mindspore/core/ops/shape.cc @@ -34,10 +34,10 @@ AbstractBasePtr ShapeInfer(const abstract::AnalysisEnginePtr &, const PrimitiveP auto in_shape = CheckAndConvertUtils::ConvertShapePtrToShape("x_shape", input_args[0]->BuildShape(), op_name); // infer type AbstractBasePtrList abs_list; - std::transform(in_shape.begin(), in_shape.end(), std::back_inserter(abs_list), - [](int64_t item) -> std::shared_ptr { - return std::make_shared(item); - }); + (void)std::transform(in_shape.begin(), in_shape.end(), std::back_inserter(abs_list), + [](int64_t item) -> std::shared_ptr { + return std::make_shared(item); + }); auto abs = std::make_shared(abs_list); abs->set_value(MakeValue(in_shape)); return abs; diff --git a/mindspore/core/utils/check_convert_utils.cc b/mindspore/core/utils/check_convert_utils.cc index b003509670..bef5154715 100644 --- a/mindspore/core/utils/check_convert_utils.cc +++ b/mindspore/core/utils/check_convert_utils.cc @@ -452,7 +452,7 @@ TypeId CheckAndConvertUtils::CheckTensorTypeSame(const std::mapelement(); MS_EXCEPTION_IF_NULL(element); - types_id.emplace(element->type_id()); + (void)types_id.emplace(element->type_id()); } if (types_id.size() > 1) { buffer << "'s input type is not same : "; diff --git a/mindspore/core/utils/tensor_construct_utils.h b/mindspore/core/utils/tensor_construct_utils.h index 4bb87ab27b..36288485a3 100644 --- a/mindspore/core/utils/tensor_construct_utils.h +++ b/mindspore/core/utils/tensor_construct_utils.h @@ -17,6 +17,7 @@ #define MINDSPORE_CORE_UTILS_TENSOR_CONSTRUCT_UTILS_H_ #include #include "ir/tensor.h" +#include "ir/dtype/type_id.h" namespace mindspore { template void SetTensorData(void *data, T num, size_t data_length) {