!29212 fix code warning 0117

Merge pull request !29212 from huanghui/fix-warning-0113
This commit is contained in:
i-robot 2022-01-18 14:01:29 +00:00 committed by Gitee
commit 907e44dd12
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
4 changed files with 13 additions and 11 deletions

View File

@ -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;

View File

@ -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<AnfNodePtrList> args_list_{};
void Visit(const AnfNodePtr &node) override {
if (!IsPrimitiveCNode(node, prim::kPrimPartial)) {
if (IsValueNode<FuncGraph>(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<FuncGraph>(inputs[1])) {
fg_list_.push_back(inputs[1]);
@ -144,6 +140,10 @@ class ChoicePartialEliminater : public AnfVisitor {
return;
}
protected:
AnfNodePtrList fg_list_{};
std::vector<AnfNodePtrList> 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<TraceCopy>(extra_inputs[i]->debug_info()));

View File

@ -70,7 +70,7 @@ class ReduceOneEliminater : public AnfVisitor {
size_t x_shape_size = x_shape_.size();
std::vector<int64_t> 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<ValuePtr> elements;
for (size_t i = 0; i < x_shape_size; i++) {

View File

@ -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);