ArmNN
 24.08
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);
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
armnn::HtmlFont
Definition: DotSerializer.hpp:56
armnn::DotAttributeSet::AddAttribute
DotAttributeSet & AddAttribute(const std::string &name, const std::stringstream &value)
Definition: DotSerializer.cpp:95
armnn::HtmlSection::HtmlSection
HtmlSection(std::ostream &stream)
Definition: DotSerializer.hpp:32
armnn::DotBase
Definition: DotSerializer.hpp:17
armnn::DotNode::~DotNode
~DotNode()
Definition: DotSerializer.cpp:200
armnn::NodeContent::SetName
NodeContent & SetName(const std::string &name)
Definition: DotSerializer.cpp:141
armnn::HtmlBold
Definition: DotSerializer.hpp:49
armnn::DotDefaults::~DotDefaults
~DotDefaults()
Definition: DotSerializer.cpp:218
armnn::HtmlSimpleTag
Definition: DotSerializer.hpp:37
armnn::DotEdge
Definition: DotSerializer.hpp:77
armnn::DotAttributeSet
Definition: DotSerializer.hpp:64
armnn::NodeContent
Definition: DotSerializer.hpp:88
armnn::DotGraph::DotGraph
DotGraph(std::ostream &stream, const char *name)
Definition: DotSerializer.cpp:224
armnn::DotNode::GetContents
NodeContent & GetContents()
Definition: DotSerializer.hpp:107
armnn::HtmlSimpleTag::~HtmlSimpleTag
~HtmlSimpleTag()
Definition: DotSerializer.hpp:43
armnn::DotNode::DotNode
DotNode(std::ostream &stream, LayerGuid nodeId, const char *label)
Definition: DotSerializer.cpp:179
armnn::NodeContent::AddContent
NodeContent & AddContent(const std::string &content)
Definition: DotSerializer.cpp:147
armnn::DotGraph
Definition: DotSerializer.hpp:125
armnn::DotNode
Definition: DotSerializer.hpp:101
armnn::HtmlBold::HtmlBold
HtmlBold(std::ostream &stream)
Definition: DotSerializer.hpp:52
armnn::DotEdge::DotEdge
DotEdge(std::ostream &stream, LayerGuid fromNodeId, LayerGuid toNodeId)
Definition: DotSerializer.cpp:119
armnn::DotAttributeSet::~DotAttributeSet
~DotAttributeSet()
Definition: DotSerializer.cpp:78
armnn::DotAttributeSet::DotAttributeSet
DotAttributeSet(std::ostream &stream)
Definition: DotSerializer.cpp:72
armnn::HtmlSimpleTag::HtmlSimpleTag
HtmlSimpleTag(std::ostream &stream, const char *name)
Definition: DotSerializer.hpp:40
LayerGuid
arm::pipe::ProfilingGuid LayerGuid
Define LayerGuid type.
Definition: Types.hpp:26
armnn::DotNode::GetAttributeSet
DotAttributeSet & GetAttributeSet()
Definition: DotSerializer.hpp:108
armnn::HtmlFont::~HtmlFont
~HtmlFont()
Definition: DotSerializer.cpp:66
armnn::DotGraph::~DotGraph
~DotGraph()
Definition: DotSerializer.cpp:230
armnn::DotEdge::GetAttributeSet
DotAttributeSet & GetAttributeSet()
Definition: DotSerializer.hpp:83
armnn::DotBase::GetStream
std::ostream & GetStream()
Definition: DotSerializer.hpp:23
armnn::NodeContent::~NodeContent
~NodeContent()
Definition: DotSerializer.cpp:153
armnn::HtmlFont::HtmlFont
HtmlFont(std::ostream &stream, int fontSize, const char *color, const char *face)
Definition: DotSerializer.cpp:38
armnn::DotEdge::~DotEdge
~DotEdge()
Definition: DotSerializer.cpp:129
armnn::DotDefaults
Definition: DotSerializer.hpp:114
armnn
Copyright (c) 2021 ARM Limited and Contributors.
Definition: 01_00_quick_start.dox:6
Types.hpp
armnn::HtmlSection
Definition: DotSerializer.hpp:29
armnn::DotDefaults::GetAttributeSet
DotAttributeSet & GetAttributeSet()
Definition: DotSerializer.hpp:120
armnn::HtmlSection::~HtmlSection
~HtmlSection()
Definition: DotSerializer.hpp:34
armnn::NodeContent::NodeContent
NodeContent(std::ostream &stream)
Definition: DotSerializer.cpp:136
armnn::DotBase::DotBase
DotBase(std::ostream &stream)
Definition: DotSerializer.hpp:20
armnn::DotDefaults::DotDefaults
DotDefaults(std::ostream &stream, const char *type)
Definition: DotSerializer.cpp:208