diff --git a/mindspore/ccsrc/frontend/optimizer/irpass/partial_eliminate.h b/mindspore/ccsrc/frontend/optimizer/irpass/partial_eliminate.h index f49dc99ed7e..303498a16dc 100644 --- a/mindspore/ccsrc/frontend/optimizer/irpass/partial_eliminate.h +++ b/mindspore/ccsrc/frontend/optimizer/irpass/partial_eliminate.h @@ -24,6 +24,7 @@ #include #include "utils/hash_map.h" +#include "ir/func_graph_cloner.h" #include "frontend/optimizer/irpass.h" #include "frontend/optimizer/optimizer.h" #include "frontend/optimizer/anf_visitor.h" @@ -264,7 +265,7 @@ class ChoicePartialEliminater : public AnfVisitor { MS_LOG(EXCEPTION) << "Can't find parameter of arg:" << arg->DebugString(); } - std::vector GetFuncGraphNewParameters( + static std::vector GetFuncGraphNewParameters( const FuncGraphPtr &func_graph, const std::vector &new_args, const HashMap> &all_old_args_index_map) { MS_EXCEPTION_IF_NULL(func_graph); diff --git a/mindspore/ccsrc/include/common/pybind_api/api_register.h b/mindspore/ccsrc/include/common/pybind_api/api_register.h index 7357e07e65d..ce1ba7ac441 100644 --- a/mindspore/ccsrc/include/common/pybind_api/api_register.h +++ b/mindspore/ccsrc/include/common/pybind_api/api_register.h @@ -17,10 +17,6 @@ #ifndef MINDSPORE_CCSRC_INCLUDE_COMMON_PYBIND_API_API_REGISTER_H_ #define MINDSPORE_CCSRC_INCLUDE_COMMON_PYBIND_API_API_REGISTER_H_ -#include -#include -#include -#include #include #include "pybind11/pybind11.h" #include "pybind11/stl.h" diff --git a/mindspore/core/ir/dtype.h b/mindspore/core/ir/dtype.h index 4cb1af9e1df..d1cfd4bd8d5 100644 --- a/mindspore/core/ir/dtype.h +++ b/mindspore/core/ir/dtype.h @@ -17,17 +17,12 @@ #ifndef MINDSPORE_CORE_IR_DTYPE_H_ #define MINDSPORE_CORE_IR_DTYPE_H_ -#include #include -#include #include -#include #include #include #include #include -#include -#include #include "base/base.h" #include "ir/named.h" diff --git a/mindspore/core/ops/arg_max.cc b/mindspore/core/ops/arg_max.cc index 06e18b69066..c3fcafbe5e2 100644 --- a/mindspore/core/ops/arg_max.cc +++ b/mindspore/core/ops/arg_max.cc @@ -52,7 +52,7 @@ class ArgMaxAbsInfer : public abstract::OpInferBase { axis = axis < 0 ? axis + SizeToLong(x_rank) : axis; auto out_shape_vector = shape_vector; - (void)out_shape_vector.erase(out_shape_vector.cbegin() + LongToSize(axis)); + (void)out_shape_vector.erase(out_shape_vector.cbegin() + axis); return std::make_shared(out_shape_vector); } diff --git a/mindspore/core/ops/select.cc b/mindspore/core/ops/select.cc index 0b0ed31d9f3..d56184d05b2 100644 --- a/mindspore/core/ops/select.cc +++ b/mindspore/core/ops/select.cc @@ -57,6 +57,18 @@ bool CheckScalarOrTensor(ShapeVector input) { return flag; } +void SelectInferShapeCheck(const std::vector &x_shape, const std::vector &y_shape, + const std::vector &cond_shape, size_t shape_size) { + for (size_t i = 0; i < shape_size; i++) { + if ((x_shape[i] > 0 && cond_shape[i] > 0 && x_shape[i] != cond_shape[i]) || + (x_shape[i] > 0 && y_shape[i] > 0 && x_shape[i] != y_shape[i])) { + MS_EXCEPTION(ValueError) + << "For 'Select', shape of tensor condition, x and y must be the same. But got condition shape: " << cond_shape + << ", x shape: " << x_shape << ", y shape: " << y_shape << "."; + } + } +} + abstract::BaseShapePtr SelectInferShape(const PrimitivePtr &, const std::vector &input_args) { auto cond_shape = CheckAndConvertUtils::ConvertShapePtrToShapeMap(input_args[kSelectCondIndex]->BuildShape())[kShape]; auto x_shape = CheckAndConvertUtils::ConvertShapePtrToShapeMap(input_args[kSelectXIndex]->BuildShape())[kShape]; @@ -72,16 +84,8 @@ abstract::BaseShapePtr SelectInferShape(const PrimitivePtr &, const std::vector< MS_EXCEPTION(ValueError) << "For 'Select', shape size of tensor condition, x and y must be equal. But got condition size: " << cond_shape_size << ", x size: " << x_shape_size << ", y size: " << y_shape_size << "."; - } else { - for (size_t i = 0; i < x_shape_size; i++) { - if ((x_shape[i] > 0 && cond_shape[i] > 0 && x_shape[i] != cond_shape[i]) || - (x_shape[i] > 0 && y_shape[i] > 0 && x_shape[i] != y_shape[i])) { - MS_EXCEPTION(ValueError) - << "For 'Select', shape of tensor condition, x and y must be the same. But got condition shape: " - << cond_shape << ", x shape: " << x_shape << ", y shape: " << y_shape << "."; - } - } } + SelectInferShapeCheck(x_shape, y_shape, cond_shape, x_shape_size); } else { if (!(CheckScalarOrTensor(cond_shape) && CheckScalarOrTensor(x_shape) && CheckScalarOrTensor(y_shape))) { MS_EXCEPTION(ValueError) << "For 'Select', when any of cond, x, y is of scalar type, "