• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright 2020 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 #ifndef MINDSPORE_CCSRC_BACKEND_OPTIMIZER_GRAPH_KERNEL_GRAPH_KERNEL_SPLITTER_H_
17 #define MINDSPORE_CCSRC_BACKEND_OPTIMIZER_GRAPH_KERNEL_GRAPH_KERNEL_SPLITTER_H_
18 #include <map>
19 #include <memory>
20 #include <set>
21 #include <string>
22 #include <vector>
23 #include <nlohmann/json.hpp>
24 #include "ir/func_graph.h"
25 #include "backend/optimizer/common/pass.h"
26 
27 namespace mindspore {
28 namespace kernel {
29 struct StitchInfo {
30   std::vector<std::string> stitch_ops;
31   std::vector<std::string> stitch_atomic_ops;
32 };
33 
34 class SplitNodesDecoder {
35  public:
SplitNodesDecoder()36   SplitNodesDecoder() {}
37   ~SplitNodesDecoder() = default;
38   static bool DecodeSplitNodes(const nlohmann::json &kernel_json,
39                                const std::map<std::string, AnfNodePtr> &address_node_map, AnfNodePtrList *res_graphs);
40 };
41 }  // namespace kernel
42 
43 namespace opt {
44 class GraphKernelSplitter : public Pass {
45  public:
GraphKernelSplitter()46   GraphKernelSplitter() : Pass("graph_kernel_splitter") {}
47   ~GraphKernelSplitter() override = default;
48   bool Run(const FuncGraphPtr &func_graph) override;
49 };
50 using GraphKernelSplitterPtr = std::shared_ptr<GraphKernelSplitter>;
51 }  // namespace opt
52 }  // namespace mindspore
53 #endif  // MINDSPORE_CCSRC_BACKEND_OPTIMIZER_GRAPH_KERNEL_GRAPH_KERNEL_SPLITTER_H_
54