ArmNN
 21.08
ActivationTestImpl.hpp File Reference

Go to the source code of this file.

Functions

LayerTestResult< float, 4 > SimpleSigmoidTest (armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
 
LayerTestResult< uint8_t, 4 > SimpleSigmoidUint8Test (armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
 
LayerTestResult< int16_t, 4 > SimpleSigmoidInt16Test (armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
 
LayerTestResult< float, 4 > TanhTest (armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
 
LayerTestResult< uint8_t, 4 > TanhUint8Test (armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
 
LayerTestResult< int16_t, 4 > TanhInt16Test (armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
 
LayerTestResult< float, 4 > ConstantLinearActivationTest (armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
 
LayerTestResult< uint8_t, 4 > ConstantLinearActivationUint8Test (armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
 
LayerTestResult< int16_t, 4 > ConstantLinearActivationInt16Test (armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
 
LayerTestResult< float, 4 > ReLuTest (armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
 
LayerTestResult< uint8_t, 4 > ReLuUint8Test (armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
 
LayerTestResult< int16_t, 4 > ReLuInt16Test (armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
 
LayerTestResult< uint8_t, 4 > BoundedReLuUint8Test (armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, float upperBound)
 
LayerTestResult< uint8_t, 4 > BoundedReLuUint8Test (armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, float upperBound, float lowerBound)
 
LayerTestResult< int16_t, 4 > BoundedReLuInt16Test (armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
 
LayerTestResult< float, 4 > BoundedReLuUpperAndLowerBoundTest (armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
 
LayerTestResult< uint8_t, 4 > BoundedReLuUint8UpperAndLowerBoundTest (armnn::IWorkloadFactory &workloadFactor, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManagery, const armnn::ITensorHandleFactory &tensorHandleFactory)
 
LayerTestResult< float, 4 > BoundedReLuUpperBoundOnlyTest (armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
 
LayerTestResult< uint8_t, 4 > BoundedReLuUint8UpperBoundOnlyTest (armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
 
LayerTestResult< float, 4 > CompareBoundedReLuTest (armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, armnn::IWorkloadFactory &refWorkloadFactory, const armnn::ITensorHandleFactory &tensorHandleFactory, const armnn::ITensorHandleFactory &refTensorHandleFactory, float upperBound, float lowerBound)
 
LayerTestResult< float, 4 > SoftReLuTest (armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
 
LayerTestResult< uint8_t, 4 > SoftReLuUint8Test (armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
 
LayerTestResult< int16_t, 4 > SoftReLuInt16Test (armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
 
LayerTestResult< float, 4 > LeakyReLuTest (armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
 
LayerTestResult< uint8_t, 4 > LeakyReLuUint8Test (armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
 
LayerTestResult< int16_t, 4 > LeakyReLuInt16Test (armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
 
LayerTestResult< float, 4 > EluTest (armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
 
LayerTestResult< uint8_t, 4 > EluUint8Test (armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
 
LayerTestResult< int16_t, 4 > EluInt16Test (armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
 
LayerTestResult< float, 4 > AbsTest (armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
 
LayerTestResult< uint8_t, 4 > AbsUint8Test (armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
 
LayerTestResult< int16_t, 4 > AbsInt16Test (armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
 
LayerTestResult< float, 4 > SqrtTest (armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
 
LayerTestResult< float, 5 > SqrtNNTest (armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
 
LayerTestResult< uint8_t, 4 > SqrtUint8Test (armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
 
LayerTestResult< int16_t, 4 > SqrtInt16Test (armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
 
LayerTestResult< float, 4 > SquareTest (armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
 
LayerTestResult< uint8_t, 4 > SquareUint8Test (armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
 
LayerTestResult< int16_t, 4 > SquareInt16Test (armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
 
LayerTestResult< float, 4 > HardSwishTest (armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
 
LayerTestResult< uint8_t, 4 > HardSwishUint8Test (armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
 
LayerTestResult< int16_t, 4 > HardSwishInt16Test (armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
 
LayerTestResult< float, 4 > CompareActivationTest (armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, armnn::IWorkloadFactory &refWorkloadFactory, const armnn::ITensorHandleFactory &tensorHandleFactory, const armnn::ITensorHandleFactory &refTensorHandleFactory, armnn::ActivationFunction f, unsigned int batchSize)
 
LayerTestResult< uint8_t, 4 > CompareActivationUint8Test (armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, armnn::IWorkloadFactory &refWorkloadFactory, const armnn::ITensorHandleFactory &tensorHandleFactory, const armnn::ITensorHandleFactory &refTensorHandleFactory, armnn::ActivationFunction f)
 
LayerTestResult< int16_t, 4 > CompareActivationInt16Test (armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, armnn::IWorkloadFactory &refWorkloadFactory, const armnn::ITensorHandleFactory &tensorHandleFactory, const armnn::ITensorHandleFactory &refTensorHandleFactory, armnn::ActivationFunction f)
 

Function Documentation

◆ AbsInt16Test()

LayerTestResult<int16_t, 4> AbsInt16Test ( armnn::IWorkloadFactory workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr memoryManager,
const armnn::ITensorHandleFactory tensorHandleFactory 
)

Definition at line 832 of file ActivationTestImpl.cpp.

Referenced by TEST_SUITE().

836 {
837  return AbsTestCommon<armnn::DataType::QSymmS16>(workloadFactory, memoryManager, tensorHandleFactory, 0.1f, 0);
838 }

◆ AbsTest()

LayerTestResult<float, 4> AbsTest ( armnn::IWorkloadFactory workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr memoryManager,
const armnn::ITensorHandleFactory tensorHandleFactory 
)

Definition at line 816 of file ActivationTestImpl.cpp.

Referenced by TEST_SUITE().

820 {
821  return AbsTestCommon<armnn::DataType::Float32>(workloadFactory, memoryManager, tensorHandleFactory, 0.1f, 0);
822 }

◆ AbsUint8Test()

LayerTestResult<uint8_t, 4> AbsUint8Test ( armnn::IWorkloadFactory workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr memoryManager,
const armnn::ITensorHandleFactory tensorHandleFactory 
)

Definition at line 824 of file ActivationTestImpl.cpp.

Referenced by TEST_SUITE().

828 {
829  return AbsTestCommon<armnn::DataType::QAsymmU8>(workloadFactory, memoryManager, tensorHandleFactory, 0.0625f, 64);
830 }

◆ BoundedReLuInt16Test()

LayerTestResult<int16_t, 4> BoundedReLuInt16Test ( armnn::IWorkloadFactory workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr memoryManager,
const armnn::ITensorHandleFactory tensorHandleFactory 
)

Definition at line 644 of file ActivationTestImpl.cpp.

Referenced by TEST_SUITE().

648 {
649  return ReLuTestCommon<armnn::DataType::QSymmS16>(workloadFactory, memoryManager, tensorHandleFactory, 0.1f, 0);
650 }

◆ BoundedReLuUint8Test() [1/2]

LayerTestResult<uint8_t, 4> BoundedReLuUint8Test ( armnn::IWorkloadFactory workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr memoryManager,
float  upperBound 
)

◆ BoundedReLuUint8Test() [2/2]

LayerTestResult<uint8_t, 4> BoundedReLuUint8Test ( armnn::IWorkloadFactory workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr memoryManager,
float  upperBound,
float  lowerBound 
)

◆ BoundedReLuUint8UpperAndLowerBoundTest()

LayerTestResult<uint8_t, 4> BoundedReLuUint8UpperAndLowerBoundTest ( armnn::IWorkloadFactory workloadFactor,
const armnn::IBackendInternal::IMemoryManagerSharedPtr memoryManagery,
const armnn::ITensorHandleFactory tensorHandleFactory 
)

Definition at line 187 of file ActivationTestImpl.cpp.

References CopyDataFromITensorHandle(), CopyDataToITensorHandle(), IWorkloadFactory::CreateActivation(), ITensorHandleFactory::CreateTensorHandle(), armnn::Float32, TensorInfo::GetNumElements(), armnn::IgnoreUnused(), and QueueDescriptorWithParameters< LayerDescriptor >::m_Parameters.

Referenced by TEST_SUITE().

191 {
192  unsigned int inputWidth = 3u;
193  unsigned int inputHeight = 2u;
194  unsigned int inputChannels = 1u;
195  unsigned int inputBatchSize = 1;
196 
197  std::vector<uint8_t> input = std::vector<uint8_t>{
198  51, 230, 28,
199  251, 8, 92
200  };
201 
202  // Calculated manually.
203  std::vector<uint8_t> output = std::vector<uint8_t>{
204  51, 192, 32,
205  192, 32, 92
206  };
207 
208  int32_t inputOffset = 112;
209  float inputScale = 0.0125f;
210 
211  return BoundedReLuTestCommon<armnn::DataType::QAsymmU8>(
212  workloadFactory, memoryManager, tensorHandleFactory, 1.0f, -1.0f,
213  inputScale, inputOffset, inputScale, inputOffset, // Input/output scale & offset same.
214  input, output, inputWidth, inputHeight, inputChannels, inputBatchSize);
215 }

◆ BoundedReLuUint8UpperBoundOnlyTest()

LayerTestResult<uint8_t, 4> BoundedReLuUint8UpperBoundOnlyTest ( armnn::IWorkloadFactory workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr memoryManager,
const armnn::ITensorHandleFactory tensorHandleFactory 
)

Definition at line 155 of file ActivationTestImpl.cpp.

Referenced by TEST_SUITE().

159 {
160  unsigned int inputWidth = 3u;
161  unsigned int inputHeight = 2u;
162  unsigned int inputChannels = 1u;
163  unsigned int inputBatchSize = 1;
164 
165  std::vector<uint8_t> input = std::vector<uint8_t>{
166  51, 124, 28,
167  251, 8, 92
168  };
169 
170  // Calculated manually.
171  std::vector<uint8_t> output = std::vector<uint8_t>{
172  0, 122, 0,
173  255, 0, 58
174  };
175 
176  float inputScale = 12.0f / 255.0f;
177  int32_t inputOffset = 63;
178  float outputScale = 6.0f / 255.0f;
179  int32_t outputOffset = 0;
180 
181  return BoundedReLuTestCommon<armnn::DataType::QAsymmU8>(
182  workloadFactory, memoryManager, tensorHandleFactory, 6.0f, 0.0f,
183  inputScale, inputOffset, outputScale, outputOffset,
184  input, output, inputWidth, inputHeight, inputChannels, inputBatchSize);
185 }

◆ BoundedReLuUpperAndLowerBoundTest()

LayerTestResult<float, 4> BoundedReLuUpperAndLowerBoundTest ( armnn::IWorkloadFactory workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr memoryManager,
const armnn::ITensorHandleFactory tensorHandleFactory 
)

Definition at line 91 of file ActivationTestImpl.cpp.

Referenced by TEST_SUITE().

95 {
96  unsigned int inputWidth = 4u;
97  unsigned int inputHeight = 5u;
98  unsigned int inputChannels = 1u;
99  unsigned int inputBatchSize = 1;
100 
101  std::vector<float> input = std::vector<float>{
102  -2.0f, 0.1f, 0.5f, 1.25f,
103  0.786f, 0.9875f, -1.5f, 0.384f,
104  1.0001f, 3.5f, 7.5f, 0.896f,
105  2.126f, 2.0f, 0.3f, 0.15f,
106  0.999f, 1.2f, 0.89f, 6.1f,
107  };
108 
109  // Calculated manually.
110  std::vector<float> output = std::vector<float>{
111  -1.0f, 0.1f, 0.5f, 1.0f,
112  0.786f, 0.9875f, -1.0f, 0.384f,
113  1.0f, 1.0f, 1.0f, 0.896f,
114  1.0f, 1.0f, 0.3f, 0.15f,
115  0.999f, 1.0f, 0.89f, 1.0f,
116  };
117 
118  return BoundedReLuTestCommon<armnn::DataType::Float32>(
119  workloadFactory, memoryManager, tensorHandleFactory, 1.0f, -1.0f, 1.0f, 0, 1.0f, 0, input, output,
120  inputWidth, inputHeight, inputChannels, inputBatchSize);
121 }

◆ BoundedReLuUpperBoundOnlyTest()

LayerTestResult<float, 4> BoundedReLuUpperBoundOnlyTest ( armnn::IWorkloadFactory workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr memoryManager,
const armnn::ITensorHandleFactory tensorHandleFactory 
)

Definition at line 123 of file ActivationTestImpl.cpp.

Referenced by TEST_SUITE().

127 {
128  unsigned int inputWidth = 4u;
129  unsigned int inputHeight = 5u;
130  unsigned int inputChannels = 1u;
131  unsigned int inputBatchSize = 1;
132 
133  std::vector<float> input = std::vector<float>{
134  -1.0f, 0.1f, 0.5f, 6.25f,
135  0.786f, 5.9875f, -0.5f, 0.384f,
136  6.0001f, 3.5f, 7.5f, 0.896f,
137  2.126f, 12.0f, 0.3f, 0.15f,
138  0.999f, 1.2f, 0.89f, 6.1f,
139  };
140 
141  // Calculated manually.
142  std::vector<float> output = std::vector<float>{
143  0.0f, 0.1f, 0.5f, 6.0f,
144  0.786f, 5.9875f, 0.0f, 0.384f,
145  6.0f, 3.5f, 6.0f, 0.896f,
146  2.126f, 6.0f, 0.3f, 0.15f,
147  0.999f, 1.2f, 0.89f, 6.0f,
148  };
149 
150  return BoundedReLuTestCommon<armnn::DataType::Float32>(
151  workloadFactory, memoryManager, tensorHandleFactory, 6.0f, 0.0f, 1.0f, 0, 1.0f, 0, input, output,
152  inputWidth, inputHeight, inputChannels, inputBatchSize);
153 }

◆ CompareActivationInt16Test()

LayerTestResult<int16_t, 4> CompareActivationInt16Test ( armnn::IWorkloadFactory workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr memoryManager,
armnn::IWorkloadFactory refWorkloadFactory,
const armnn::ITensorHandleFactory tensorHandleFactory,
const armnn::ITensorHandleFactory refTensorHandleFactory,
armnn::ActivationFunction  f 
)

Definition at line 1334 of file ActivationTestImpl.cpp.

1341 {
1342  return CompareActivationTestImpl<armnn::DataType::QSymmS16>(
1343  workloadFactory, memoryManager, refWorkloadFactory, tensorHandleFactory,
1344  refTensorHandleFactory, f, 5, 0.1f, 0);
1345 }

◆ CompareActivationTest()

LayerTestResult<float, 4> CompareActivationTest ( armnn::IWorkloadFactory workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr memoryManager,
armnn::IWorkloadFactory refWorkloadFactory,
const armnn::ITensorHandleFactory tensorHandleFactory,
const armnn::ITensorHandleFactory refTensorHandleFactory,
armnn::ActivationFunction  f,
unsigned int  batchSize 
)

Definition at line 1307 of file ActivationTestImpl.cpp.

Referenced by TEST_SUITE().

1315 {
1316  return CompareActivationTestImpl<armnn::DataType::Float32>(
1317  workloadFactory, memoryManager, refWorkloadFactory, tensorHandleFactory,
1318  refTensorHandleFactory, f, batchSize);
1319 }

◆ CompareActivationUint8Test()

LayerTestResult<uint8_t, 4> CompareActivationUint8Test ( armnn::IWorkloadFactory workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr memoryManager,
armnn::IWorkloadFactory refWorkloadFactory,
const armnn::ITensorHandleFactory tensorHandleFactory,
const armnn::ITensorHandleFactory refTensorHandleFactory,
armnn::ActivationFunction  f 
)

Definition at line 1321 of file ActivationTestImpl.cpp.

Referenced by TEST_SUITE().

1328 {
1329  return CompareActivationTestImpl<armnn::DataType::QAsymmU8>(
1330  workloadFactory, memoryManager, refWorkloadFactory,
1331  tensorHandleFactory, refTensorHandleFactory, f, 5, 0.1f, 50);
1332 }

◆ CompareBoundedReLuTest()

LayerTestResult<float, 4> CompareBoundedReLuTest ( armnn::IWorkloadFactory workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr memoryManager,
armnn::IWorkloadFactory refWorkloadFactory,
const armnn::ITensorHandleFactory tensorHandleFactory,
const armnn::ITensorHandleFactory refTensorHandleFactory,
float  upperBound,
float  lowerBound 
)

Definition at line 288 of file ActivationTestImpl.cpp.

References armnn::BoundedReLu, ActivationDescriptor::m_A, LayerTestResult< T, n >::m_ActualData, ActivationDescriptor::m_B, LayerTestResult< T, n >::m_ExpectedData, and ActivationDescriptor::m_Function.

Referenced by TEST_SUITE().

296 {
297  LayerTestResult<float, 4> result(BoundedReLuRandomInputTestTraits::GetOutputTensorInfo());
298 
299  armnn::ActivationDescriptor activationDescriptor;
300  activationDescriptor.m_Function = armnn::ActivationFunction::BoundedReLu;
301  activationDescriptor.m_A = upperBound;
302  activationDescriptor.m_B = lowerBound;
303 
304  result.m_ActualData = BoundedReLuRandomInputTest(
305  workloadFactory, memoryManager, tensorHandleFactory, 0.0f, upperBound, activationDescriptor);
306  result.m_ExpectedData = BoundedReLuRandomInputTest(
307  refWorkloadFactory, nullptr, refTensorHandleFactory, 0.0f, upperBound, activationDescriptor);
308 
309  return result;
310 }
An ActivationDescriptor for the ActivationLayer.
Definition: Descriptors.hpp:25
min(a, max(b, input)) ReLu1 & ReLu6.
float m_A
Alpha upper bound value used by the activation functions. (BoundedReLu, Linear, TanH, Elu).
Definition: Descriptors.hpp:50
float m_B
Beta lower bound value used by the activation functions. (BoundedReLu, Linear, TanH).
Definition: Descriptors.hpp:52
ActivationFunction m_Function
The activation function to use (Sigmoid, TanH, Linear, ReLu, BoundedReLu, SoftReLu, LeakyReLu, Abs, Sqrt, Square, Elu).
Definition: Descriptors.hpp:48

◆ ConstantLinearActivationInt16Test()

LayerTestResult<int16_t, 4> ConstantLinearActivationInt16Test ( armnn::IWorkloadFactory workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr memoryManager,
const armnn::ITensorHandleFactory tensorHandleFactory 
)

Definition at line 395 of file ActivationTestImpl.cpp.

Referenced by TEST_SUITE().

399 {
400  return ConstantLinearActivationTestCommon<armnn::DataType::QSymmS16>(
401  workloadFactory, memoryManager, tensorHandleFactory, 0.1f, 0);
402 }

◆ ConstantLinearActivationTest()

LayerTestResult<float, 4> ConstantLinearActivationTest ( armnn::IWorkloadFactory workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr memoryManager,
const armnn::ITensorHandleFactory tensorHandleFactory 
)

Definition at line 376 of file ActivationTestImpl.cpp.

Referenced by TEST_SUITE().

380 {
381  return ConstantLinearActivationTestCommon<armnn::DataType::Float32>(workloadFactory,
382  memoryManager,
383  tensorHandleFactory);
384 }

◆ ConstantLinearActivationUint8Test()

LayerTestResult<uint8_t, 4> ConstantLinearActivationUint8Test ( armnn::IWorkloadFactory workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr memoryManager,
const armnn::ITensorHandleFactory tensorHandleFactory 
)

Definition at line 386 of file ActivationTestImpl.cpp.

Referenced by TEST_SUITE().

390 {
391  return ConstantLinearActivationTestCommon<armnn::DataType::QAsymmU8>(
392  workloadFactory, memoryManager, tensorHandleFactory, 4.0f, 3);
393 }

◆ EluInt16Test()

LayerTestResult<int16_t, 4> EluInt16Test ( armnn::IWorkloadFactory workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr memoryManager,
const armnn::ITensorHandleFactory tensorHandleFactory 
)

Definition at line 1137 of file ActivationTestImpl.cpp.

Referenced by TEST_SUITE().

1141 {
1142  return EluTestCommon<armnn::DataType::QSymmS16>(workloadFactory, memoryManager, tensorHandleFactory, 0.1f, 0);
1143 }

◆ EluTest()

LayerTestResult<float, 4> EluTest ( armnn::IWorkloadFactory workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr memoryManager,
const armnn::ITensorHandleFactory tensorHandleFactory 
)

Definition at line 1121 of file ActivationTestImpl.cpp.

Referenced by TEST_SUITE().

1125 {
1126  return EluTestCommon<armnn::DataType::Float32>(workloadFactory, memoryManager, tensorHandleFactory, 0.1f, 0);
1127 }

◆ EluUint8Test()

LayerTestResult<uint8_t, 4> EluUint8Test ( armnn::IWorkloadFactory workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr memoryManager,
const armnn::ITensorHandleFactory tensorHandleFactory 
)

Definition at line 1129 of file ActivationTestImpl.cpp.

Referenced by TEST_SUITE().

1133 {
1134  return EluTestCommon<armnn::DataType::QAsymmU8>(workloadFactory, memoryManager, tensorHandleFactory, 0.1f, 64);
1135 }

◆ HardSwishInt16Test()

LayerTestResult<int16_t, 4> HardSwishInt16Test ( armnn::IWorkloadFactory workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr memoryManager,
const armnn::ITensorHandleFactory tensorHandleFactory 
)

Definition at line 1206 of file ActivationTestImpl.cpp.

Referenced by TEST_SUITE().

1210 {
1211  return HardSwishTestCommon<armnn::DataType::QSymmS16>(workloadFactory, memoryManager, tensorHandleFactory, 0.1f, 0);
1212 }

◆ HardSwishTest()

LayerTestResult<float, 4> HardSwishTest ( armnn::IWorkloadFactory workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr memoryManager,
const armnn::ITensorHandleFactory tensorHandleFactory 
)

Definition at line 1189 of file ActivationTestImpl.cpp.

Referenced by TEST_SUITE().

1193 {
1194  return HardSwishTestCommon<armnn::DataType::Float32>(workloadFactory, memoryManager, tensorHandleFactory, 0.1f, 0);
1195 }

◆ HardSwishUint8Test()

LayerTestResult<uint8_t, 4> HardSwishUint8Test ( armnn::IWorkloadFactory workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr memoryManager,
const armnn::ITensorHandleFactory tensorHandleFactory 
)

Definition at line 1197 of file ActivationTestImpl.cpp.

Referenced by TEST_SUITE().

1201 {
1202  return HardSwishTestCommon<armnn::DataType::QAsymmU8>(workloadFactory, memoryManager,
1203  tensorHandleFactory, 0.1f, 64);
1204 }

◆ LeakyReLuInt16Test()

LayerTestResult<int16_t, 4> LeakyReLuInt16Test ( armnn::IWorkloadFactory workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr memoryManager,
const armnn::ITensorHandleFactory tensorHandleFactory 
)

Definition at line 771 of file ActivationTestImpl.cpp.

Referenced by TEST_SUITE().

775 {
776  return LeakyReLuTestCommon<armnn::DataType::QSymmS16>(workloadFactory, memoryManager, tensorHandleFactory, 0.1f, 0);
777 }

◆ LeakyReLuTest()

LayerTestResult<float, 4> LeakyReLuTest ( armnn::IWorkloadFactory workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr memoryManager,
const armnn::ITensorHandleFactory tensorHandleFactory 
)

Definition at line 754 of file ActivationTestImpl.cpp.

Referenced by TEST_SUITE().

758 {
759  return LeakyReLuTestCommon<armnn::DataType::Float32>(workloadFactory, memoryManager, tensorHandleFactory, 0.1f, 0);
760 }

◆ LeakyReLuUint8Test()

LayerTestResult<uint8_t, 4> LeakyReLuUint8Test ( armnn::IWorkloadFactory workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr memoryManager,
const armnn::ITensorHandleFactory tensorHandleFactory 
)

Definition at line 762 of file ActivationTestImpl.cpp.

Referenced by TEST_SUITE().

766 {
767  return LeakyReLuTestCommon<armnn::DataType::QAsymmU8>(workloadFactory, memoryManager,
768  tensorHandleFactory, 0.0625f, 64);
769 }

◆ ReLuInt16Test()

LayerTestResult<int16_t, 4> ReLuInt16Test ( armnn::IWorkloadFactory workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr memoryManager,
const armnn::ITensorHandleFactory tensorHandleFactory 
)

Definition at line 580 of file ActivationTestImpl.cpp.

Referenced by TEST_SUITE().

584 {
585  return ReLuTestCommon<armnn::DataType::QSymmS16>(workloadFactory, memoryManager, tensorHandleFactory, 0.1f, 0);
586 }

◆ ReLuTest()

LayerTestResult<float, 4> ReLuTest ( armnn::IWorkloadFactory workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr memoryManager,
const armnn::ITensorHandleFactory tensorHandleFactory 
)

Definition at line 597 of file ActivationTestImpl.cpp.

Referenced by TEST_SUITE().

601 {
602  return ReLuTestCommon<armnn::DataType::Float32>(workloadFactory, memoryManager, tensorHandleFactory, 0.1f, 0);
603 }

◆ ReLuUint8Test()

LayerTestResult<uint8_t, 4> ReLuUint8Test ( armnn::IWorkloadFactory workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr memoryManager,
const armnn::ITensorHandleFactory tensorHandleFactory 
)

Definition at line 589 of file ActivationTestImpl.cpp.

Referenced by TEST_SUITE().

593 {
594  return ReLuTestCommon<armnn::DataType::QAsymmU8>(workloadFactory, memoryManager, tensorHandleFactory, 0.1f, 0);
595 }

◆ SimpleSigmoidInt16Test()

LayerTestResult<int16_t, 4> SimpleSigmoidInt16Test ( armnn::IWorkloadFactory workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr memoryManager,
const armnn::ITensorHandleFactory tensorHandleFactory 
)

Definition at line 534 of file ActivationTestImpl.cpp.

Referenced by TEST_SUITE().

538 {
539  return SimpleSigmoidTestCommon<armnn::DataType::QSymmS16>(workloadFactory, memoryManager,
540  tensorHandleFactory, 0.1f, 0);
541 }

◆ SimpleSigmoidTest()

LayerTestResult<float, 4> SimpleSigmoidTest ( armnn::IWorkloadFactory workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr memoryManager,
const armnn::ITensorHandleFactory tensorHandleFactory 
)

Definition at line 516 of file ActivationTestImpl.cpp.

Referenced by TEST_SUITE().

520 {
521  return SimpleSigmoidTestCommon<armnn::DataType::Float32>(workloadFactory, memoryManager,
522  tensorHandleFactory, 0.0f, 0);
523 }

◆ SimpleSigmoidUint8Test()

LayerTestResult<uint8_t, 4> SimpleSigmoidUint8Test ( armnn::IWorkloadFactory workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr memoryManager,
const armnn::ITensorHandleFactory tensorHandleFactory 
)

Definition at line 525 of file ActivationTestImpl.cpp.

Referenced by TEST_SUITE().

529 {
530  return SimpleSigmoidTestCommon<armnn::DataType::QAsymmU8>(workloadFactory, memoryManager,
531  tensorHandleFactory, 0.1f, 50);
532 }

◆ SoftReLuInt16Test()

LayerTestResult<int16_t, 4> SoftReLuInt16Test ( armnn::IWorkloadFactory workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr memoryManager,
const armnn::ITensorHandleFactory tensorHandleFactory 
)

Definition at line 708 of file ActivationTestImpl.cpp.

Referenced by TEST_SUITE().

712 {
713  return SoftReLuTestCommon<armnn::DataType::QSymmS16>(workloadFactory, memoryManager, tensorHandleFactory, 0.1f, 0);
714 }

◆ SoftReLuTest()

LayerTestResult<float, 4> SoftReLuTest ( armnn::IWorkloadFactory workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr memoryManager,
const armnn::ITensorHandleFactory tensorHandleFactory 
)

Definition at line 691 of file ActivationTestImpl.cpp.

Referenced by TEST_SUITE().

695 {
696  return SoftReLuTestCommon<armnn::DataType::Float32>(workloadFactory, memoryManager, tensorHandleFactory, 0.1f, 0);
697 }

◆ SoftReLuUint8Test()

LayerTestResult<uint8_t, 4> SoftReLuUint8Test ( armnn::IWorkloadFactory workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr memoryManager,
const armnn::ITensorHandleFactory tensorHandleFactory 
)

Definition at line 699 of file ActivationTestImpl.cpp.

Referenced by TEST_SUITE().

703 {
704  return SoftReLuTestCommon<armnn::DataType::QAsymmU8>(workloadFactory, memoryManager,
705  tensorHandleFactory, 0.0625f, 64);
706 }

◆ SqrtInt16Test()

LayerTestResult<int16_t, 4> SqrtInt16Test ( armnn::IWorkloadFactory workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr memoryManager,
const armnn::ITensorHandleFactory tensorHandleFactory 
)

Definition at line 948 of file ActivationTestImpl.cpp.

Referenced by TEST_SUITE().

952 {
953  return SqrtTestCommon<armnn::DataType::QSymmS16>(workloadFactory, memoryManager, tensorHandleFactory, 0.1f, 0);
954 }

◆ SqrtNNTest()

LayerTestResult<float, 5> SqrtNNTest ( armnn::IWorkloadFactory workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr memoryManager,
const armnn::ITensorHandleFactory tensorHandleFactory 
)

Definition at line 840 of file ActivationTestImpl.cpp.

References CopyDataFromITensorHandle(), CopyDataToITensorHandle(), IWorkloadFactory::CreateActivation(), ITensorHandleFactory::CreateTensorHandle(), armnn::Float32, armnn::IgnoreUnused(), ActivationDescriptor::m_Function, QueueDescriptorWithParameters< LayerDescriptor >::m_Parameters, and armnn::Sqrt.

Referenced by TEST_SUITE().

844 {
845  IgnoreUnused(memoryManager);
846  const int inputDataSize = 120;
847  std::vector<float> inputData(inputDataSize);
848 
849  for (unsigned int i = 0u; i < inputDataSize; ++i)
850  {
851  inputData[i] = static_cast<float>(i) / 10;
852  }
853 
854  auto f = [](float value)
855  {
856  return std::sqrt(value);
857  };
858  std::vector<float> expectedOutput(inputDataSize);
859  std::transform(inputData.begin(), inputData.end(), expectedOutput.begin(), f);
860 
861  armnn::TensorInfo inputTensorInfo(
862  { 1u, 2u, 3u, 4u, 5u }, armnn::DataType::Float32);
863  armnn::TensorInfo outputTensorInfo(
864  { 1u, 2u, 3u, 4u, 5u }, armnn::DataType::Float32);
865 
866  std::vector<float> actualOutput(outputTensorInfo.GetNumElements());
867 
868  std::unique_ptr<armnn::ITensorHandle> inputHandle = tensorHandleFactory.CreateTensorHandle(inputTensorInfo);
869  std::unique_ptr<armnn::ITensorHandle> outputHandle = tensorHandleFactory.CreateTensorHandle(outputTensorInfo);
870 
872  armnn::WorkloadInfo workloadInfo;
873  AddInputToWorkload(descriptor, workloadInfo, inputTensorInfo, inputHandle.get());
874  AddOutputToWorkload(descriptor, workloadInfo, outputTensorInfo, outputHandle.get());
875 
877 
878  std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreateActivation(descriptor, workloadInfo);
879 
880  inputHandle->Allocate();
881  outputHandle->Allocate();
882 
883  CopyDataToITensorHandle(inputHandle.get(), inputData.data());
884 
885  workload->Execute();
886 
887  CopyDataFromITensorHandle(actualOutput.data(), outputHandle.get());
888 
889  return LayerTestResult<float, 5>(actualOutput,
890  expectedOutput,
891  outputHandle->GetShape(),
892  outputTensorInfo.GetShape());
893 };
void IgnoreUnused(Ts &&...)
virtual std::unique_ptr< IWorkload > CreateActivation(const ActivationQueueDescriptor &descriptor, const WorkloadInfo &info) const
void CopyDataFromITensorHandle(void *memory, const armnn::ITensorHandle *tensorHandle)
Contains information about TensorInfos of a layer.
virtual std::unique_ptr< ITensorHandle > CreateTensorHandle(const TensorInfo &tensorInfo) const =0
ActivationFunction m_Function
The activation function to use (Sigmoid, TanH, Linear, ReLu, BoundedReLu, SoftReLu, LeakyReLu, Abs, Sqrt, Square, Elu).
Definition: Descriptors.hpp:48
void CopyDataToITensorHandle(armnn::ITensorHandle *tensorHandle, const void *memory)

◆ SqrtTest()

LayerTestResult<float, 4> SqrtTest ( armnn::IWorkloadFactory workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr memoryManager,
const armnn::ITensorHandleFactory tensorHandleFactory 
)

Definition at line 932 of file ActivationTestImpl.cpp.

Referenced by TEST_SUITE().

936 {
937  return SqrtTestCommon<armnn::DataType::Float32>(workloadFactory, memoryManager, tensorHandleFactory, 0.1f, 0);
938 }

◆ SqrtUint8Test()

LayerTestResult<uint8_t, 4> SqrtUint8Test ( armnn::IWorkloadFactory workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr memoryManager,
const armnn::ITensorHandleFactory tensorHandleFactory 
)

Definition at line 940 of file ActivationTestImpl.cpp.

Referenced by TEST_SUITE().

944 {
945  return SqrtTestCommon<armnn::DataType::QAsymmU8>(workloadFactory, memoryManager, tensorHandleFactory, 0.0625f, 64);
946 }

◆ SquareInt16Test()

LayerTestResult<int16_t, 4> SquareInt16Test ( armnn::IWorkloadFactory workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr memoryManager,
const armnn::ITensorHandleFactory tensorHandleFactory 
)

Definition at line 1010 of file ActivationTestImpl.cpp.

Referenced by TEST_SUITE().

1014 {
1015  return SquareTestCommon<armnn::DataType::QSymmS16>(workloadFactory, memoryManager, tensorHandleFactory, 0.1f, 0);
1016 }

◆ SquareTest()

LayerTestResult<float, 4> SquareTest ( armnn::IWorkloadFactory workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr memoryManager,
const armnn::ITensorHandleFactory tensorHandleFactory 
)

Definition at line 993 of file ActivationTestImpl.cpp.

Referenced by TEST_SUITE().

997 {
998  return SquareTestCommon<armnn::DataType::Float32>(workloadFactory, memoryManager, tensorHandleFactory, 0.1f, 0);
999 }

◆ SquareUint8Test()

LayerTestResult<uint8_t, 4> SquareUint8Test ( armnn::IWorkloadFactory workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr memoryManager,
const armnn::ITensorHandleFactory tensorHandleFactory 
)

Definition at line 1001 of file ActivationTestImpl.cpp.

Referenced by TEST_SUITE().

1005 {
1006  return SquareTestCommon<armnn::DataType::QAsymmU8>(workloadFactory, memoryManager,
1007  tensorHandleFactory, 0.0625f, 64);
1008 }

◆ TanhInt16Test()

LayerTestResult<int16_t, 4> TanhInt16Test ( armnn::IWorkloadFactory workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr memoryManager,
const armnn::ITensorHandleFactory tensorHandleFactory 
)

Definition at line 1073 of file ActivationTestImpl.cpp.

Referenced by TEST_SUITE().

1077 {
1078  return TanhTestCommon<armnn::DataType::QSymmS16>(workloadFactory, memoryManager, tensorHandleFactory, 0.1f, 0);
1079 }

◆ TanhTest()

LayerTestResult<float, 4> TanhTest ( armnn::IWorkloadFactory workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr memoryManager,
const armnn::ITensorHandleFactory tensorHandleFactory 
)

Definition at line 1057 of file ActivationTestImpl.cpp.

Referenced by TEST_SUITE().

1061 {
1062  return TanhTestCommon<armnn::DataType::Float32>(workloadFactory, memoryManager, tensorHandleFactory, 0.1f, 0);
1063 }

◆ TanhUint8Test()

LayerTestResult<uint8_t, 4> TanhUint8Test ( armnn::IWorkloadFactory workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr memoryManager,
const armnn::ITensorHandleFactory tensorHandleFactory 
)

Definition at line 1065 of file ActivationTestImpl.cpp.

Referenced by TEST_SUITE().

1069 {
1070  return TanhTestCommon<armnn::DataType::QAsymmU8>(workloadFactory, memoryManager, tensorHandleFactory, 0.1f, 64);
1071 }