aboutsummaryrefslogtreecommitdiff
path: root/src/armnnUtils/DotSerializer.hpp
blob: dfb8c7f22e8b0142d2b7f1a961d54dc05bebde36 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
//
// Copyright © 2017 Arm Ltd. All rights reserved.
// SPDX-License-Identifier: MIT
//

#pragma once

#include <ostream>
#include <vector>
#include <memory>

namespace armnn
{

class DotBase
{
public:
    explicit DotBase(std::ostream& stream)
        : m_Stream(stream) {}

    std::ostream& GetStream() { return m_Stream; }

private:
    std::ostream& m_Stream;
};

class HtmlSection : public DotBase
{
public:
    explicit HtmlSection(std::ostream& stream)
        : DotBase(stream) { GetStream() << "<";}
    ~HtmlSection() { GetStream() << ">"; }
};

class HtmlSimpleTag : public DotBase
{
public:
    explicit HtmlSimpleTag(std::ostream& stream, const char* name)
        : DotBase(stream)
        , m_Name(name){ GetStream() << "<" << m_Name << ">"; }
    ~HtmlSimpleTag() { GetStream() << "</" << m_Name << ">"; }

private:
    const char* m_Name;
};

class HtmlBold : public HtmlSimpleTag
{
public:
    explicit HtmlBold(std::ostream &stream)
        : HtmlSimpleTag(stream, "B") {}
};

class HtmlFont : public DotBase
{
public:
    explicit HtmlFont(std::ostream& stream, int fontSize, const char* color, const char* face);
    explicit HtmlFont(std::ostream& stream);
    ~HtmlFont();
};

class DotAttributeSet : public DotBase
{
public:
    explicit DotAttributeSet(std::ostream& stream);
    ~DotAttributeSet();

    DotAttributeSet & AddAttribute(const std::string& name, const std::stringstream& value);
    DotAttributeSet & AddAttribute(const std::string& name, int value);
    DotAttributeSet & AddAttribute(const std::string& name, const std::string& value);
private:
    std::vector<std::string> m_Attributes;
};

class DotEdge : public DotBase
{
public:
    explicit DotEdge(std::ostream& stream, unsigned int fromNodeId, unsigned int toNodeId);
    ~DotEdge();

    DotAttributeSet& GetAttributeSet() { return *m_Attributes.get(); }
private:
    std::unique_ptr<DotAttributeSet> m_Attributes;
};

class NodeContent : public DotBase
{
public:
    explicit NodeContent(std::ostream& stream);
    NodeContent & SetName(const std::string & name);
    NodeContent & AddContent(const std::string & content);

    ~NodeContent();
private:
    std::string m_Name;
    std::vector<std::string> m_Contents;
};

class DotNode : public DotBase
{
public:
    explicit DotNode(std::ostream& stream, unsigned int nodeId, const char* label);
    ~DotNode();

    NodeContent& GetContents()         { return *m_Contents.get(); }
    DotAttributeSet& GetAttributeSet() { return *m_Attributes.get(); }
private:
    std::unique_ptr<NodeContent>     m_Contents;
    std::unique_ptr<DotAttributeSet> m_Attributes;
};

class DotDefaults : public DotBase
{
public:
    explicit DotDefaults(std::ostream& stream, const char* type);
    ~DotDefaults();

    DotAttributeSet& GetAttributeSet() { return *m_Attributes.get(); }
private:
    std::unique_ptr<DotAttributeSet> m_Attributes;
};

class DotGraph : public DotBase
{
public:
    explicit DotGraph(std::ostream& stream, const char* name);
    ~DotGraph();
private:
};

} //namespace armnn