aboutsummaryrefslogtreecommitdiff
path: root/src/backends
diff options
context:
space:
mode:
Diffstat (limited to 'src/backends')
-rw-r--r--src/backends/backendsCommon/test/layerTests/DebugTestImpl.cpp141
-rw-r--r--src/backends/backendsCommon/test/layerTests/DebugTestImpl.hpp48
-rw-r--r--src/backends/reference/test/RefLayerTests.cpp59
-rw-r--r--src/backends/reference/workloads/Debug.cpp110
-rw-r--r--src/backends/reference/workloads/Debug.hpp4
-rw-r--r--src/backends/reference/workloads/RefDebugWorkload.cpp2
6 files changed, 240 insertions, 124 deletions
diff --git a/src/backends/backendsCommon/test/layerTests/DebugTestImpl.cpp b/src/backends/backendsCommon/test/layerTests/DebugTestImpl.cpp
index 9226f215aa..fa9a825313 100644
--- a/src/backends/backendsCommon/test/layerTests/DebugTestImpl.cpp
+++ b/src/backends/backendsCommon/test/layerTests/DebugTestImpl.cpp
@@ -6,15 +6,16 @@
#include "DebugTestImpl.hpp"
#include <armnnUtils/QuantizeHelper.hpp>
+#include <armnnUtils/Filesystem.hpp>
#include <ResolveType.hpp>
-
#include <armnnTestUtils/TensorCopyUtils.hpp>
#include <armnnTestUtils/WorkloadTestUtils.hpp>
#include <armnnTestUtils/TensorHelpers.hpp>
#include <doctest/doctest.h>
+#include <armnnUtils/Filesystem.hpp>
namespace
{
@@ -29,6 +30,8 @@ LayerTestResult<T, Dim> DebugTestImpl(
std::vector<float>& outputExpectedData,
armnn::DebugQueueDescriptor descriptor,
const std::string expectedStringOutput,
+ const std::string& layerName,
+ bool toFile,
const float qScale = 1.0f,
const int32_t qOffset = 0)
{
@@ -65,15 +68,27 @@ LayerTestResult<T, Dim> DebugTestImpl(
CopyDataToITensorHandle(inputHandle.get(), input.data());
- std::ostringstream oss;
- std::streambuf* coutStreambuf = std::cout.rdbuf();
- std::cout.rdbuf(oss.rdbuf());
+ if (toFile)
+ {
+ fs::path tmpDir = fs::temp_directory_path();
+ std::string full_path = tmpDir.generic_string() + "/ArmNNIntermediateLayerOutputs/" + layerName + ".numpy";
- ExecuteWorkload(*workload, memoryManager);
+ ExecuteWorkload(*workload, memoryManager);
- std::cout.rdbuf(coutStreambuf);
+ armnnUtils::Filesystem::FileContents output = armnnUtils::Filesystem::ReadFileContentsIntoString(full_path);
+ CHECK((output == expectedStringOutput));
+ }
+ else
+ {
+ std::ostringstream oss;
+ std::streambuf* coutStreambuf = std::cout.rdbuf();
+ std::cout.rdbuf(oss.rdbuf());
- CHECK(oss.str() == expectedStringOutput);
+ ExecuteWorkload(*workload, memoryManager);
+
+ std::cout.rdbuf(coutStreambuf);
+ CHECK(oss.str() == expectedStringOutput);
+ }
CopyDataFromITensorHandle(actualOutput.data(), outputHandle.get());
@@ -86,7 +101,8 @@ LayerTestResult<T, Dim> DebugTestImpl(
template <armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>>
LayerTestResult<T, 4> Debug4dTest(
armnn::IWorkloadFactory& workloadFactory,
- const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
+ const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
+ bool toFile = false)
{
armnn::TensorInfo inputTensorInfo;
armnn::TensorInfo outputTensorInfo;
@@ -98,6 +114,7 @@ LayerTestResult<T, 4> Debug4dTest(
desc.m_Guid = 1;
desc.m_LayerName = "TestOutput";
desc.m_SlotIndex = 0;
+ desc.m_LayerOutputToFile = toFile;
inputTensorInfo = armnn::TensorInfo(4, inputShape, ArmnnType);
outputTensorInfo = armnn::TensorInfo(4, outputShape, ArmnnType);
@@ -133,13 +150,16 @@ LayerTestResult<T, 4> Debug4dTest(
input,
outputExpected,
desc,
- expectedStringOutput);
+ expectedStringOutput,
+ desc.m_LayerName,
+ toFile);
}
template <armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>>
LayerTestResult<T, 3> Debug3dTest(
armnn::IWorkloadFactory& workloadFactory,
- const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
+ const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
+ bool toFile = false)
{
armnn::TensorInfo inputTensorInfo;
armnn::TensorInfo outputTensorInfo;
@@ -151,6 +171,7 @@ LayerTestResult<T, 3> Debug3dTest(
desc.m_Guid = 1;
desc.m_LayerName = "TestOutput";
desc.m_SlotIndex = 0;
+ desc.m_LayerOutputToFile = toFile;
inputTensorInfo = armnn::TensorInfo(3, inputShape, ArmnnType);
outputTensorInfo = armnn::TensorInfo(3, outputShape, ArmnnType);
@@ -184,13 +205,16 @@ LayerTestResult<T, 3> Debug3dTest(
input,
outputExpected,
desc,
- expectedStringOutput);
+ expectedStringOutput,
+ desc.m_LayerName,
+ toFile);
}
template <armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>>
LayerTestResult<T, 2> Debug2dTest(
armnn::IWorkloadFactory& workloadFactory,
- const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
+ const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
+ bool toFile = false)
{
armnn::TensorInfo inputTensorInfo;
armnn::TensorInfo outputTensorInfo;
@@ -202,6 +226,7 @@ LayerTestResult<T, 2> Debug2dTest(
desc.m_Guid = 1;
desc.m_LayerName = "TestOutput";
desc.m_SlotIndex = 0;
+ desc.m_LayerOutputToFile = toFile;
inputTensorInfo = armnn::TensorInfo(2, inputShape, ArmnnType);
outputTensorInfo = armnn::TensorInfo(2, outputShape, ArmnnType);
@@ -233,13 +258,16 @@ LayerTestResult<T, 2> Debug2dTest(
input,
outputExpected,
desc,
- expectedStringOutput);
+ expectedStringOutput,
+ desc.m_LayerName,
+ toFile);
}
template <armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>>
LayerTestResult<T, 1> Debug1dTest(
armnn::IWorkloadFactory& workloadFactory,
- const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
+ const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
+ bool toFile = false)
{
armnn::TensorInfo inputTensorInfo;
armnn::TensorInfo outputTensorInfo;
@@ -251,6 +279,7 @@ LayerTestResult<T, 1> Debug1dTest(
desc.m_Guid = 1;
desc.m_LayerName = "TestOutput";
desc.m_SlotIndex = 0;
+ desc.m_LayerOutputToFile = toFile;
inputTensorInfo = armnn::TensorInfo(1, inputShape, ArmnnType);
outputTensorInfo = armnn::TensorInfo(1, outputShape, ArmnnType);
@@ -280,119 +309,137 @@ LayerTestResult<T, 1> Debug1dTest(
input,
outputExpected,
desc,
- expectedStringOutput);
+ expectedStringOutput,
+ desc.m_LayerName,
+ toFile);
}
} // anonymous namespace
LayerTestResult<float, 4> Debug4dFloat32Test(
armnn::IWorkloadFactory& workloadFactory,
- const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
+ const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
+ bool toFile = false)
{
- return Debug4dTest<armnn::DataType::Float32>(workloadFactory, memoryManager);
+ return Debug4dTest<armnn::DataType::Float32>(workloadFactory, memoryManager, toFile);
}
LayerTestResult<float, 3> Debug3dFloat32Test(
armnn::IWorkloadFactory& workloadFactory,
- const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
+ const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
+ bool toFile = false)
{
- return Debug3dTest<armnn::DataType::Float32>(workloadFactory, memoryManager);
+ return Debug3dTest<armnn::DataType::Float32>(workloadFactory, memoryManager, toFile);
}
LayerTestResult<float, 2> Debug2dFloat32Test(
armnn::IWorkloadFactory& workloadFactory,
- const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
+ const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
+ bool toFile = false)
{
- return Debug2dTest<armnn::DataType::Float32>(workloadFactory, memoryManager);
+ return Debug2dTest<armnn::DataType::Float32>(workloadFactory, memoryManager, toFile);
}
LayerTestResult<float, 1> Debug1dFloat32Test(
armnn::IWorkloadFactory& workloadFactory,
- const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
+ const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
+ bool toFile = false)
{
- return Debug1dTest<armnn::DataType::Float32>(workloadFactory, memoryManager);
+ return Debug1dTest<armnn::DataType::Float32>(workloadFactory, memoryManager, toFile);
}
LayerTestResult<armnn::BFloat16, 4> Debug4dBFloat16Test(
armnn::IWorkloadFactory& workloadFactory,
- const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
+ const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
+ bool toFile = false)
{
- return Debug4dTest<armnn::DataType::BFloat16>(workloadFactory, memoryManager);
+ return Debug4dTest<armnn::DataType::BFloat16>(workloadFactory, memoryManager, toFile);
}
LayerTestResult<armnn::BFloat16, 3> Debug3dBFloat16Test(
armnn::IWorkloadFactory& workloadFactory,
- const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
+ const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
+ bool toFile = false)
{
- return Debug3dTest<armnn::DataType::BFloat16>(workloadFactory, memoryManager);
+ return Debug3dTest<armnn::DataType::BFloat16>(workloadFactory, memoryManager, toFile);
}
LayerTestResult<armnn::BFloat16, 2> Debug2dBFloat16Test(
armnn::IWorkloadFactory& workloadFactory,
- const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
+ const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
+ bool toFile = false)
{
- return Debug2dTest<armnn::DataType::BFloat16>(workloadFactory, memoryManager);
+ return Debug2dTest<armnn::DataType::BFloat16>(workloadFactory, memoryManager, toFile);
}
LayerTestResult<armnn::BFloat16, 1> Debug1dBFloat16Test(
armnn::IWorkloadFactory& workloadFactory,
- const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
+ const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
+ bool toFile = false)
{
- return Debug1dTest<armnn::DataType::BFloat16>(workloadFactory, memoryManager);
+ return Debug1dTest<armnn::DataType::BFloat16>(workloadFactory, memoryManager, toFile);
}
LayerTestResult<uint8_t, 4> Debug4dUint8Test(
armnn::IWorkloadFactory& workloadFactory,
- const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
+ const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
+ bool toFile = false)
{
- return Debug4dTest<armnn::DataType::QAsymmU8>(workloadFactory, memoryManager);
+ return Debug4dTest<armnn::DataType::QAsymmU8>(workloadFactory, memoryManager, toFile);
}
LayerTestResult<uint8_t, 3> Debug3dUint8Test(
armnn::IWorkloadFactory& workloadFactory,
- const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
+ const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
+ bool toFile = false)
{
- return Debug3dTest<armnn::DataType::QAsymmU8>(workloadFactory, memoryManager);
+ return Debug3dTest<armnn::DataType::QAsymmU8>(workloadFactory, memoryManager, toFile);
}
LayerTestResult<uint8_t, 2> Debug2dUint8Test(
armnn::IWorkloadFactory& workloadFactory,
- const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
+ const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
+ bool toFile = false)
{
- return Debug2dTest<armnn::DataType::QAsymmU8>(workloadFactory, memoryManager);
+ return Debug2dTest<armnn::DataType::QAsymmU8>(workloadFactory, memoryManager, toFile);
}
LayerTestResult<uint8_t, 1> Debug1dUint8Test(
armnn::IWorkloadFactory& workloadFactory,
- const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
+ const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
+ bool toFile = false)
{
- return Debug1dTest<armnn::DataType::QAsymmU8>(workloadFactory, memoryManager);
+ return Debug1dTest<armnn::DataType::QAsymmU8>(workloadFactory, memoryManager, toFile);
}
LayerTestResult<int16_t, 4> Debug4dInt16Test(
armnn::IWorkloadFactory& workloadFactory,
- const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
+ const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
+ bool toFile = false)
{
- return Debug4dTest<armnn::DataType::QSymmS16>(workloadFactory, memoryManager);
+ return Debug4dTest<armnn::DataType::QSymmS16>(workloadFactory, memoryManager, toFile);
}
LayerTestResult<int16_t, 3> Debug3dInt16Test(
armnn::IWorkloadFactory& workloadFactory,
- const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
+ const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
+ bool toFile = false)
{
- return Debug3dTest<armnn::DataType::QSymmS16>(workloadFactory, memoryManager);
+ return Debug3dTest<armnn::DataType::QSymmS16>(workloadFactory, memoryManager, toFile);
}
LayerTestResult<int16_t, 2> Debug2dInt16Test(
armnn::IWorkloadFactory& workloadFactory,
- const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
+ const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
+ bool toFile = false)
{
- return Debug2dTest<armnn::DataType::QSymmS16>(workloadFactory, memoryManager);
+ return Debug2dTest<armnn::DataType::QSymmS16>(workloadFactory, memoryManager, toFile);
}
LayerTestResult<int16_t, 1> Debug1dInt16Test(
armnn::IWorkloadFactory& workloadFactory,
- const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
+ const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
+ bool toFile = false)
{
- return Debug1dTest<armnn::DataType::QSymmS16>(workloadFactory, memoryManager);
+ return Debug1dTest<armnn::DataType::QSymmS16>(workloadFactory, memoryManager, toFile);
}
diff --git a/src/backends/backendsCommon/test/layerTests/DebugTestImpl.hpp b/src/backends/backendsCommon/test/layerTests/DebugTestImpl.hpp
index ac068e8939..250c658cbf 100644
--- a/src/backends/backendsCommon/test/layerTests/DebugTestImpl.hpp
+++ b/src/backends/backendsCommon/test/layerTests/DebugTestImpl.hpp
@@ -14,64 +14,80 @@
LayerTestResult<float, 4> Debug4dFloat32Test(
armnn::IWorkloadFactory& workloadFactory,
- const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager);
+ const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
+ bool toFile);
LayerTestResult<float, 3> Debug3dFloat32Test(
armnn::IWorkloadFactory& workloadFactory,
- const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager);
+ const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
+ bool toFile);
LayerTestResult<float, 2> Debug2dFloat32Test(
armnn::IWorkloadFactory& workloadFactory,
- const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager);
+ const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
+ bool toFile);
LayerTestResult<float, 1> Debug1dFloat32Test(
armnn::IWorkloadFactory& workloadFactory,
- const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager);
+ const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
+ bool toFile);
LayerTestResult<armnn::BFloat16, 4> Debug4dBFloat16Test(
armnn::IWorkloadFactory& workloadFactory,
- const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager);
+ const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
+ bool toFile);
LayerTestResult<armnn::BFloat16, 3> Debug3dBFloat16Test(
armnn::IWorkloadFactory& workloadFactory,
- const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager);
+ const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
+ bool toFile);
LayerTestResult<armnn::BFloat16, 2> Debug2dBFloat16Test(
armnn::IWorkloadFactory& workloadFactory,
- const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager);
+ const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
+ bool toFile);
LayerTestResult<armnn::BFloat16, 1> Debug1dBFloat16Test(
armnn::IWorkloadFactory& workloadFactory,
- const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager);
+ const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
+ bool toFile);
LayerTestResult<uint8_t, 4> Debug4dUint8Test(
armnn::IWorkloadFactory& workloadFactory,
- const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager);
+ const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
+ bool toFile);
LayerTestResult<uint8_t, 3> Debug3dUint8Test(
armnn::IWorkloadFactory& workloadFactory,
- const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager);
+ const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
+ bool toFile);
LayerTestResult<uint8_t, 2> Debug2dUint8Test(
armnn::IWorkloadFactory& workloadFactory,
- const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager);
+ const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
+ bool toFile);
LayerTestResult<uint8_t, 1> Debug1dUint8Test(
armnn::IWorkloadFactory& workloadFactory,
- const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager);
+ const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
+ bool toFile);
LayerTestResult<int16_t, 4> Debug4dInt16Test(
armnn::IWorkloadFactory& workloadFactory,
- const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager);
+ const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
+ bool toFile);
LayerTestResult<int16_t, 3> Debug3dInt16Test(
armnn::IWorkloadFactory& workloadFactory,
- const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager);
+ const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
+ bool toFile);
LayerTestResult<int16_t, 2> Debug2dInt16Test(
armnn::IWorkloadFactory& workloadFactory,
- const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager);
+ const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
+ bool toFile);
LayerTestResult<int16_t, 1> Debug1dInt16Test(
armnn::IWorkloadFactory& workloadFactory,
- const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager);
+ const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
+ bool toFile);
diff --git a/src/backends/reference/test/RefLayerTests.cpp b/src/backends/reference/test/RefLayerTests.cpp
index ae40333658..7375847602 100644
--- a/src/backends/reference/test/RefLayerTests.cpp
+++ b/src/backends/reference/test/RefLayerTests.cpp
@@ -2250,25 +2250,46 @@ ARMNN_AUTO_TEST_CASE_WITH_THF(StridedSlice2dInt16, StridedSlice2dInt16Test)
ARMNN_AUTO_TEST_CASE_WITH_THF(StridedSlice2dReverseInt16, StridedSlice2dReverseInt16Test)
// Debug
-ARMNN_AUTO_TEST_CASE(Debug4dFloat32, Debug4dFloat32Test)
-ARMNN_AUTO_TEST_CASE(Debug3dFloat32, Debug3dFloat32Test)
-ARMNN_AUTO_TEST_CASE(Debug2dFloat32, Debug2dFloat32Test)
-ARMNN_AUTO_TEST_CASE(Debug1dFloat32, Debug1dFloat32Test)
-
-ARMNN_AUTO_TEST_CASE(Debug4dBFloat16, Debug4dBFloat16Test)
-ARMNN_AUTO_TEST_CASE(Debug3dBFloat16, Debug3dBFloat16Test)
-ARMNN_AUTO_TEST_CASE(Debug2dBFloat16, Debug2dBFloat16Test)
-ARMNN_AUTO_TEST_CASE(Debug1dBFloat16, Debug1dBFloat16Test)
-
-ARMNN_AUTO_TEST_CASE(Debug4dUint8, Debug4dUint8Test)
-ARMNN_AUTO_TEST_CASE(Debug3dUint8, Debug3dUint8Test)
-ARMNN_AUTO_TEST_CASE(Debug2dUint8, Debug2dUint8Test)
-ARMNN_AUTO_TEST_CASE(Debug1dUint8, Debug1dUint8Test)
-
-ARMNN_AUTO_TEST_CASE(Debug4dQSymm16, Debug4dInt16Test)
-ARMNN_AUTO_TEST_CASE(Debug3dQSymm16, Debug3dInt16Test)
-ARMNN_AUTO_TEST_CASE(Debug2dQSymm16, Debug2dInt16Test)
-ARMNN_AUTO_TEST_CASE(Debug1dQSymm16, Debug1dInt16Test)
+ARMNN_AUTO_TEST_CASE(Debug4dFloat32, Debug4dFloat32Test, /*toFile*/ false)
+ARMNN_AUTO_TEST_CASE(Debug3dFloat32, Debug3dFloat32Test, /*toFile*/ false)
+ARMNN_AUTO_TEST_CASE(Debug2dFloat32, Debug2dFloat32Test, /*toFile*/ false)
+ARMNN_AUTO_TEST_CASE(Debug1dFloat32, Debug1dFloat32Test, /*toFile*/ false)
+
+ARMNN_AUTO_TEST_CASE(Debug4dBFloat16, Debug4dBFloat16Test, /*toFile*/ false)
+ARMNN_AUTO_TEST_CASE(Debug3dBFloat16, Debug3dBFloat16Test, /*toFile*/ false)
+ARMNN_AUTO_TEST_CASE(Debug2dBFloat16, Debug2dBFloat16Test, /*toFile*/ false)
+ARMNN_AUTO_TEST_CASE(Debug1dBFloat16, Debug1dBFloat16Test, /*toFile*/ false)
+
+ARMNN_AUTO_TEST_CASE(Debug4dUint8, Debug4dUint8Test, /*toFile*/ false)
+ARMNN_AUTO_TEST_CASE(Debug3dUint8, Debug3dUint8Test, /*toFile*/ false)
+ARMNN_AUTO_TEST_CASE(Debug2dUint8, Debug2dUint8Test, /*toFile*/ false)
+ARMNN_AUTO_TEST_CASE(Debug1dUint8, Debug1dUint8Test, /*toFile*/ false)
+
+ARMNN_AUTO_TEST_CASE(Debug4dQSymm16, Debug4dInt16Test, /*toFile*/ false)
+ARMNN_AUTO_TEST_CASE(Debug3dQSymm16, Debug3dInt16Test, /*toFile*/ false)
+ARMNN_AUTO_TEST_CASE(Debug2dQSymm16, Debug2dInt16Test, /*toFile*/ false)
+ARMNN_AUTO_TEST_CASE(Debug1dQSymm16, Debug1dInt16Test, /*toFile*/ false)
+
+// Debug To File
+ARMNN_AUTO_TEST_CASE(DebugToFile4dFloat32, Debug4dFloat32Test, /*toFile*/ true)
+ARMNN_AUTO_TEST_CASE(DebugToFile3dFloat32, Debug3dFloat32Test, /*toFile*/ true)
+ARMNN_AUTO_TEST_CASE(DebugToFile2dFloat32, Debug2dFloat32Test, /*toFile*/ true)
+ARMNN_AUTO_TEST_CASE(DebugToFile1dFloat32, Debug1dFloat32Test, /*toFile*/ true)
+
+ARMNN_AUTO_TEST_CASE(DebugToFile4dBFloat16, Debug4dBFloat16Test, /*toFile*/ true)
+ARMNN_AUTO_TEST_CASE(DebugToFile3dBFloat16, Debug3dBFloat16Test, /*toFile*/ true)
+ARMNN_AUTO_TEST_CASE(DebugToFile2dBFloat16, Debug2dBFloat16Test, /*toFile*/ true)
+ARMNN_AUTO_TEST_CASE(DebugToFile1dBFloat16, Debug1dBFloat16Test, /*toFile*/ true)
+
+ARMNN_AUTO_TEST_CASE(DebugToFile4dUint8, Debug4dUint8Test, /*toFile*/ true)
+ARMNN_AUTO_TEST_CASE(DebugToFile3dUint8, Debug3dUint8Test, /*toFile*/ true)
+ARMNN_AUTO_TEST_CASE(DebugToFile2dUint8, Debug2dUint8Test, /*toFile*/ true)
+ARMNN_AUTO_TEST_CASE(DebugToFile1dUint8, Debug1dUint8Test, /*toFile*/ true)
+
+ARMNN_AUTO_TEST_CASE(DebugToFile4dQSymm16, Debug4dInt16Test, /*toFile*/ true)
+ARMNN_AUTO_TEST_CASE(DebugToFile3dQSymm16, Debug3dInt16Test, /*toFile*/ true)
+ARMNN_AUTO_TEST_CASE(DebugToFile2dQSymm16, Debug2dInt16Test, /*toFile*/ true)
+ARMNN_AUTO_TEST_CASE(DebugToFile1dQSymm16, Debug1dInt16Test, /*toFile*/ true)
// Gather
ARMNN_AUTO_TEST_CASE_WITH_THF(Gather1dParamsFloat32, Gather1dParamsFloat32Test)
diff --git a/src/backends/reference/workloads/Debug.cpp b/src/backends/reference/workloads/Debug.cpp
index 24000d45e6..fdadfef590 100644
--- a/src/backends/reference/workloads/Debug.cpp
+++ b/src/backends/reference/workloads/Debug.cpp
@@ -5,22 +5,27 @@
#include "Debug.hpp"
#include <common/include/ProfilingGuid.hpp>
+#include <armnnUtils/Filesystem.hpp>
#include <BFloat16.hpp>
#include <Half.hpp>
#include <algorithm>
#include <iostream>
+#include <iosfwd>
+#include <fstream>
+#include <sys/stat.h>
namespace armnn
{
-template <typename T>
-void Debug(const TensorInfo& inputInfo,
- const T* inputData,
- LayerGuid guid,
- const std::string& layerName,
- unsigned int slotIndex)
+template<typename T>
+void PrintOutput(const TensorInfo& inputInfo,
+ const T* inputData,
+ LayerGuid guid,
+ const std::string& layerName,
+ unsigned int slotIndex,
+ std::ostream& os)
{
const unsigned int numDims = inputInfo.GetNumDimensions();
const unsigned int numElements = inputInfo.GetNumElements();
@@ -34,30 +39,30 @@ void Debug(const TensorInfo& inputInfo,
strides[numDims - i] = strides[numDims - i + 1] * inputShape[numDims - i];
}
- std::cout << "{ ";
- std::cout << "\"layerGuid\": " << guid << ", ";
- std::cout << "\"layerName\": \"" << layerName << "\", ";
- std::cout << "\"outputSlot\": " << slotIndex << ", ";
- std::cout << "\"shape\": ";
+ os << "{ ";
+ os << "\"layerGuid\": " << guid << ", ";
+ os << "\"layerName\": \"" << layerName << "\", ";
+ os << "\"outputSlot\": " << slotIndex << ", ";
+ os << "\"shape\": ";
- std::cout << "[";
+ os << "[";
for (unsigned int i = 0; i < numDims; i++)
{
- std::cout << inputShape[i];
+ os << inputShape[i];
if (i != numDims - 1)
{
- std::cout << ", ";
+ os << ", ";
}
}
- std::cout << "], ";
+ os << "], ";
- std::cout << "\"min\": "
- << static_cast<float>(*std::min_element(inputData, inputData + numElements)) << ", ";
+ os << "\"min\": "
+ << static_cast<float>(*std::min_element(inputData, inputData + numElements)) << ", ";
- std::cout << "\"max\": "
- << static_cast<float>(*std::max_element(inputData, inputData + numElements)) << ", ";
+ os << "\"max\": "
+ << static_cast<float>(*std::max_element(inputData, inputData + numElements)) << ", ";
- std::cout << "\"data\": ";
+ os << "\"data\": ";
for (unsigned int i = 0; i < numElements; i++)
{
@@ -65,69 +70,96 @@ void Debug(const TensorInfo& inputInfo,
{
if (i % strides[j] == 0)
{
- std::cout << "[" ;
+ os << "[";
}
}
- std::cout << static_cast<float>(inputData[i]);
+ os << static_cast<float>(inputData[i]);
for (unsigned int j = 0; j < numDims; j++)
{
- if ((i+1) % strides[j] == 0)
+ if ((i + 1) % strides[j] == 0)
{
- std::cout << "]" ;
+ os << "]";
}
}
if (i != numElements - 1)
{
- std::cout << ", ";
+ os << ", ";
}
}
- std::cout << " }" << std::endl;
+ os << " }" << std::endl;
+}
+
+template<typename T>
+void Debug(const TensorInfo& inputInfo,
+ const T* inputData,
+ LayerGuid guid,
+ const std::string& layerName,
+ unsigned int slotIndex,
+ bool outputsToFile)
+{
+ if (outputsToFile)
+ {
+ auto rootPathToFile = armnnUtils::Filesystem::CreateDirectory("/ArmNNIntermediateLayerOutputs");
+ std::ofstream out(rootPathToFile + layerName + ".numpy");
+ PrintOutput<T>(inputInfo, inputData, guid, layerName, slotIndex, out);
+ }
+ else
+ {
+ PrintOutput<T>(inputInfo, inputData, guid, layerName, slotIndex, std::cout);
+ }
}
template void Debug<BFloat16>(const TensorInfo& inputInfo,
- const BFloat16* inputData,
- LayerGuid guid,
- const std::string& layerName,
- unsigned int slotIndex);
+ const BFloat16* inputData,
+ LayerGuid guid,
+ const std::string& layerName,
+ unsigned int slotIndex,
+ bool outputsToFile);
template void Debug<Half>(const TensorInfo& inputInfo,
const Half* inputData,
LayerGuid guid,
const std::string& layerName,
- unsigned int slotIndex);
+ unsigned int slotIndex,
+ bool outputsToFile);
template void Debug<float>(const TensorInfo& inputInfo,
const float* inputData,
LayerGuid guid,
const std::string& layerName,
- unsigned int slotIndex);
+ unsigned int slotIndex,
+ bool outputsToFile);
template void Debug<uint8_t>(const TensorInfo& inputInfo,
const uint8_t* inputData,
LayerGuid guid,
const std::string& layerName,
- unsigned int slotIndex);
+ unsigned int slotIndex,
+ bool outputsToFile);
template void Debug<int8_t>(const TensorInfo& inputInfo,
- const int8_t* inputData,
- LayerGuid guid,
- const std::string& layerName,
- unsigned int slotIndex);
+ const int8_t* inputData,
+ LayerGuid guid,
+ const std::string& layerName,
+ unsigned int slotIndex,
+ bool outputsToFile);
template void Debug<int16_t>(const TensorInfo& inputInfo,
const int16_t* inputData,
LayerGuid guid,
const std::string& layerName,
- unsigned int slotIndex);
+ unsigned int slotIndex,
+ bool outputsToFile);
template void Debug<int32_t>(const TensorInfo& inputInfo,
const int32_t* inputData,
LayerGuid guid,
const std::string& layerName,
- unsigned int slotIndex);
+ unsigned int slotIndex,
+ bool outputsToFile);
} // namespace armnn
diff --git a/src/backends/reference/workloads/Debug.hpp b/src/backends/reference/workloads/Debug.hpp
index 3f9920c543..a8802d1524 100644
--- a/src/backends/reference/workloads/Debug.hpp
+++ b/src/backends/reference/workloads/Debug.hpp
@@ -8,12 +8,12 @@
namespace armnn
{
-
template <typename T>
void Debug(const TensorInfo& inputInfo,
const T* inputData,
LayerGuid guid,
const std::string& layerName,
- unsigned int slotIndex);
+ unsigned int slotIndex,
+ bool outputsToFile);
} //namespace armnn
diff --git a/src/backends/reference/workloads/RefDebugWorkload.cpp b/src/backends/reference/workloads/RefDebugWorkload.cpp
index 48b519f809..db67b3a782 100644
--- a/src/backends/reference/workloads/RefDebugWorkload.cpp
+++ b/src/backends/reference/workloads/RefDebugWorkload.cpp
@@ -45,7 +45,7 @@ void RefDebugWorkload<DataType>::Execute(std::vector<ITensorHandle*> inputs) con
}
else
{
- Debug(inputInfo, inputData, m_Data.m_Guid, m_Data.m_LayerName, m_Data.m_SlotIndex);
+ Debug(inputInfo, inputData, m_Data.m_Guid, m_Data.m_LayerName, m_Data.m_SlotIndex, m_Data.m_LayerOutputToFile);
}
std::memcpy(outputData, inputData, inputInfo.GetNumElements()*sizeof(T));