diff options
author | Colm Donelan <colm.donelan@arm.com> | 2022-08-08 21:13:34 +0100 |
---|---|---|
committer | Nikhil Raj <nikhil.raj@arm.com> | 2022-08-29 10:11:45 +0100 |
commit | 83443f4ff6962026ebd9c5e3e76983444d588c46 (patch) | |
tree | b4249c4d40de8e76d34bfa7327619a208f4b553e /src/armnn/test | |
parent | f0aea2ce42616a23ccfd11f0cb4ed1b0ead2e783 (diff) | |
download | armnn-83443f4ff6962026ebd9c5e3e76983444d588c46.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')
-rw-r--r-- | src/armnn/test/ProfilerTests.cpp | 63 |
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. |