diff options
author | Éanna Ó Catháin <eanna.ocathain@arm.com> | 2020-04-01 15:40:12 +0100 |
---|---|---|
committer | Jim Flynn <jim.flynn@arm.com> | 2020-04-01 15:21:49 +0000 |
commit | 0de4712098d4cb9ab66fce6f2f65e783b18bfa37 (patch) | |
tree | 3156d52d3ccdeec0f15c4210af2751772b647cd6 /src/timelineDecoder/JSONTimelineDecoder.hpp | |
parent | 7a7ca576d117b0f433ddb796de3dbcb96a3bb991 (diff) | |
download | armnn-0de4712098d4cb9ab66fce6f2f65e783b18bfa37.tar.gz |
MLECO-756 First cut of adding JSONTimelineDecoder and tests
Change-Id: Ibcd5fdefb5dda3ac3f2a5ff6d6eca618c27c538b
Signed-off-by: Éanna Ó Catháin <eanna.ocathain@arm.com>
Diffstat (limited to 'src/timelineDecoder/JSONTimelineDecoder.hpp')
-rw-r--r-- | src/timelineDecoder/JSONTimelineDecoder.hpp | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/src/timelineDecoder/JSONTimelineDecoder.hpp b/src/timelineDecoder/JSONTimelineDecoder.hpp new file mode 100644 index 0000000000..17ee84b679 --- /dev/null +++ b/src/timelineDecoder/JSONTimelineDecoder.hpp @@ -0,0 +1,82 @@ +// +// Copyright © 2020 Arm Ltd. All rights reserved. +// SPDX-License-Identifier: MIT +// + +#pragma once + +#include "armnn/profiling/ITimelineDecoder.hpp" + +#include <map> +#include <vector> + +namespace armnn +{ +namespace timelinedecoder +{ +class JSONTimelineDecoder : public ITimelineDecoder +{ +public: + struct JSONEntity + { + public: + std::vector<uint64_t> connected_entities; + std::vector<uint64_t> childEntities; + + JSONEntity(uint64_t guid): m_Guid(guid){} + uint64_t GetGuid(); + std::string GetName(); + std::string GetType(); + void SetName(std::string entityName); + void SetType(std::string entityType); + void SetParent(JSONEntity& parent); + void AddConnection(JSONEntity& headEntity, JSONEntity& connectedEntity); + std::map<std::string, std::string> extendedData; + + private: + uint64_t m_Guid; + std::string name; + std::string type; + }; + + struct Model + { + std::map<uint64_t, JSONEntity> jsonEntities; + std::map<uint64_t, Relationship> relationships; + std::map<uint64_t, Label> labels; + std::map<uint64_t, Event> events; + std::map<uint64_t, EventClass> eventClasses; + }; + + void PrintJSON(JSONEntity& entity); + std::string GetJSONString(JSONEntity& rootEntity); + std::string GetJSONEntityString(JSONEntity& entity, int& counter); + + virtual TimelineStatus CreateEntity(const Entity&) override; + virtual TimelineStatus CreateEventClass(const EventClass&) override; + virtual TimelineStatus CreateEvent(const Event&) override; + virtual TimelineStatus CreateLabel(const Label&) override; + virtual TimelineStatus CreateRelationship(const Relationship&) override; + + const Model& GetModel(); + void SetOutgoingCaptureFile(const std::string& basicString); + +private: + Model m_Model; + std::string outputJSONFile = "/tmp/output.json"; + + void HandleRetentionLink(const Relationship& relationship); + void HandleLabelLink(const Relationship& relationship); + void HandleExecutionLink(const Relationship& relationship); + void HandleConnectionLabel(const Relationship& relationship); + void HandleBackendIdLabel(const Relationship& relationship); + void HandleNameLabel(const Relationship& relationship); + void HandleTypeLabel(const Relationship& relationship); + + std::string GetLayerJSONString(JSONEntity& entity, int& counter, std::string& jsonEntityString); + std::string GetWorkloadJSONString(const JSONEntity& entity, int& counter, std::string& jsonEntityString); + std::string GetWorkloadExecutionJSONString(const JSONEntity& entity, std::string& jsonEntityString) const; +}; + +} +}
\ No newline at end of file |