!47986 fix code warning
Merge pull request !47986 from lianliguang/master
This commit is contained in:
commit
fa21a9f933
|
@ -55,7 +55,8 @@ class TupleListConvertItemIndexToPositive : public AnfVisitor {
|
|||
FuncGraphPtr fg = node->func_graph();
|
||||
if (is_match_ && fg != nullptr) {
|
||||
auto inputs = node->cast<CNodePtr>()->inputs();
|
||||
inputs[2] = NewValueNode(id_);
|
||||
constexpr auto index_input = 2;
|
||||
inputs[index_input] = NewValueNode(id_);
|
||||
return fg->NewCNode(inputs);
|
||||
}
|
||||
return nullptr;
|
||||
|
@ -493,7 +494,8 @@ class TupleListGetitemDependReorder : public AnfVisitor {
|
|||
|
||||
void Visit(const CNodePtr &cnode) override {
|
||||
// {prim::kPrimDepend, X, Y}
|
||||
if (IsPrimitiveCNode(cnode, prim::kPrimDepend) && cnode->size() == 3) {
|
||||
constexpr auto depend_input_size = 3;
|
||||
if (IsPrimitiveCNode(cnode, prim::kPrimDepend) && cnode->size() == depend_input_size) {
|
||||
x_ = cnode->input(1);
|
||||
y_ = cnode->input(2);
|
||||
}
|
||||
|
|
|
@ -176,7 +176,8 @@ class AddNZeroFilter : public AnfVisitor {
|
|||
}
|
||||
|
||||
// if only two node in filtered_nodes, {make_tuple, x}. return x.
|
||||
if (filtered_Xs_.size() == 2) {
|
||||
constexpr auto input_size = 2;
|
||||
if (filtered_Xs_.size() == input_size) {
|
||||
return filtered_Xs_[1];
|
||||
}
|
||||
|
||||
|
|
|
@ -65,7 +65,8 @@ class PartialEliminater : public AnfVisitor {
|
|||
}
|
||||
// {X, Ys, Xs} if Xs has monad
|
||||
if (!IsValueNode<FuncGraph>(X_)) {
|
||||
MS_LOG(EXCEPTION) << "not support yet as X_ is not a funcgraph. node: " << node->DebugString(2);
|
||||
constexpr auto recursive_level = 2;
|
||||
MS_LOG(EXCEPTION) << "not support yet as X_ is not a funcgraph. node: " << node->DebugString(recursive_level);
|
||||
}
|
||||
auto fg = GetValueNode<FuncGraphPtr>(X_);
|
||||
MS_EXCEPTION_IF_NULL(fg);
|
||||
|
@ -108,7 +109,9 @@ class PartialEliminater : public AnfVisitor {
|
|||
|
||||
X_ = inputs[1];
|
||||
// fill Xs
|
||||
(void)std::copy(inputs.begin() + 2, inputs.end(), std::back_inserter(Xs_));
|
||||
// {Partial, Function, Args....}
|
||||
constexpr auto args_index = 2;
|
||||
(void)std::copy(inputs.begin() + args_index, inputs.end(), std::back_inserter(Xs_));
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -137,7 +140,9 @@ class ChoicePartialEliminater : public AnfVisitor {
|
|||
if (IsValueNode<FuncGraph>(inputs[1])) {
|
||||
fg_list_.push_back(inputs[1]);
|
||||
AnfNodePtrList args;
|
||||
(void)std::copy(inputs.begin() + 2, inputs.end(), std::back_inserter(args));
|
||||
// {Partial, Function, Args....}
|
||||
constexpr auto args_index = 2;
|
||||
(void)std::copy(inputs.begin() + args_index, inputs.end(), std::back_inserter(args));
|
||||
args_list_.push_back(args);
|
||||
}
|
||||
return;
|
||||
|
|
|
@ -108,7 +108,8 @@ class TwoReshapeEliminater : public AnfVisitor {
|
|||
if (IsPrimitiveCNode(node, prim::kPrimReshape)) {
|
||||
auto &inputs = node->cast<CNodePtr>()->inputs();
|
||||
// {PrimReshape, X, Y}
|
||||
if (inputs.size() != 3) {
|
||||
constexpr auto reshape_input_size = 3;
|
||||
if (inputs.size() != reshape_input_size) {
|
||||
return;
|
||||
}
|
||||
prim_ = GetValueNode<PrimitivePtr>(inputs[0]);
|
||||
|
|
|
@ -32,7 +32,9 @@ namespace irpass {
|
|||
class RowTensorEliminater : public OptimizerCaller {
|
||||
public:
|
||||
AnfNodePtr operator()(const OptimizerPtr &, const AnfNodePtr &node) override {
|
||||
PatternNode x, y, z;
|
||||
PatternNode x;
|
||||
PatternNode y;
|
||||
PatternNode z;
|
||||
auto slices = PPrimitive(prim::kPrimMakeRowTensor, x, y, z).MinExtraNodes(0);
|
||||
MATCH_REPLACE(node, PPrimitive(prim::kPrimRowTensorGetIndices, slices), x);
|
||||
MATCH_REPLACE(node, PPrimitive(prim::kPrimRowTensorGetValues, slices), y);
|
||||
|
@ -45,7 +47,8 @@ class RowTensorEliminater : public OptimizerCaller {
|
|||
class RowTensorAddZerosLike : public AnfVisitor {
|
||||
public:
|
||||
AnfNodePtr operator()(const OptimizerPtr &, const AnfNodePtr &node) override {
|
||||
PatternNode x, y;
|
||||
PatternNode x;
|
||||
PatternNode y;
|
||||
auto zeros_like = PPrimitive(prim::kPrimZerosLike, y);
|
||||
MATCH_REPLACE(node, PPrimitive(prim::kPrimRowTensorAdd, x, zeros_like), x);
|
||||
return nullptr;
|
||||
|
|
Loading…
Reference in New Issue