aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Davis <keith.davis@arm.com>2021-08-09 16:49:18 +0100
committerMatthew Sloyan <matthew.sloyan@arm.com>2021-08-10 14:07:27 +0000
commitf487486c843a38fced90229923433d09f99fc2e5 (patch)
tree63a2268196279a5c97c3b9dea86024f0bf4a751e
parentbcd860a30eba22bb2ba0943ad705734ce0ec5b23 (diff)
downloadarmnn-f487486c843a38fced90229923433d09f99fc2e5.tar.gz
IVGCVSW-6292 Allow profiling details to be switched off during profiling
* Add switch for network details during profiling Signed-off-by: Keith Davis <keith.davis@arm.com> Change-Id: I8bd49fd58f0e0255598106e9ab36806ee78391d6
-rw-r--r--include/armnn/IProfiler.hpp4
-rw-r--r--include/armnn/IRuntime.hpp32
-rw-r--r--src/armnn/LoadedNetwork.cpp2
-rw-r--r--src/armnn/Profiling.cpp12
-rw-r--r--src/armnn/Profiling.hpp4
-rw-r--r--src/backends/reference/workloads/RefConvolution2dWorkload.cpp2
-rw-r--r--tests/ExecuteNetwork/ExecuteNetwork.cpp7
-rw-r--r--tests/ExecuteNetwork/ExecuteNetworkParams.hpp1
-rw-r--r--tests/ExecuteNetwork/ExecuteNetworkProgramOptions.cpp7
-rw-r--r--tests/InferenceModel.hpp5
10 files changed, 59 insertions, 17 deletions
diff --git a/include/armnn/IProfiler.hpp b/include/armnn/IProfiler.hpp
index 5ce42017d9..5fbb67000a 100644
--- a/include/armnn/IProfiler.hpp
+++ b/include/armnn/IProfiler.hpp
@@ -39,6 +39,10 @@ public:
/// @param [out] outStream The stream where to write the profiling results to.
void Print(std::ostream& outStream) const;
+ /// Print out details of each layer within the network that possesses a descriptor.
+ /// Also outputs tensor info.
+ void EnableNetworkDetailsToStdOut();
+
~IProfiler();
IProfiler();
diff --git a/include/armnn/IRuntime.hpp b/include/armnn/IRuntime.hpp
index 1bae94374e..8c269dee49 100644
--- a/include/armnn/IRuntime.hpp
+++ b/include/armnn/IRuntime.hpp
@@ -39,36 +39,40 @@ struct INetworkProperties
m_ExportEnabled(exportEnabled),
m_AsyncEnabled(asyncEnabled),
m_ProfilingEnabled(profilingEnabled),
+ m_OutputNetworkDetails(false),
m_InputSource(m_ImportEnabled ? MemorySource::Malloc : MemorySource::Undefined),
m_OutputSource(m_ExportEnabled ? MemorySource::Malloc : MemorySource::Undefined)
{}
ARMNN_DEPRECATED_MSG("Please use INetworkProperties constructor without numThreads argument")
INetworkProperties(bool asyncEnabled,
- MemorySource m_InputSource,
- MemorySource m_OutputSource,
+ MemorySource inputSource,
+ MemorySource outputSource,
size_t numThreads,
bool profilingEnabled = false)
- : m_ImportEnabled(m_InputSource != MemorySource::Undefined),
- m_ExportEnabled(m_OutputSource != MemorySource::Undefined),
+ : m_ImportEnabled(inputSource != MemorySource::Undefined),
+ m_ExportEnabled(outputSource != MemorySource::Undefined),
m_AsyncEnabled(asyncEnabled),
m_ProfilingEnabled(profilingEnabled),
- m_InputSource(m_InputSource),
- m_OutputSource(m_OutputSource)
+ m_OutputNetworkDetails(false),
+ m_InputSource(inputSource),
+ m_OutputSource(outputSource)
{
armnn::IgnoreUnused(numThreads);
}
INetworkProperties(bool asyncEnabled,
- MemorySource m_InputSource,
- MemorySource m_OutputSource,
- bool profilingEnabled = false)
- : m_ImportEnabled(m_InputSource != MemorySource::Undefined),
- m_ExportEnabled(m_OutputSource != MemorySource::Undefined),
+ MemorySource inputSource,
+ MemorySource outputSource,
+ bool profilingEnabled = false,
+ bool outputDetails = false)
+ : m_ImportEnabled(inputSource != MemorySource::Undefined),
+ m_ExportEnabled(outputSource != MemorySource::Undefined),
m_AsyncEnabled(asyncEnabled),
m_ProfilingEnabled(profilingEnabled),
- m_InputSource(m_InputSource),
- m_OutputSource(m_OutputSource)
+ m_OutputNetworkDetails(outputDetails),
+ m_InputSource(inputSource),
+ m_OutputSource(outputSource)
{}
/// Deprecated and will be removed in future release.
@@ -80,6 +84,8 @@ struct INetworkProperties
const bool m_ProfilingEnabled;
+ const bool m_OutputNetworkDetails;
+
const MemorySource m_InputSource;
const MemorySource m_OutputSource;
diff --git a/src/armnn/LoadedNetwork.cpp b/src/armnn/LoadedNetwork.cpp
index c8dbcaaeb5..70b5f4e89b 100644
--- a/src/armnn/LoadedNetwork.cpp
+++ b/src/armnn/LoadedNetwork.cpp
@@ -127,6 +127,8 @@ LoadedNetwork::LoadedNetwork(std::unique_ptr<IOptimizedNetwork> net,
m_Profiler->EnableProfiling(networkProperties.m_ProfilingEnabled);
+ if (networkProperties.m_OutputNetworkDetails) m_Profiler->EnableNetworkDetailsToStdOut();
+
Graph& order = m_OptimizedNetwork->pOptimizedNetworkImpl->GetGraph().TopologicalSort();
//First create tensor handlers, backends and workload factories.
//Handlers are created before workloads are.
diff --git a/src/armnn/Profiling.cpp b/src/armnn/Profiling.cpp
index 509e9dec08..b9afc8665a 100644
--- a/src/armnn/Profiling.cpp
+++ b/src/armnn/Profiling.cpp
@@ -196,6 +196,11 @@ void ProfilerImpl::EnableProfiling(bool enableProfiling)
m_ProfilingEnabled = enableProfiling;
}
+void ProfilerImpl::EnableNetworkDetailsToStdOut()
+{
+ m_EnableDetailsToStdOut = true;
+}
+
Event* ProfilerImpl::BeginEvent(armnn::IProfiler* profiler,
const BackendId& backendId,
const std::string& label,
@@ -378,7 +383,7 @@ void ProfilerImpl::Print(std::ostream& outStream) const
printer.PrintHeader();
printer.PrintArmNNHeader();
- if (m_ProfilingDetails.get()->DetailsExist())
+ if (m_ProfilingDetails.get()->DetailsExist() && m_EnableDetailsToStdOut)
{
JsonChildObject detailsObject{ "layer_details" };
ConfigureDetailsObject(detailsObject, m_ProfilingDetails.get()->GetProfilingDetails());
@@ -539,6 +544,11 @@ void IProfiler::EnableProfiling(bool enableProfiling)
pProfilerImpl->EnableProfiling(enableProfiling);
}
+void IProfiler::EnableNetworkDetailsToStdOut()
+{
+ pProfilerImpl->EnableNetworkDetailsToStdOut();
+}
+
bool IProfiler::IsProfilingEnabled()
{
return pProfilerImpl->IsProfilingEnabled();
diff --git a/src/armnn/Profiling.hpp b/src/armnn/Profiling.hpp
index a336a0ee2a..372b489abf 100644
--- a/src/armnn/Profiling.hpp
+++ b/src/armnn/Profiling.hpp
@@ -59,6 +59,9 @@ public:
// Checks if profiling is enabled.
bool IsProfilingEnabled();
+ // Enables outputting the layer descriptors and infos to stdout
+ void EnableNetworkDetailsToStdOut();
+
// Increments the event tag, allowing grouping of events in a user-defined manner (e.g. per inference).
void UpdateEventTag();
@@ -99,6 +102,7 @@ public:
std::vector<EventPtr> m_EventSequence;
DescPtr m_ProfilingDetails = std::make_unique<ProfilingDetails>();
bool m_ProfilingEnabled;
+ bool m_EnableDetailsToStdOut;
};
// Singleton profiler manager.
diff --git a/src/backends/reference/workloads/RefConvolution2dWorkload.cpp b/src/backends/reference/workloads/RefConvolution2dWorkload.cpp
index b0b88b18db..20c5c08b17 100644
--- a/src/backends/reference/workloads/RefConvolution2dWorkload.cpp
+++ b/src/backends/reference/workloads/RefConvolution2dWorkload.cpp
@@ -26,7 +26,7 @@ RefConvolution2dWorkload::RefConvolution2dWorkload(
}
// Report Profiling Details
- ARMNN_REPORT_PROFILING_WORKLOAD_DESC("RefConvolution2dWorkload_Execute",
+ ARMNN_REPORT_PROFILING_WORKLOAD_DESC("RefConvolution2dWorkload_Construct",
descriptor.m_Parameters,
detailsInfo,
this->GetGuid());
diff --git a/tests/ExecuteNetwork/ExecuteNetwork.cpp b/tests/ExecuteNetwork/ExecuteNetwork.cpp
index e757d2c992..64296d31b7 100644
--- a/tests/ExecuteNetwork/ExecuteNetwork.cpp
+++ b/tests/ExecuteNetwork/ExecuteNetwork.cpp
@@ -324,6 +324,7 @@ int MainImpl(const ExecuteNetworkParams& params,
inferenceModelParams.m_MLGOTuningFilePath = params.m_MLGOTuningFilePath;
inferenceModelParams.m_AsyncEnabled = params.m_Concurrent;
inferenceModelParams.m_ThreadPoolSize = params.m_ThreadPoolSize;
+ inferenceModelParams.m_OutputDetailsToStdOut = params.m_OutputDetailsToStdOut;
for(const std::string& inputName: params.m_InputNames)
{
@@ -768,6 +769,12 @@ int main(int argc, const char* argv[])
return EXIT_FAILURE;
}
+ if (ProgramOptions.m_ExNetParams.m_OutputDetailsToStdOut && !ProgramOptions.m_ExNetParams.m_EnableProfiling)
+ {
+ ARMNN_LOG(fatal) << "You must enable profiling if you would like to output layer details";
+ return EXIT_FAILURE;
+ }
+
// Create runtime
std::shared_ptr<armnn::IRuntime> runtime(armnn::IRuntime::Create(ProgramOptions.m_RuntimeOptions));
diff --git a/tests/ExecuteNetwork/ExecuteNetworkParams.hpp b/tests/ExecuteNetwork/ExecuteNetworkParams.hpp
index fe0c446087..97c605b0a7 100644
--- a/tests/ExecuteNetwork/ExecuteNetworkParams.hpp
+++ b/tests/ExecuteNetwork/ExecuteNetworkParams.hpp
@@ -43,6 +43,7 @@ struct ExecuteNetworkParams
std::string m_ModelFormat;
std::string m_ModelPath;
unsigned int m_NumberOfThreads;
+ bool m_OutputDetailsToStdOut;
std::vector<std::string> m_OutputNames;
std::vector<std::string> m_OutputTensorFiles;
std::vector<std::string> m_OutputTypes;
diff --git a/tests/ExecuteNetwork/ExecuteNetworkProgramOptions.cpp b/tests/ExecuteNetwork/ExecuteNetworkProgramOptions.cpp
index 6ac64ffff2..1fd4b3d96d 100644
--- a/tests/ExecuteNetwork/ExecuteNetworkProgramOptions.cpp
+++ b/tests/ExecuteNetwork/ExecuteNetworkProgramOptions.cpp
@@ -407,7 +407,12 @@ ProgramOptions::ProgramOptions() : m_CxxOptions{"ExecuteNetwork",
("u,counter-capture-period",
"If profiling is enabled in 'file-only' mode this is the capture period that will be used in the test",
- cxxopts::value<uint32_t>(m_RuntimeOptions.m_ProfilingOptions.m_CapturePeriod)->default_value("150"));
+ cxxopts::value<uint32_t>(m_RuntimeOptions.m_ProfilingOptions.m_CapturePeriod)->default_value("150"))
+
+ ("output-network-details",
+ "Outputs layer tensor infos and descriptors to std out. Defaults to off.",
+ cxxopts::value<bool>(m_ExNetParams.m_OutputDetailsToStdOut)->default_value("false")
+ ->implicit_value("true"));
}
catch (const std::exception& e)
{
diff --git a/tests/InferenceModel.hpp b/tests/InferenceModel.hpp
index 4d2b167522..1db287f453 100644
--- a/tests/InferenceModel.hpp
+++ b/tests/InferenceModel.hpp
@@ -100,6 +100,7 @@ struct Params
bool m_InferOutputShape;
bool m_EnableFastMath;
bool m_SaveCachedNetwork;
+ bool m_OutputDetailsToStdOut;
std::string m_CachedNetworkFilePath;
unsigned int m_NumberOfThreads;
std::string m_MLGOTuningFilePath;
@@ -119,6 +120,7 @@ struct Params
, m_InferOutputShape(false)
, m_EnableFastMath(false)
, m_SaveCachedNetwork(false)
+ , m_OutputDetailsToStdOut(false)
, m_CachedNetworkFilePath("")
, m_NumberOfThreads(0)
, m_MLGOTuningFilePath("")
@@ -489,7 +491,8 @@ public:
armnn::INetworkProperties networkProperties(params.m_AsyncEnabled,
armnn::MemorySource::Undefined,
armnn::MemorySource::Undefined,
- enableProfiling);
+ enableProfiling,
+ params.m_OutputDetailsToStdOut);
std::string errorMessage;
ret = m_Runtime->LoadNetwork(m_NetworkIdentifier, std::move(optNet), errorMessage, networkProperties);