• 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_GRAPH_PREPROCESS_DYNAMIC_SHAPE_H
18 #define MINDSPORE_LITE_TOOLS_OPTIMIZER_GRAPH_PREPROCESS_DYNAMIC_SHAPE_H
19 
20 #include <map>
21 #include <string>
22 #include <utility>
23 #include <vector>
24 #include "ir/anf.h"
25 #include "mindapi/base/shape_vector.h"
26 
27 namespace mindspore {
28 namespace opt {
29 class DynamicShapePreprocessor {
30   typedef std::map<AnfNodePtr, std::pair<std::vector<ShapeVector>, std::vector<ShapeVector>>> ShapeContainer;
31 
32  public:
33   DynamicShapePreprocessor() = default;
34   ~DynamicShapePreprocessor() = default;
35   int Run(const FuncGraphPtr &func_graph);
GetShapeContainer()36   const ShapeContainer &GetShapeContainer() { return op_shape_infos_; }
37 
38  private:
39   bool CheckIsDynamicModel(const FuncGraphPtr &func_graph);
40   int ProcessOps(const FuncGraphPtr &func_graph);
41   int DoInfer(const CNodePtr &cnode, const std::string &op_type);
42   ShapeContainer op_shape_infos_;
43 };
44 }  // namespace opt
45 }  // namespace mindspore
46 
47 #endif  // MINDSPORE_LITE_TOOLS_OPTIMIZER_GRAPH_PREPROCESS_DYNAMIC_SHAPE_H
48