• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright 2021 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_DEBUG_RDR_GRAPH_RECORDER_H_
17 #define MINDSPORE_CCSRC_DEBUG_RDR_GRAPH_RECORDER_H_
18 #include <vector>
19 #include <string>
20 #include <memory>
21 
22 #include "debug/rdr/base_recorder.h"
23 
24 namespace mindspore {
25 struct DumpGraphParams {
26   bool dump_full_name;
27   int dump_mode;
28 };
29 class FuncGraph;
30 using FuncGraphPtr = std::shared_ptr<FuncGraph>;
31 class GraphRecorder : public BaseRecorder {
32  public:
GraphRecorder()33   GraphRecorder() : BaseRecorder(), func_graph_(nullptr), graph_type_("") {}
GraphRecorder(const std::string & module,const std::string & name,const FuncGraphPtr & graph,const std::string & file_type)34   GraphRecorder(const std::string &module, const std::string &name, const FuncGraphPtr &graph,
35                 const std::string &file_type)
36       : BaseRecorder(module, name), func_graph_(graph), graph_type_(file_type) {}
~GraphRecorder()37   ~GraphRecorder() {}
SetGraphType(const std::string & file_type)38   void SetGraphType(const std::string &file_type) { graph_type_ = file_type; }
SetFuncGraph(const FuncGraphPtr & func_graph)39   void SetFuncGraph(const FuncGraphPtr &func_graph) { func_graph_ = func_graph; }
SetDumpFlag(DumpGraphParams info)40   void SetDumpFlag(DumpGraphParams info) { dump_graph_info_ = info; }
41 
42   virtual void Export();
43 
44  private:
45   FuncGraphPtr func_graph_;
46   std::string graph_type_;
47   DumpGraphParams dump_graph_info_{false, 0};
48 };
49 using GraphRecorderPtr = std::shared_ptr<GraphRecorder>;
50 }  // namespace mindspore
51 #endif  // MINDSPORE_CCSRC_DEBUG_RDR_GRAPH_RECORDER_H_
52