aboutsummaryrefslogtreecommitdiff
path: root/src/backends/backendsCommon/test/layerTests/SplitterTestImpl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/backends/backendsCommon/test/layerTests/SplitterTestImpl.cpp')
-rw-r--r--src/backends/backendsCommon/test/layerTests/SplitterTestImpl.cpp82
1 files changed, 42 insertions, 40 deletions
diff --git a/src/backends/backendsCommon/test/layerTests/SplitterTestImpl.cpp b/src/backends/backendsCommon/test/layerTests/SplitterTestImpl.cpp
index e2040b5b20..e19a3216c3 100644
--- a/src/backends/backendsCommon/test/layerTests/SplitterTestImpl.cpp
+++ b/src/backends/backendsCommon/test/layerTests/SplitterTestImpl.cpp
@@ -47,7 +47,6 @@ std::vector<LayerTestResult<T,3>> SplitterTestCommon(
unsigned int outputHeight2 = inputHeight;
unsigned int outputChannels2 = 2;
-
// Define the tensor descriptors.
armnn::TensorInfo inputTensorInfo({ inputChannels, inputHeight, inputWidth }, ArmnnType, qScale, qOffset);
@@ -75,13 +74,8 @@ std::vector<LayerTestResult<T,3>> SplitterTestCommon(
outputTensorInfo4.SetQuantizationOffset(qOffset);
}
- LayerTestResult<T,3> ret1(outputTensorInfo1);
- LayerTestResult<T,3> ret2(outputTensorInfo2);
- LayerTestResult<T,3> ret3(outputTensorInfo3);
- LayerTestResult<T,3> ret4(outputTensorInfo4);
-
- auto input = MakeTensor<T, 3>(inputTensorInfo, std::vector<T>(
- armnnUtils::QuantizedVector<T>({
+ auto input = armnnUtils::QuantizedVector<T>(
+ {
1.0f, 2.0f, 3.0f, 4.0f, 5.0f,
6.0f, 7.0f, 8.0f, 9.0f, 10.0f,
11.0f, 12.0f, 13.0f, 14.0f, 15.0f,
@@ -103,12 +97,11 @@ std::vector<LayerTestResult<T,3>> SplitterTestCommon(
81.0f, 82.0f, 83.0f, 84.0f, 85.0f,
86.0f, 87.0f, 88.0f, 89.0f, 90.0f,
},
- qScale, qOffset)
- ));
+ qScale, qOffset);
// Channel 0 of the original input.
- ret1.outputExpected = MakeTensor<T, 3>(outputTensorInfo1, std::vector<T>(
- armnnUtils::QuantizedVector<T>({
+ auto expectedData1 = armnnUtils::QuantizedVector<T>(
+ {
1.0f, 2.0f, 3.0f, 4.0f, 5.0f,
6.0f, 7.0f, 8.0f, 9.0f, 10.0f,
11.0f, 12.0f, 13.0f, 14.0f, 15.0f,
@@ -116,12 +109,11 @@ std::vector<LayerTestResult<T,3>> SplitterTestCommon(
21.0f, 22.0f, 23.0f, 24.0f, 25.0f,
26.0f, 27.0f, 28.0f, 29.0f, 30.0f,
},
- qScale, qOffset)
- ));
+ qScale, qOffset);
// Channel 1 & 2 of the original input.
- ret2.outputExpected = MakeTensor<T, 3>(outputTensorInfo2, std::vector<T>(
- armnnUtils::QuantizedVector<T>({
+ auto expectedData2 = armnnUtils::QuantizedVector<T>(
+ {
31.0f, 32.0f, 33.0f, 34.0f, 35.0f,
36.0f, 37.0f, 38.0f, 39.0f, 40.0f,
41.0f, 42.0f, 43.0f, 44.0f, 45.0f,
@@ -136,12 +128,11 @@ std::vector<LayerTestResult<T,3>> SplitterTestCommon(
81.0f, 82.0f, 83.0f, 84.0f, 85.0f,
86.0f, 87.0f, 88.0f, 89.0f, 90.0f,
},
- qScale, qOffset)
- ));
+ qScale, qOffset);
// Channel 0 of return 2 (i.e. channels 1 and 2 of the original input).
- ret3.outputExpected = MakeTensor<T, 3>(outputTensorInfo3, std::vector<T>(
- armnnUtils::QuantizedVector<T>({
+ auto expectedData3 = armnnUtils::QuantizedVector<T>(
+ {
31.0f, 32.0f, 33.0f, 34.0f, 35.0f,
36.0f, 37.0f, 38.0f, 39.0f, 40.0f,
41.0f, 42.0f, 43.0f, 44.0f, 45.0f,
@@ -149,12 +140,11 @@ std::vector<LayerTestResult<T,3>> SplitterTestCommon(
51.0f, 52.0f, 53.0f, 54.0f, 55.0f,
56.0f, 57.0f, 58.0f, 59.0f, 60.0f,
},
- qScale, qOffset)
- ));
+ qScale, qOffset);
// Channel 1 of return 2.
- ret4.outputExpected = MakeTensor<T, 3>(outputTensorInfo4, std::vector<T>(
- armnnUtils::QuantizedVector<T>({
+ auto expectedData4 = armnnUtils::QuantizedVector<T>(
+ {
61.0f, 62.0f, 63.0f, 64.0f, 65.0f,
66.0f, 67.0f, 68.0f, 69.0f, 70.0f,
71.0f, 72.0f, 73.0f, 74.0f, 75.0f,
@@ -162,8 +152,12 @@ std::vector<LayerTestResult<T,3>> SplitterTestCommon(
81.0f, 82.0f, 83.0f, 84.0f, 85.0f,
86.0f, 87.0f, 88.0f, 89.0f, 90.0f,
},
- qScale, qOffset)
- ));
+ qScale, qOffset);
+
+ std::vector<T> actualData1(outputTensorInfo1.GetNumElements());
+ std::vector<T> actualData2(outputTensorInfo2.GetNumElements());
+ std::vector<T> actualData3(outputTensorInfo3.GetNumElements());
+ std::vector<T> actualData4(outputTensorInfo4.GetNumElements());
// NOTE: as a corollary of the splitting of x and y restriction the x and y values of the view origins
// have to be zero, the co-ordinates are as per the tensor info above channels, height/y, width/x
@@ -219,12 +213,12 @@ std::vector<LayerTestResult<T,3>> SplitterTestCommon(
outputHandle1->Allocate();
outputHandle2->Allocate();
- CopyDataToITensorHandle(inputHandle.get(), &input[0][0][0]);
+ CopyDataToITensorHandle(inputHandle.get(), input.data());
workload->Execute();
- CopyDataFromITensorHandle(&ret1.output[0][0][0], outputHandle1.get());
- CopyDataFromITensorHandle(&ret2.output[0][0][0], outputHandle2.get());
+ CopyDataFromITensorHandle(actualData1.data(), outputHandle1.get());
+ CopyDataFromITensorHandle(actualData2.data(), outputHandle2.get());
// Do the second split.
armnn::SplitterQueueDescriptor data2;
@@ -243,8 +237,13 @@ std::vector<LayerTestResult<T,3>> SplitterTestCommon(
ExecuteWorkload(*workload2, memoryManager);
- CopyDataFromITensorHandle(&ret3.output[0][0][0], outputHandle3.get());
- CopyDataFromITensorHandle(&ret4.output[0][0][0], outputHandle4.get());
+ CopyDataFromITensorHandle(actualData3.data(), outputHandle3.get());
+ CopyDataFromITensorHandle(actualData4.data(), outputHandle4.get());
+
+ LayerTestResult<T,3> ret1(actualData1, expectedData1, outputHandle1->GetShape(), outputTensorInfo1.GetShape());
+ LayerTestResult<T,3> ret2(actualData2, expectedData2, outputHandle2->GetShape(), outputTensorInfo2.GetShape());
+ LayerTestResult<T,3> ret3(actualData3, expectedData3, outputHandle3->GetShape(), outputTensorInfo3.GetShape());
+ LayerTestResult<T,3> ret4(actualData4, expectedData4, outputHandle4->GetShape(), outputTensorInfo4.GetShape());
std::vector<LayerTestResult<T,3>> ret = {ret1, ret2, ret3, ret4,};
@@ -259,10 +258,10 @@ LayerTestResult<T, 3> CopyViaSplitterTestImpl(
float qScale, int32_t qOffset)
{
IgnoreUnused(memoryManager);
+
const armnn::TensorInfo tensorInfo({ 3, 6, 5 }, ArmnnType, qScale, qOffset);
- auto input = MakeTensor<T, 3>(
- tensorInfo,
- armnnUtils::QuantizedVector<T>({
+ auto input = armnnUtils::QuantizedVector<T>(
+ {
1.0f, 2.0f, 3.0f, 4.0f, 5.0f,
6.0f, 7.0f, 8.0f, 9.0f, 10.0f,
11.0f, 12.0f, 13.0f, 14.0f, 15.0f,
@@ -284,7 +283,9 @@ LayerTestResult<T, 3> CopyViaSplitterTestImpl(
81.0f, 82.0f, 83.0f, 84.0f, 85.0f,
86.0f, 87.0f, 88.0f, 89.0f, 90.0f,
},
- qScale, qOffset));
+ qScale, qOffset);
+
+ std::vector<T> actualOutput(tensorInfo.GetNumElements());
std::vector<unsigned int> origin = { 0, 0, 0 };
armnn::SplitterQueueDescriptor::ViewOrigin window(origin);
@@ -309,15 +310,16 @@ LayerTestResult<T, 3> CopyViaSplitterTestImpl(
inputHandle->Allocate();
outputHandle->Allocate();
- CopyDataToITensorHandle(inputHandle.get(), &input[0][0][0]);
+ CopyDataToITensorHandle(inputHandle.get(), input.data());
workload->Execute();
- LayerTestResult<T, 3> ret(tensorInfo);
- CopyDataFromITensorHandle(&ret.output[0][0][0], outputHandle.get());
- ret.outputExpected = input;
+ CopyDataFromITensorHandle(actualOutput.data(), outputHandle.get());
- return ret;
+ return LayerTestResult<T, 3>(actualOutput,
+ input,
+ outputHandle->GetShape(),
+ tensorInfo.GetShape());
}
} // anonymous namespace