Imported Upstream version 1.9.0
[platform/core/ml/nnfw.git] / runtime / onert / core / src / dumper / dot / DotDumper.h
1 /*
2  * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved
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 #include "ir/Graph.h"
18 #include "compiler/LoweredGraph.h"
19
20 #ifndef __ONERT_DUMPER_DOT_DOT_DUMPER_H__
21 #define __ONERT_DUMPER_DOT_DOT_DUMPER_H__
22
23 namespace onert
24 {
25 namespace dumper
26 {
27 namespace dot
28 {
29
30 class DotDumper
31 {
32 public:
33   enum Level
34   {
35     OFF = 0,               //< Do not dump
36     ALL_BUT_CONSTANTS = 1, //< Emit all operations and operands but constants
37     ALL = 2                //< Emit all operations and operands
38   };
39
40 public:
41   DotDumper(const ir::Graph &graph, Level level)
42       : _lowered_graph{nullptr}, _graph(graph), _level{level}
43   {
44   }
45   DotDumper(const compiler::LoweredGraph *lowered_graph, Level level)
46       : _lowered_graph{lowered_graph}, _graph(_lowered_graph->graph()), _level{level}
47   {
48   }
49
50 public:
51   /**
52    * @brief Dump to dot file as tag name if "GRAPH_DOT_DUMP" is set
53    *
54    * @param[in] tag    The name of dot file that would be created
55    * @return N/A
56    */
57   void dump(const std::string &tag);
58
59 private:
60   const compiler::LoweredGraph *_lowered_graph;
61   const ir::Graph &_graph;
62   Level _level;
63 };
64
65 } // namespace dot
66 } // namespace dumper
67 } // namespace onert
68
69 #endif // __ONERT_DUMPER_DOT_DOT_DUMPER_H__