ArmNN
 20.02
DotSerializer.hpp
Go to the documentation of this file.
1 //
2 // Copyright © 2017 Arm Ltd. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
6 #pragma once
7 
8 #include <armnn/Types.hpp>
9 
10 #include <ostream>
11 #include <vector>
12 #include <memory>
13 
14 namespace armnn
15 {
16 
17 class DotBase
18 {
19 public:
20  explicit DotBase(std::ostream& stream)
21  : m_Stream(stream) {}
22 
23  std::ostream& GetStream() { return m_Stream; }
24 
25 private:
26  std::ostream& m_Stream;
27 };
28 
29 class HtmlSection : public DotBase
30 {
31 public:
32  explicit HtmlSection(std::ostream& stream)
33  : DotBase(stream) { GetStream() << "<";}
34  ~HtmlSection() { GetStream() << ">"; }
35 };
36 
37 class HtmlSimpleTag : public DotBase
38 {
39 public:
40  explicit HtmlSimpleTag(std::ostream& stream, const char* name)
41  : DotBase(stream)
42  , m_Name(name){ GetStream() << "<" << m_Name << ">"; }
43  ~HtmlSimpleTag() { GetStream() << "</" << m_Name << ">"; }
44 
45 private:
46  const char* m_Name;
47 };
48 
49 class HtmlBold : public HtmlSimpleTag
50 {
51 public:
52  explicit HtmlBold(std::ostream &stream)
53  : HtmlSimpleTag(stream, "B") {}
54 };
55 
56 class HtmlFont : public DotBase
57 {
58 public:
59  explicit HtmlFont(std::ostream& stream, int fontSize, const char* color, const char* face);
60  explicit HtmlFont(std::ostream& stream);
61  ~HtmlFont();
62 };
63 
64 class DotAttributeSet : public DotBase
65 {
66 public:
67  explicit DotAttributeSet(std::ostream& stream);
68  ~DotAttributeSet();
69 
70  DotAttributeSet & AddAttribute(const std::string& name, const std::stringstream& value);
71  DotAttributeSet & AddAttribute(const std::string& name, int value);
72  DotAttributeSet & AddAttribute(const std::string& name, const std::string& value);
73 private:
74  std::vector<std::string> m_Attributes;
75 };
76 
77 class DotEdge : public DotBase
78 {
79 public:
80  explicit DotEdge(std::ostream& stream, LayerGuid fromNodeId, LayerGuid toNodeId);
81  ~DotEdge();
82 
83  DotAttributeSet& GetAttributeSet() { return *m_Attributes.get(); }
84 private:
85  std::unique_ptr<DotAttributeSet> m_Attributes;
86 };
87 
88 class NodeContent : public DotBase
89 {
90 public:
91  explicit NodeContent(std::ostream& stream);
92  NodeContent & SetName(const std::string & name);
93  NodeContent & AddContent(const std::string & content);
94 
95  ~NodeContent();
96 private:
97  std::string m_Name;
98  std::vector<std::string> m_Contents;
99 };
100 
101 class DotNode : public DotBase
102 {
103 public:
104  explicit DotNode(std::ostream& stream, LayerGuid nodeId, const char* label);
105  ~DotNode();
106 
107  NodeContent& GetContents() { return *m_Contents.get(); }
108  DotAttributeSet& GetAttributeSet() { return *m_Attributes.get(); }
109 private:
110  std::unique_ptr<NodeContent> m_Contents;
111  std::unique_ptr<DotAttributeSet> m_Attributes;
112 };
113 
114 class DotDefaults : public DotBase
115 {
116 public:
117  explicit DotDefaults(std::ostream& stream, const char* type);
118  ~DotDefaults();
119 
120  DotAttributeSet& GetAttributeSet() { return *m_Attributes.get(); }
121 private:
122  std::unique_ptr<DotAttributeSet> m_Attributes;
123 };
124 
125 class DotGraph : public DotBase
126 {
127 public:
128  explicit DotGraph(std::ostream& stream, const char* name);
129  ~DotGraph();
130 private:
131 };
132 
133 } //namespace armnn
DotBase(std::ostream &stream)
DotAttributeSet & GetAttributeSet()
Copyright (c) 2020 ARM Limited.
DotAttributeSet & GetAttributeSet()
HtmlSection(std::ostream &stream)
HtmlBold(std::ostream &stream)
NodeContent & GetContents()
std::ostream & GetStream()
HtmlSimpleTag(std::ostream &stream, const char *name)
DotAttributeSet & GetAttributeSet()