aboutsummaryrefslogtreecommitdiff
path: root/src/backends/backendsCommon/test/layerTests
diff options
context:
space:
mode:
Diffstat (limited to 'src/backends/backendsCommon/test/layerTests')
-rw-r--r--src/backends/backendsCommon/test/layerTests/ActivationTestImpl.cpp10
-rw-r--r--src/backends/backendsCommon/test/layerTests/Conv2dTestImpl.cpp101
-rw-r--r--src/backends/backendsCommon/test/layerTests/LstmTestImpl.cpp19
-rw-r--r--src/backends/backendsCommon/test/layerTests/NormalizationTestImpl.cpp10
-rw-r--r--src/backends/backendsCommon/test/layerTests/Pooling2dTestImpl.cpp17
5 files changed, 82 insertions, 75 deletions
diff --git a/src/backends/backendsCommon/test/layerTests/ActivationTestImpl.cpp b/src/backends/backendsCommon/test/layerTests/ActivationTestImpl.cpp
index 543ea7716a..6d83b1ca99 100644
--- a/src/backends/backendsCommon/test/layerTests/ActivationTestImpl.cpp
+++ b/src/backends/backendsCommon/test/layerTests/ActivationTestImpl.cpp
@@ -13,6 +13,8 @@
#include <backendsCommon/test/WorkloadTestUtils.hpp>
#include <reference/test/RefWorkloadFactoryHelper.hpp>
+#include <armnn/utility/NumericCast.hpp>
+
#include <test/TensorHelpers.hpp>
#include <boost/multi_array.hpp>
@@ -1261,10 +1263,10 @@ LayerTestResult<T,4> CompareActivationTestImpl(
LayerTestResult<T,4> ret(outputTensorInfo);
auto boostArrayExtents = boost::extents
- [boost::numeric_cast<boost::multi_array_types::extent_gen::index>(batchSize)]
- [boost::numeric_cast<boost::multi_array_types::extent_gen::index>(channels)]
- [boost::numeric_cast<boost::multi_array_types::extent_gen::index>(height)]
- [boost::numeric_cast<boost::multi_array_types::extent_gen::index>(width)];
+ [armnn::numeric_cast<boost::multi_array_types::extent_gen::index>(batchSize)]
+ [armnn::numeric_cast<boost::multi_array_types::extent_gen::index>(channels)]
+ [armnn::numeric_cast<boost::multi_array_types::extent_gen::index>(height)]
+ [armnn::numeric_cast<boost::multi_array_types::extent_gen::index>(width)];
ret.output.resize(boostArrayExtents);
ret.outputExpected.resize(boostArrayExtents);
diff --git a/src/backends/backendsCommon/test/layerTests/Conv2dTestImpl.cpp b/src/backends/backendsCommon/test/layerTests/Conv2dTestImpl.cpp
index e99a26e81e..690d1cd66f 100644
--- a/src/backends/backendsCommon/test/layerTests/Conv2dTestImpl.cpp
+++ b/src/backends/backendsCommon/test/layerTests/Conv2dTestImpl.cpp
@@ -9,6 +9,7 @@
#include <armnnUtils/TensorUtils.hpp>
#include <armnn/utility/IgnoreUnused.hpp>
+#include <armnn/utility/NumericCast.hpp>
#include <armnnUtils/DataLayoutIndexed.hpp>
#include <armnnUtils/Permute.hpp>
@@ -219,20 +220,20 @@ LayerTestResult<T, 4> SimpleConvolution2dTestImpl(
uint32_t dilationY = 1)
{
armnn::IgnoreUnused(memoryManager);
- unsigned int inputHeight = boost::numeric_cast<unsigned int>(originalInput.shape()[2]);
- unsigned int inputWidth = boost::numeric_cast<unsigned int>(originalInput.shape()[3]);
- unsigned int inputChannels = boost::numeric_cast<unsigned int>(originalInput.shape()[1]);
- unsigned int inputNum = boost::numeric_cast<unsigned int>(originalInput.shape()[0]);
+ unsigned int inputHeight = armnn::numeric_cast<unsigned int>(originalInput.shape()[2]);
+ unsigned int inputWidth = armnn::numeric_cast<unsigned int>(originalInput.shape()[3]);
+ unsigned int inputChannels = armnn::numeric_cast<unsigned int>(originalInput.shape()[1]);
+ unsigned int inputNum = armnn::numeric_cast<unsigned int>(originalInput.shape()[0]);
- unsigned int outputHeight = boost::numeric_cast<unsigned int>(originalOutputExpected.shape()[2]);
- unsigned int outputWidth = boost::numeric_cast<unsigned int>(originalOutputExpected.shape()[3]);
- unsigned int outputChannels = boost::numeric_cast<unsigned int>(originalOutputExpected.shape()[1]);
- unsigned int outputNum = boost::numeric_cast<unsigned int>(originalOutputExpected.shape()[0]);
+ unsigned int outputHeight = armnn::numeric_cast<unsigned int>(originalOutputExpected.shape()[2]);
+ unsigned int outputWidth = armnn::numeric_cast<unsigned int>(originalOutputExpected.shape()[3]);
+ unsigned int outputChannels = armnn::numeric_cast<unsigned int>(originalOutputExpected.shape()[1]);
+ unsigned int outputNum = armnn::numeric_cast<unsigned int>(originalOutputExpected.shape()[0]);
- unsigned int kernelHeight = boost::numeric_cast<unsigned int>(originalKernel.shape()[2]);
- unsigned int kernelWidth = boost::numeric_cast<unsigned int>(originalKernel.shape()[3]);
- unsigned int kernelChannels = boost::numeric_cast<unsigned int>(originalKernel.shape()[1]);
- unsigned int kernelDepthMul = boost::numeric_cast<unsigned int>(originalKernel.shape()[0]);
+ unsigned int kernelHeight = armnn::numeric_cast<unsigned int>(originalKernel.shape()[2]);
+ unsigned int kernelWidth = armnn::numeric_cast<unsigned int>(originalKernel.shape()[3]);
+ unsigned int kernelChannels = armnn::numeric_cast<unsigned int>(originalKernel.shape()[1]);
+ unsigned int kernelDepthMul = armnn::numeric_cast<unsigned int>(originalKernel.shape()[0]);
bool biasEnabled = bias.size() > 0;
@@ -385,20 +386,20 @@ LayerTestResult<O, 4> SimpleConvolution2dNhwcTestImpl(
uint32_t strideY = 1)
{
armnn::IgnoreUnused(qScale, qOffset);
- unsigned int inputNum = boost::numeric_cast<unsigned int>(input.shape()[0]);
- unsigned int inputChannels = boost::numeric_cast<unsigned int>(input.shape()[3]);
- unsigned int inputHeight = boost::numeric_cast<unsigned int>(input.shape()[1]);
- unsigned int inputWidth = boost::numeric_cast<unsigned int>(input.shape()[2]);
+ unsigned int inputNum = armnn::numeric_cast<unsigned int>(input.shape()[0]);
+ unsigned int inputChannels = armnn::numeric_cast<unsigned int>(input.shape()[3]);
+ unsigned int inputHeight = armnn::numeric_cast<unsigned int>(input.shape()[1]);
+ unsigned int inputWidth = armnn::numeric_cast<unsigned int>(input.shape()[2]);
- unsigned int kernelChanMul = boost::numeric_cast<unsigned int>(kernel.shape()[0]);
- unsigned int kernelChannels = boost::numeric_cast<unsigned int>(kernel.shape()[3]);
- unsigned int kernelHeight = boost::numeric_cast<unsigned int>(kernel.shape()[1]);
- unsigned int kernelWidth = boost::numeric_cast<unsigned int>(kernel.shape()[2]);
+ unsigned int kernelChanMul = armnn::numeric_cast<unsigned int>(kernel.shape()[0]);
+ unsigned int kernelChannels = armnn::numeric_cast<unsigned int>(kernel.shape()[3]);
+ unsigned int kernelHeight = armnn::numeric_cast<unsigned int>(kernel.shape()[1]);
+ unsigned int kernelWidth = armnn::numeric_cast<unsigned int>(kernel.shape()[2]);
- unsigned int outputNum = boost::numeric_cast<unsigned int>(outputExpected.shape()[0]);
- unsigned int outputChannels = boost::numeric_cast<unsigned int>(outputExpected.shape()[3]);
- unsigned int outputHeight = boost::numeric_cast<unsigned int>(outputExpected.shape()[1]);
- unsigned int outputWidth = boost::numeric_cast<unsigned int>(outputExpected.shape()[2]);
+ unsigned int outputNum = armnn::numeric_cast<unsigned int>(outputExpected.shape()[0]);
+ unsigned int outputChannels = armnn::numeric_cast<unsigned int>(outputExpected.shape()[3]);
+ unsigned int outputHeight = armnn::numeric_cast<unsigned int>(outputExpected.shape()[1]);
+ unsigned int outputWidth = armnn::numeric_cast<unsigned int>(outputExpected.shape()[2]);
bool biasEnabled = bias.size() > 0;
@@ -1643,18 +1644,18 @@ LayerTestResult<T, 4> DepthwiseConvolution2dAsymmetricTestImpl(
uint32_t strideX = 1,
uint32_t strideY = 1)
{
- unsigned int inputNum = boost::numeric_cast<unsigned int>(input.shape()[0]);
- unsigned int inputChannels = boost::numeric_cast<unsigned int>(input.shape()[1]);
- unsigned int inputHeight = boost::numeric_cast<unsigned int>(input.shape()[2]);
- unsigned int inputWidth = boost::numeric_cast<unsigned int>(input.shape()[3]);
- unsigned int kernelChanMul = boost::numeric_cast<unsigned int>(kernel.shape()[0]);
- unsigned int kernelChannels = boost::numeric_cast<unsigned int>(kernel.shape()[1]);
- unsigned int kernelHeight = boost::numeric_cast<unsigned int>(kernel.shape()[2]);
- unsigned int kernelWidth = boost::numeric_cast<unsigned int>(kernel.shape()[3]);
- unsigned int outputNum = boost::numeric_cast<unsigned int>(outputExpected.shape()[0]);
- unsigned int outputChannels = boost::numeric_cast<unsigned int>(outputExpected.shape()[1]);
- unsigned int outputHeight = boost::numeric_cast<unsigned int>(outputExpected.shape()[2]);
- unsigned int outputWidth = boost::numeric_cast<unsigned int>(outputExpected.shape()[3]);
+ unsigned int inputNum = armnn::numeric_cast<unsigned int>(input.shape()[0]);
+ unsigned int inputChannels = armnn::numeric_cast<unsigned int>(input.shape()[1]);
+ unsigned int inputHeight = armnn::numeric_cast<unsigned int>(input.shape()[2]);
+ unsigned int inputWidth = armnn::numeric_cast<unsigned int>(input.shape()[3]);
+ unsigned int kernelChanMul = armnn::numeric_cast<unsigned int>(kernel.shape()[0]);
+ unsigned int kernelChannels = armnn::numeric_cast<unsigned int>(kernel.shape()[1]);
+ unsigned int kernelHeight = armnn::numeric_cast<unsigned int>(kernel.shape()[2]);
+ unsigned int kernelWidth = armnn::numeric_cast<unsigned int>(kernel.shape()[3]);
+ unsigned int outputNum = armnn::numeric_cast<unsigned int>(outputExpected.shape()[0]);
+ unsigned int outputChannels = armnn::numeric_cast<unsigned int>(outputExpected.shape()[1]);
+ unsigned int outputHeight = armnn::numeric_cast<unsigned int>(outputExpected.shape()[2]);
+ unsigned int outputWidth = armnn::numeric_cast<unsigned int>(outputExpected.shape()[3]);
// If a bias is used, its size must equal the number of output channels.
bool biasEnabled = bias.size() > 0;
@@ -2151,20 +2152,20 @@ LayerTestResult<T, 4> DepthwiseConvolution2dTestImpl(
uint32_t dilationX = 1,
uint32_t dilationY = 1)
{
- unsigned int inputHeight = boost::numeric_cast<unsigned int>(originalInput.shape()[2]);
- unsigned int inputWidth = boost::numeric_cast<unsigned int>(originalInput.shape()[3]);
- unsigned int inputChannels = boost::numeric_cast<unsigned int>(originalInput.shape()[1]);
- unsigned int inputNum = boost::numeric_cast<unsigned int>(originalInput.shape()[0]);
-
- unsigned int outputHeight = boost::numeric_cast<unsigned int>(originalOutputExpected.shape()[2]);
- unsigned int outputWidth = boost::numeric_cast<unsigned int>(originalOutputExpected.shape()[3]);
- unsigned int outputChannels = boost::numeric_cast<unsigned int>(originalOutputExpected.shape()[1]);
- unsigned int outputNum = boost::numeric_cast<unsigned int>(originalOutputExpected.shape()[0]);
-
- unsigned int kernelHeight = boost::numeric_cast<unsigned int>(originalKernel.shape()[2]);
- unsigned int kernelWidth = boost::numeric_cast<unsigned int>(originalKernel.shape()[3]);
- unsigned int kernelChannels = boost::numeric_cast<unsigned int>(originalKernel.shape()[1]);
- unsigned int kernelDepthMul = boost::numeric_cast<unsigned int>(originalKernel.shape()[0]);
+ unsigned int inputHeight = armnn::numeric_cast<unsigned int>(originalInput.shape()[2]);
+ unsigned int inputWidth = armnn::numeric_cast<unsigned int>(originalInput.shape()[3]);
+ unsigned int inputChannels = armnn::numeric_cast<unsigned int>(originalInput.shape()[1]);
+ unsigned int inputNum = armnn::numeric_cast<unsigned int>(originalInput.shape()[0]);
+
+ unsigned int outputHeight = armnn::numeric_cast<unsigned int>(originalOutputExpected.shape()[2]);
+ unsigned int outputWidth = armnn::numeric_cast<unsigned int>(originalOutputExpected.shape()[3]);
+ unsigned int outputChannels = armnn::numeric_cast<unsigned int>(originalOutputExpected.shape()[1]);
+ unsigned int outputNum = armnn::numeric_cast<unsigned int>(originalOutputExpected.shape()[0]);
+
+ unsigned int kernelHeight = armnn::numeric_cast<unsigned int>(originalKernel.shape()[2]);
+ unsigned int kernelWidth = armnn::numeric_cast<unsigned int>(originalKernel.shape()[3]);
+ unsigned int kernelChannels = armnn::numeric_cast<unsigned int>(originalKernel.shape()[1]);
+ unsigned int kernelDepthMul = armnn::numeric_cast<unsigned int>(originalKernel.shape()[0]);
bool biasEnabled = bias.size() > 0;
diff --git a/src/backends/backendsCommon/test/layerTests/LstmTestImpl.cpp b/src/backends/backendsCommon/test/layerTests/LstmTestImpl.cpp
index 8f39f42452..088ca3b4c2 100644
--- a/src/backends/backendsCommon/test/layerTests/LstmTestImpl.cpp
+++ b/src/backends/backendsCommon/test/layerTests/LstmTestImpl.cpp
@@ -7,6 +7,7 @@
#include <QuantizeHelper.hpp>
+#include <armnn/utility/NumericCast.hpp>
#include <backendsCommon/CpuTensorHandle.hpp>
@@ -144,9 +145,9 @@ LstmNoCifgNoPeepholeNoProjectionTestImpl(
armnn::DataType constantDataType = armnn::DataType::Float32)
{
IgnoreUnused(memoryManager);
- unsigned int batchSize = boost::numeric_cast<unsigned int>(input.shape()[0]);
- unsigned int inputSize = boost::numeric_cast<unsigned int>(input.shape()[1]);
- unsigned int outputSize = boost::numeric_cast<unsigned int>(outputExpected.shape()[1]);
+ unsigned int batchSize = armnn::numeric_cast<unsigned int>(input.shape()[0]);
+ unsigned int inputSize = armnn::numeric_cast<unsigned int>(input.shape()[1]);
+ unsigned int outputSize = armnn::numeric_cast<unsigned int>(outputExpected.shape()[1]);
// cellSize and outputSize have the same size when there is no projection.
unsigned numUnits = outputSize;
@@ -1069,10 +1070,10 @@ LayerTestResult<T, 2> LstmLayerWithCifgWithPeepholeNoProjectionTestImpl(
bool peepholeEnabled = true;
bool projectionEnabled = false;
// These are not the input and the output of Lstm yet
- unsigned int batchSize = boost::numeric_cast<unsigned int>(input.shape()[0]);
- unsigned int inputSize = boost::numeric_cast<unsigned int>(input.shape()[1]);
+ unsigned int batchSize = armnn::numeric_cast<unsigned int>(input.shape()[0]);
+ unsigned int inputSize = armnn::numeric_cast<unsigned int>(input.shape()[1]);
- unsigned int outputSize = boost::numeric_cast<unsigned int>(outputExpected.shape()[1]);
+ unsigned int outputSize = armnn::numeric_cast<unsigned int>(outputExpected.shape()[1]);
const unsigned int cellSize = outputSize;
@@ -1560,9 +1561,9 @@ LayerTestResult<uint8_t, 2> QuantizedLstmTestImpl(
const boost::multi_array<uint8_t, 2>& outputExpected)
{
IgnoreUnused(memoryManager);
- auto numBatches = boost::numeric_cast<unsigned int>(input.shape()[0]);
- auto inputSize = boost::numeric_cast<unsigned int>(input.shape()[1]);
- auto outputSize = boost::numeric_cast<unsigned int>(outputExpected.shape()[1]);
+ auto numBatches = armnn::numeric_cast<unsigned int>(input.shape()[0]);
+ auto inputSize = armnn::numeric_cast<unsigned int>(input.shape()[1]);
+ auto outputSize = armnn::numeric_cast<unsigned int>(outputExpected.shape()[1]);
// Scale/Offset for input/output, cellState In/Out, weights, bias
float inputOutputScale = 0.0078125f;
diff --git a/src/backends/backendsCommon/test/layerTests/NormalizationTestImpl.cpp b/src/backends/backendsCommon/test/layerTests/NormalizationTestImpl.cpp
index b42b180dc9..2e8e16f0c2 100644
--- a/src/backends/backendsCommon/test/layerTests/NormalizationTestImpl.cpp
+++ b/src/backends/backendsCommon/test/layerTests/NormalizationTestImpl.cpp
@@ -8,6 +8,8 @@
#include <armnn/Exceptions.hpp>
#include <armnn/LayerSupport.hpp>
+#include <armnn/utility/NumericCast.hpp>
+
#include <backendsCommon/CpuTensorHandle.hpp>
#include <backendsCommon/test/TensorCopyUtils.hpp>
@@ -102,7 +104,7 @@ LayerTestResult<float,4> SimpleNormalizationTestImpl(
// pow((kappa + (accumulatedScale * alpha)), beta)
// ...where accumulatedScale is the sum of every element squared.
float divisor[inputNum];
- for(int i = 0; i < boost::numeric_cast<int>(inputNum); i++)
+ for(int i = 0; i < armnn::numeric_cast<int>(inputNum); i++)
{
float accumulatedScale = input[i][0][0][0]*input[i][0][0][0] +
input[i][0][0][1]*input[i][0][0][1] +
@@ -129,11 +131,11 @@ LayerTestResult<float,4> SimpleNormalizationTestImpl(
// ...where adjacent channels means within half the normSize for the channel
// The test data has only one channel, so this is simplified below.
std::vector<float> outputVector;
- for (int n = 0; n < boost::numeric_cast<int>(inputNum); ++n)
+ for (int n = 0; n < armnn::numeric_cast<int>(inputNum); ++n)
{
- for (int h = 0; h < boost::numeric_cast<int>(inputHeight); ++h)
+ for (int h = 0; h < armnn::numeric_cast<int>(inputHeight); ++h)
{
- for (int w = 0; w < boost::numeric_cast<int>(inputWidth); ++w)
+ for (int w = 0; w < armnn::numeric_cast<int>(inputWidth); ++w)
{
float accumulatedScale = input[n][0][h][w]*input[n][0][h][w];
float scale = powf((kappa + accumulatedScale * alpha), -beta);
diff --git a/src/backends/backendsCommon/test/layerTests/Pooling2dTestImpl.cpp b/src/backends/backendsCommon/test/layerTests/Pooling2dTestImpl.cpp
index a4f87ff3ed..70e2e61475 100644
--- a/src/backends/backendsCommon/test/layerTests/Pooling2dTestImpl.cpp
+++ b/src/backends/backendsCommon/test/layerTests/Pooling2dTestImpl.cpp
@@ -15,6 +15,7 @@
#include <armnnUtils/Permute.hpp>
#include <armnn/utility/IgnoreUnused.hpp>
+#include <armnn/utility/NumericCast.hpp>
#include <backendsCommon/WorkloadInfo.hpp>
@@ -48,15 +49,15 @@ LayerTestResult<T, 4> SimplePooling2dTestImpl(
auto widthIndex = dimensionIndices.GetWidthIndex();
auto channelsIndex = dimensionIndices.GetChannelsIndex();
- unsigned int inputHeight = boost::numeric_cast<unsigned int>(input.shape()[heightIndex]);
- unsigned int inputWidth = boost::numeric_cast<unsigned int>(input.shape()[widthIndex]);
- unsigned int inputChannels = boost::numeric_cast<unsigned int>(input.shape()[channelsIndex]);
- unsigned int inputBatchSize = boost::numeric_cast<unsigned int>(input.shape()[0]);
+ unsigned int inputHeight = armnn::numeric_cast<unsigned int>(input.shape()[heightIndex]);
+ unsigned int inputWidth = armnn::numeric_cast<unsigned int>(input.shape()[widthIndex]);
+ unsigned int inputChannels = armnn::numeric_cast<unsigned int>(input.shape()[channelsIndex]);
+ unsigned int inputBatchSize = armnn::numeric_cast<unsigned int>(input.shape()[0]);
- unsigned int outputHeight = boost::numeric_cast<unsigned int>(outputExpected.shape()[heightIndex]);
- unsigned int outputWidth = boost::numeric_cast<unsigned int>(outputExpected.shape()[widthIndex]);
- unsigned int outputChannels = boost::numeric_cast<unsigned int>(outputExpected.shape()[channelsIndex]);
- unsigned int outputBatchSize = boost::numeric_cast<unsigned int>(outputExpected.shape()[0]);
+ unsigned int outputHeight = armnn::numeric_cast<unsigned int>(outputExpected.shape()[heightIndex]);
+ unsigned int outputWidth = armnn::numeric_cast<unsigned int>(outputExpected.shape()[widthIndex]);
+ unsigned int outputChannels = armnn::numeric_cast<unsigned int>(outputExpected.shape()[channelsIndex]);
+ unsigned int outputBatchSize = armnn::numeric_cast<unsigned int>(outputExpected.shape()[0]);
armnn::TensorInfo inputTensorInfo = armnnUtils::GetTensorInfo(
inputBatchSize, inputChannels, inputHeight, inputWidth, dataLayout, ArmnnType);