diff options
author | Keith Davis <keith.davis@arm.com> | 2021-07-20 11:25:22 +0100 |
---|---|---|
committer | Keith Davis <keith.davis@arm.com> | 2021-08-04 11:49:16 +0100 |
commit | 554fa09a0f3d6c9c572634c9d2de9bfb6c3218b0 (patch) | |
tree | 1820a2cadcc1f34667199acff2d044e5d2083ea2 /src/armnn/JsonUtils.hpp | |
parent | 96fd98c28441618fbdf9376fe46a368ef06b19e1 (diff) | |
download | armnn-554fa09a0f3d6c9c572634c9d2de9bfb6c3218b0.tar.gz |
IVGCVSW-5980 JSON profiling output
* Add new ProfilingDetails class to construct operator details string
* Add new macro which helps append layer details to ostream
* Add ProfilingEnabled to NetworkProperties so that profiling can be
realised when loading the network
* Add further optional info to WorkloadInfo specific to convolutions
* Generalise some JsonPrinter functions into JsonUtils for reusability
* Remove explicit enabling of profiling within InferenceModel as it is
done when loading network
* Add ProfilingDetails macros to ConvolutionWorkloads for validation
Signed-off-by: Keith Davis <keith.davis@arm.com>
Change-Id: Ie84bc7dc667e72e6bcb635544f9ead7af1765690
Diffstat (limited to 'src/armnn/JsonUtils.hpp')
-rw-r--r-- | src/armnn/JsonUtils.hpp | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/src/armnn/JsonUtils.hpp b/src/armnn/JsonUtils.hpp new file mode 100644 index 0000000000..44fa7edc85 --- /dev/null +++ b/src/armnn/JsonUtils.hpp @@ -0,0 +1,80 @@ +// +// Copyright © 2021 Arm Ltd and Contributors. All rights reserved. +// SPDX-License-Identifier: MIT +// + +#pragma once + +#include <iomanip> + +#include "armnn/Types.hpp" +#include "armnn/backends/WorkloadInfo.hpp" + +namespace armnn +{ + +class JsonUtils +{ +public: + JsonUtils(std::ostream& outputStream) + : m_NumTabs(0), m_OutputStream(outputStream) + {} + + void PrintTabs() + { + unsigned int numTabs = m_NumTabs; + while ( numTabs-- > 0 ) + { + m_OutputStream << "\t"; + } + } + + void DecrementNumberOfTabs() + { + if ( m_NumTabs == 0 ) + { + return; + } + --m_NumTabs; + } + + void IncrementNumberOfTabs() + { + ++m_NumTabs; + } + + void PrintNewLine() + { + m_OutputStream << std::endl; + } + + void PrintFooter() + { + DecrementNumberOfTabs(); + PrintTabs(); + m_OutputStream << "}"; + } + + void PrintHeader() + { + m_OutputStream << "{" << std::endl; + IncrementNumberOfTabs(); + } + + void PrintArmNNHeader() + { + PrintTabs(); + m_OutputStream << R"("ArmNN": {)" << std::endl; + IncrementNumberOfTabs(); + } + void PrintSeparator() + { + m_OutputStream << ","; + } + +private: + unsigned int m_NumTabs; + std::ostream& m_OutputStream; +}; + +} // namespace armnn
\ No newline at end of file |