• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright 2022 Huawei Technologies Co., Ltd
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef MINDSPORE_LITE_TOOLS_OPTIMIZER_COMMON_HELPER_H_
18 #define MINDSPORE_LITE_TOOLS_OPTIMIZER_COMMON_HELPER_H_
19 
20 #include <utility>
21 #include <memory>
22 #include <vector>
23 #include "include/backend/optimizer/helper.h"
24 #include "tools/optimizer/common/gllo_utils.h"
25 
26 namespace mindspore {
27 namespace opt {
28 class Helper {
29  public:
30   static std::shared_ptr<std::vector<std::pair<AnfNodePtr, int>>> GetRealNodeUsedList(const FuncGraphPtr &graph,
31                                                                                       const AnfNodePtr &node);
32   static std::shared_ptr<std::vector<std::pair<AnfNodePtr, int>>> GetRealNodeUsedListByOutputIdx(
33     const FuncGraphPtr &graph, const AnfNodePtr &node, size_t output_index);
34   static AnfNodePtr SexpToNode(const BaseRef &sexp, const BaseRef &graph, PrimitiveVarMap *primitive_vars,
35                                bool multigraph);
36 
37  private:
38   static ValueNodePtr CreateValueNodeWithSexp(const BaseRef &sexp);
39   static CNodePtr CreateCNodeWithGraph(const std::vector<AnfNodePtr> &input_nodes, const BaseRef &graph);
40   static VarNodePtr CreateVarNodeWithSexp(const BaseRef &sexp, const BaseRef &graph);
41   static AnfNodePtr HandleSexpVector(const BaseRef &sexp, const BaseRef &graph, PrimitiveVarMap *primitive_vars,
42                                      bool multigraph);
43 };
44 }  // namespace opt
45 }  // namespace mindspore
46 
47 #endif  // MINDSPORE_LITE_TOOLS_OPTIMIZER_COMMON_HELPER_H_
48