From bceff2fb3fc68bb0aa88b886900c34b77340c826 Mon Sep 17 00:00:00 2001 From: surmeh01 Date: Thu, 29 Mar 2018 16:29:27 +0100 Subject: Release 18.03 --- src/armnnUtils/DotSerializer.hpp | 131 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 131 insertions(+) create mode 100644 src/armnnUtils/DotSerializer.hpp (limited to 'src/armnnUtils/DotSerializer.hpp') diff --git a/src/armnnUtils/DotSerializer.hpp b/src/armnnUtils/DotSerializer.hpp new file mode 100644 index 0000000000..3cb591ca72 --- /dev/null +++ b/src/armnnUtils/DotSerializer.hpp @@ -0,0 +1,131 @@ +// +// Copyright © 2017 Arm Ltd. All rights reserved. +// See LICENSE file in the project root for full license information. +// + +#pragma once + +#include +#include +#include + +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() << ""; } + +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 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 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 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 m_Contents; + std::unique_ptr 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 m_Attributes; +}; + +class DotGraph : public DotBase +{ +public: + explicit DotGraph(std::ostream& stream, const char* name); + ~DotGraph(); +private: +}; + +} //namespace armnn -- cgit v1.2.1