aboutsummaryrefslogtreecommitdiff
path: root/src/armnn/test/ProfilerTests.cpp
diff options
context:
space:
mode:
authorColm Donelan <colm.donelan@arm.com>2022-08-08 21:13:34 +0100
committerColm Donelan <colm.donelan@arm.com>2022-08-09 11:40:34 +0100
commita1e1ee8696d842a0e7b660865bd0317d6e509ece (patch)
treeb4249c4d40de8e76d34bfa7327619a208f4b553e /src/armnn/test/ProfilerTests.cpp
parent96ec1cbaffdca0a7afca21dcdce49b1e17f7b827 (diff)
downloadarmnn-a1e1ee8696d842a0e7b660865bd0317d6e509ece.tar.gz
IVGCVSW-7106 Incorrect Json format for some networks.
* ProfilingDetails assumed that every workload description included both tensors and parameters. This is not always the case. * Modify ProfilingDetails::AddDetailsToString to check the next element to be printed before deciding to add a separator and new line. Signed-off-by: Colm Donelan <colm.donelan@arm.com> Change-Id: I2577b0e8a149d0a172ee12975e18b78238d8256e
Diffstat (limited to 'src/armnn/test/ProfilerTests.cpp')
-rw-r--r--src/armnn/test/ProfilerTests.cpp63
1 files changed, 63 insertions, 0 deletions
diff --git a/src/armnn/test/ProfilerTests.cpp b/src/armnn/test/ProfilerTests.cpp
index 6cb8d7fae6..6bccd5c97f 100644
--- a/src/armnn/test/ProfilerTests.cpp
+++ b/src/armnn/test/ProfilerTests.cpp
@@ -12,6 +12,7 @@
#include <Profiling.hpp>
#include <armnn/Optional.hpp>
+#include <armnnUtils/TensorUtils.hpp>
namespace armnn
{
@@ -107,6 +108,68 @@ TEST_CASE("RegisterUnregisterProfilerMultipleThreads")
}
}
+TEST_CASE("LayerWorkloadConstructorWithEmptyWorkloadInfo")
+{
+ // Calling AddDetailsToString with a descriptor that contains no tensors or parameters results
+ // in an invalid piece of JSON as the function assumes there will be something after the input
+ // and output tensors are printed and leaves a hanging ','
+ // This test validates that the fix for that continues to work.
+ armnn::ProfilingDetails classOnTest;
+ armnn::ArgMinMaxDescriptor descriptor;
+ armnn::WorkloadInfo workloadInfo;
+ arm::pipe::ProfilingGuid guid;
+ classOnTest.AddDetailsToString("NeonArgMinMaxWorkload_Construct", descriptor, workloadInfo, guid);
+ std::string result = classOnTest.GetProfilingDetails();
+ // Make sure the string ends with a "GUID": "0"\n}"
+ REQUIRE(result.find("GUID\": \"0\"\n}") != std::string::npos);
+}
+
+TEST_CASE("LayerWorkloadConstructorWithWorkloadInfoOnlyInputTensor")
+{
+ // Calling AddDetailsToString with a descriptor that contains a single inout tensor and no output
+ // tensor or parameters results in an invalid piece of JSON as the function assumes there will be
+ // something after the input and output tensors are printed and leaves a hanging ','
+ // This test validates that the fix for that continues to work.
+
+ armnn::ProfilingDetails classOnTest;
+ armnn::ArgMinMaxDescriptor descriptor;
+ armnn::WorkloadInfo workloadInfo;
+ arm::pipe::ProfilingGuid guid;
+ armnn::TensorInfo inputTensorInfo =
+ armnnUtils::GetTensorInfo(1, 1, 1, 1, armnn::DataLayout::NCHW, armnn::DataType::Float32);
+ workloadInfo.m_InputTensorInfos.push_back(inputTensorInfo);
+
+ classOnTest.AddDetailsToString("NeonArgMinMaxWorkload_Construct", descriptor, workloadInfo, guid);
+ std::string result = classOnTest.GetProfilingDetails();
+ // Make sure the string ends with a "Num Dims\": \"4\"\n\t}\n}"
+ REQUIRE(result.find("Num Dims\": \"4\"\n\t}\n}") != std::string::npos);
+}
+
+TEST_CASE("LayerWorkloadConstructorWithWorkloadInfoInputAndOutputTensorNoParameters")
+{
+ // Calling AddDetailsToString with a descriptor that contains no tensors or parameters results
+ // in an invalid piece of JSON as the function assumes there will be something after the input
+ // and output tensors are printed and leaves a hanging ','
+ // This test validates that the fix for that continues to work.
+ armnn::ProfilingDetails classOnTest;
+ armnn::ArgMinMaxDescriptor descriptor;
+ armnn::WorkloadInfo workloadInfo;
+ arm::pipe::ProfilingGuid guid;
+ armnn::TensorInfo inputTensorInfo =
+ armnnUtils::GetTensorInfo(1, 1, 1, 1, armnn::DataLayout::NCHW, armnn::DataType::Float32);
+ workloadInfo.m_InputTensorInfos.push_back(inputTensorInfo);
+
+ // We'll make the output tensrinfo have 5 dimensions to make errors easier to detect.
+ armnn::TensorInfo outputTensorInfo =
+ armnnUtils::GetTensorInfo(1, 1, 1, 1, 1, armnn::DataLayout::NCDHW, armnn::DataType::Float32);
+ workloadInfo.m_OutputTensorInfos.push_back(outputTensorInfo);
+
+ classOnTest.AddDetailsToString("NeonArgMinMaxWorkload_Construct", descriptor, workloadInfo, guid);
+ std::string result = classOnTest.GetProfilingDetails();
+ // Make sure the string ends with a "Num Dims\": \"4\"\n\t}\n}"
+ REQUIRE(result.find("Num Dims\": \"5\"\n\t}\n}") != std::string::npos);
+}
+
TEST_CASE("ProfilingMacros")
{
// Get a reference to the profiler manager.