aboutsummaryrefslogtreecommitdiff
path: root/src/armnn/ProfilingDetails.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/armnn/ProfilingDetails.hpp')
-rw-r--r--src/armnn/ProfilingDetails.hpp69
1 files changed, 41 insertions, 28 deletions
diff --git a/src/armnn/ProfilingDetails.hpp b/src/armnn/ProfilingDetails.hpp
index 68ec00e7f8..e1f357b3f3 100644
--- a/src/armnn/ProfilingDetails.hpp
+++ b/src/armnn/ProfilingDetails.hpp
@@ -1,5 +1,5 @@
//
-// Copyright © 2021 Arm Ltd and Contributors. All rights reserved.
+// Copyright © 2022 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
@@ -22,7 +22,7 @@ class ProfilingDetails : public JsonUtils
{
public:
/// Constructor
- ProfilingDetails() : JsonUtils(m_ProfilingDetails), m_DetailsExist(false), m_PrintSeparator(false)
+ ProfilingDetails() : JsonUtils(m_ProfilingDetails), m_DetailsExist(false)
{}
/// Destructor
@@ -30,7 +30,7 @@ public:
{}
/// Add to the ProfilingDetails
- template<typename DescriptorType>
+ template <typename DescriptorType>
void AddDetailsToString(const std::string& workloadName,
const DescriptorType& desc,
const WorkloadInfo& infos,
@@ -50,42 +50,54 @@ public:
PrintNewLine();
PrintTabs();
m_ProfilingDetails << std::quoted("GUID") << ": " << std::quoted(std::to_string(guid));
- PrintSeparator();
- PrintNewLine();
+
+ // From this point onwards everything is potentially optional so we must be careful of separators and new lines.
// Print tensor infos and related data types
- PrintInfos(infos.m_InputTensorInfos, "Input");
+ if (!infos.m_InputTensorInfos.empty())
+ {
+ PrintSeparator();
+ PrintNewLine();
+ // Only add separator and new line if there is an output tensor info.
+ PrintInfos(infos.m_InputTensorInfos, "Input", !infos.m_OutputTensorInfos.empty());
+ }
- PrintInfos(infos.m_OutputTensorInfos, "Output");
+ if (!infos.m_OutputTensorInfos.empty())
+ {
+ // Don't add a separator as we don't know what's next.
+ PrintInfos(infos.m_OutputTensorInfos, "Output", false);
+ }
- if ( infos.m_BiasTensorInfo.has_value())
+ if (infos.m_BiasTensorInfo.has_value())
{
- PrintInfo(infos.m_BiasTensorInfo.value(), "Bias");
+ PrintSeparator();
+ PrintNewLine();
+ PrintInfo(infos.m_BiasTensorInfo.value(), "Bias", false);
}
- if ( infos.m_WeightsTensorInfo.has_value())
+
+ if (infos.m_WeightsTensorInfo.has_value())
{
- PrintInfo(infos.m_WeightsTensorInfo.value(), "Weights");
+ PrintSeparator();
+ PrintNewLine();
+ PrintInfo(infos.m_WeightsTensorInfo.value(), "Weights", false);
}
- if ( infos.m_ConvolutionMethod.has_value())
+
+ if (infos.m_ConvolutionMethod.has_value())
{
+ PrintSeparator();
+ PrintNewLine();
PrintTabs();
m_ProfilingDetails << std::quoted("Convolution Method") << ": "
<< std::quoted(infos.m_ConvolutionMethod.value());
-
- PrintSeparator();
- PrintNewLine();
}
ParameterStringifyFunction extractParams = [this](const std::string& name, const std::string& value) {
- if (m_PrintSeparator)
- {
- PrintSeparator();
- PrintNewLine();
- }
+ // Always begin with a separator and new line.
+ PrintSeparator();
+ PrintNewLine();
PrintTabs();
m_ProfilingDetails << std::quoted(name) << " : " << std::quoted(value);
- m_PrintSeparator = true;
};
StringifyLayerParameters<DescriptorType>::Serialize(extractParams, desc);
@@ -94,7 +106,6 @@ public:
PrintFooter();
m_DetailsExist = true;
- m_PrintSeparator = false;
}
/// Get the ProfilingDetails
@@ -111,13 +122,13 @@ public:
private:
// Print tensor infos and related data types
- void PrintInfo(const TensorInfo& info, const std::string& ioString)
+ void PrintInfo(const TensorInfo& info, const std::string& ioString, bool addSeparator = true)
{
const std::vector<TensorInfo> infoVect{ info };
- PrintInfos(infoVect, ioString);
+ PrintInfos(infoVect, ioString, addSeparator);
}
- void PrintInfos(const std::vector<TensorInfo>& infos, const std::string& ioString)
+ void PrintInfos(const std::vector<TensorInfo>& infos, const std::string& ioString, bool addSeparator = true)
{
for ( size_t i = 0; i < infos.size(); i++ )
{
@@ -158,15 +169,17 @@ private:
// Close out the scope
PrintNewLine();
PrintFooter();
- PrintSeparator();
- PrintNewLine();
+ if (addSeparator)
+ {
+ PrintSeparator();
+ PrintNewLine();
+ }
}
}
/// Stores ProfilingDetails
std::ostringstream m_ProfilingDetails;
bool m_DetailsExist;
- bool m_PrintSeparator;
};