diff --git a/mindspore/ccsrc/frontend/optimizer/irpass/parameter_eliminate.h b/mindspore/ccsrc/frontend/optimizer/irpass/parameter_eliminate.h index 0ebe216ddbb..8adae838ec0 100644 --- a/mindspore/ccsrc/frontend/optimizer/irpass/parameter_eliminate.h +++ b/mindspore/ccsrc/frontend/optimizer/irpass/parameter_eliminate.h @@ -36,7 +36,7 @@ class ParameterEliminator { public: ParameterEliminator() = default; virtual ~ParameterEliminator() = default; - bool operator()(const FuncGraphPtr &func_graph, const OptimizerPtr &optimizer) { + bool operator()(const FuncGraphPtr &func_graph, const OptimizerPtr &) { const auto &manager = func_graph->manager(); MS_EXCEPTION_IF_NULL(manager); bool changes = false; diff --git a/mindspore/ccsrc/frontend/optimizer/irpass/partial_eliminate.h b/mindspore/ccsrc/frontend/optimizer/irpass/partial_eliminate.h index 1573da0bea8..9e6d19896fa 100644 --- a/mindspore/ccsrc/frontend/optimizer/irpass/partial_eliminate.h +++ b/mindspore/ccsrc/frontend/optimizer/irpass/partial_eliminate.h @@ -85,8 +85,9 @@ class PartialEliminater : public AnfVisitor { // reorder the formal parameter of fg. AnfNodePtrList new_params; - std::copy(fg->parameters().cbegin() + xs_size, fg->parameters().cend(), std::back_inserter(new_params)); - std::copy(fg->parameters().cbegin(), fg->parameters().cbegin() + xs_size, std::back_inserter(new_params)); + std::copy(fg->parameters().cbegin() + SizeToLong(xs_size), fg->parameters().cend(), std::back_inserter(new_params)); + std::copy(fg->parameters().cbegin(), fg->parameters().cbegin() + SizeToLong(xs_size), + std::back_inserter(new_params)); fg->manager()->SetParameters(fg, new_params); return new_node; } @@ -116,15 +117,11 @@ class ChoicePartialEliminater : public AnfVisitor { public: virtual ~ChoicePartialEliminater() = default; - protected: - AnfNodePtrList fg_list_{}; - std::vector args_list_{}; - void Visit(const AnfNodePtr &node) override { if (!IsPrimitiveCNode(node, prim::kPrimPartial)) { if (IsValueNode(node)) { fg_list_.push_back(node); - args_list_.push_back(AnfNodePtrList{}); + (void)args_list_.push_back(AnfNodePtrList{}); } return; } @@ -133,7 +130,6 @@ class ChoicePartialEliminater : public AnfVisitor { // {prim::kPrimPartial, G, Xs} if (inputs.size() < 3) { MS_LOG(EXCEPTION) << "Node should be Partial CNode, but: " << node->DebugString(); - return; } if (IsValueNode(inputs[1])) { fg_list_.push_back(inputs[1]); @@ -144,6 +140,10 @@ class ChoicePartialEliminater : public AnfVisitor { return; } + protected: + AnfNodePtrList fg_list_{}; + std::vector args_list_{}; + // return value: true -- continue replace; false -- return nullptr; bool CheckFuncGraphAndArgs() { // Either one should be {Partial, G, X} @@ -237,7 +237,8 @@ class ChoicePartialEliminater : public AnfVisitor { AnfNodePtrList new_params; new_params.reserve(anchor_params_size + extra_input_counter); // reuse parameters for anchor_args; - std::copy(anchor_fg_params.cbegin(), anchor_fg_params.cbegin() + anchor_args_size, std::back_inserter(new_params)); + std::copy(anchor_fg_params.cbegin(), anchor_fg_params.cbegin() + SizeToLong(anchor_args_size), + std::back_inserter(new_params)); // Extra parameters; for (size_t i = 0; i < extra_inputs.size(); ++i) { TraceGuard guard(std::make_shared(extra_inputs[i]->debug_info())); diff --git a/mindspore/ccsrc/frontend/optimizer/irpass/reduce_eliminate.h b/mindspore/ccsrc/frontend/optimizer/irpass/reduce_eliminate.h index aa2211f3cc4..a6f80ecd203 100644 --- a/mindspore/ccsrc/frontend/optimizer/irpass/reduce_eliminate.h +++ b/mindspore/ccsrc/frontend/optimizer/irpass/reduce_eliminate.h @@ -70,7 +70,7 @@ class ReduceOneEliminater : public AnfVisitor { size_t x_shape_size = x_shape_.size(); std::vector positive_axis; std::transform(axis_.begin(), axis_.end(), std::back_inserter(positive_axis), - [x_shape_size](int64_t idx) { return idx < 0 ? idx + x_shape_size : idx; }); + [x_shape_size](int64_t idx) { return idx < 0 ? idx + SizeToLong(x_shape_size) : idx; }); std::vector elements; for (size_t i = 0; i < x_shape_size; i++) { diff --git a/mindspore/ccsrc/frontend/optimizer/irpass/row_tensor_eliminate.h b/mindspore/ccsrc/frontend/optimizer/irpass/row_tensor_eliminate.h index 6235e71a226..73b60818e2b 100644 --- a/mindspore/ccsrc/frontend/optimizer/irpass/row_tensor_eliminate.h +++ b/mindspore/ccsrc/frontend/optimizer/irpass/row_tensor_eliminate.h @@ -45,6 +45,7 @@ class RowTensorEliminater : public OptimizerCaller { // {prim::kPrimRowTensorAdd, rowtensor, zeros_like(x)} -> rowtensor class RowTensorAddZerosLike : public AnfVisitor { + public: AnfNodePtr operator()(const OptimizerPtr &, const AnfNodePtr &node) override { PatternNode x, y; auto zeros_like = PPrimitive(prim::kPrimZerosLike, y);