From 83443f4ff6962026ebd9c5e3e76983444d588c46 Mon Sep 17 00:00:00 2001 From: Colm Donelan Date: Mon, 8 Aug 2022 21:13:34 +0100 Subject: 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 Change-Id: I2577b0e8a149d0a172ee12975e18b78238d8256e --- src/armnn/test/ProfilerTests.cpp | 63 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) (limited to 'src/armnn/test') 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 #include +#include 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. -- cgit v1.2.1