ArmNN
 22.05.01
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 836 of file ActivationTestImpl.cpp.

Referenced by TEST_SUITE().

840 {
841  return AbsTestCommon<armnn::DataType::QSymmS16>(workloadFactory, memoryManager, tensorHandleFactory, 0.1f, 0);
842 }

◆ AbsTest()

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

Definition at line 820 of file ActivationTestImpl.cpp.

Referenced by TEST_SUITE().

824 {
825  return AbsTestCommon<armnn::DataType::Float32>(workloadFactory, memoryManager, tensorHandleFactory, 0.1f, 0);
826 }

◆ AbsUint8Test()

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

Definition at line 828 of file ActivationTestImpl.cpp.

Referenced by TEST_SUITE().

832 {
833  return AbsTestCommon<armnn::DataType::QAsymmU8>(workloadFactory, memoryManager, tensorHandleFactory, 0.0625f, 64);
834 }

◆ BoundedReLuInt16Test()

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

Definition at line 648 of file ActivationTestImpl.cpp.

Referenced by TEST_SUITE().

652 {
653  return ReLuTestCommon<armnn::DataType::QSymmS16>(workloadFactory, memoryManager, tensorHandleFactory, 0.1f, 0);
654 }

◆ 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 188 of file ActivationTestImpl.cpp.

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

Referenced by TEST_SUITE().

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

◆ BoundedReLuUint8UpperBoundOnlyTest()

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

Definition at line 156 of file ActivationTestImpl.cpp.

Referenced by TEST_SUITE().

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

◆ BoundedReLuUpperAndLowerBoundTest()

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

Definition at line 92 of file ActivationTestImpl.cpp.

Referenced by TEST_SUITE().

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

◆ BoundedReLuUpperBoundOnlyTest()

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

Definition at line 124 of file ActivationTestImpl.cpp.

Referenced by TEST_SUITE().

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

◆ 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 1341 of file ActivationTestImpl.cpp.

1348 {
1349  return CompareActivationTestImpl<armnn::DataType::QSymmS16>(
1350  workloadFactory, memoryManager, refWorkloadFactory, tensorHandleFactory,
1351  refTensorHandleFactory, f, 5, 0.1f, 0);
1352 }

◆ 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 1314 of file ActivationTestImpl.cpp.

Referenced by TEST_SUITE().

1322 {
1323  return CompareActivationTestImpl<armnn::DataType::Float32>(
1324  workloadFactory, memoryManager, refWorkloadFactory, tensorHandleFactory,
1325  refTensorHandleFactory, f, batchSize);
1326 }

◆ 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 1328 of file ActivationTestImpl.cpp.

Referenced by TEST_SUITE().

1335 {
1336  return CompareActivationTestImpl<armnn::DataType::QAsymmU8>(
1337  workloadFactory, memoryManager, refWorkloadFactory,
1338  tensorHandleFactory, refTensorHandleFactory, f, 5, 0.1f, 50);
1339 }

◆ 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 290 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().

298 {
299  LayerTestResult<float, 4> result(BoundedReLuRandomInputTestTraits::GetOutputTensorInfo());
300 
301  armnn::ActivationDescriptor activationDescriptor;
302  activationDescriptor.m_Function = armnn::ActivationFunction::BoundedReLu;
303  activationDescriptor.m_A = upperBound;
304  activationDescriptor.m_B = lowerBound;
305 
306  result.m_ActualData = BoundedReLuRandomInputTest(
307  workloadFactory, memoryManager, tensorHandleFactory, 0.0f, upperBound, activationDescriptor);
308  result.m_ExpectedData = BoundedReLuRandomInputTest(
309  refWorkloadFactory, nullptr, refTensorHandleFactory, 0.0f, upperBound, activationDescriptor);
310 
311  return result;
312 }
An ActivationDescriptor for the ActivationLayer.
Definition: Descriptors.hpp:36
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:61
float m_B
Beta lower bound value used by the activation functions. (BoundedReLu, Linear, TanH).
Definition: Descriptors.hpp:63
ActivationFunction m_Function
The activation function to use (Sigmoid, TanH, Linear, ReLu, BoundedReLu, SoftReLu, LeakyReLu, Abs, Sqrt, Square, Elu).
Definition: Descriptors.hpp:59

◆ ConstantLinearActivationInt16Test()

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

Definition at line 398 of file ActivationTestImpl.cpp.

Referenced by TEST_SUITE().

402 {
403  return ConstantLinearActivationTestCommon<armnn::DataType::QSymmS16>(
404  workloadFactory, memoryManager, tensorHandleFactory, 0.1f, 0);
405 }

◆ ConstantLinearActivationTest()

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

Definition at line 379 of file ActivationTestImpl.cpp.

Referenced by TEST_SUITE().

383 {
384  return ConstantLinearActivationTestCommon<armnn::DataType::Float32>(workloadFactory,
385  memoryManager,
386  tensorHandleFactory);
387 }

◆ ConstantLinearActivationUint8Test()

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

Definition at line 389 of file ActivationTestImpl.cpp.

Referenced by TEST_SUITE().

393 {
394  return ConstantLinearActivationTestCommon<armnn::DataType::QAsymmU8>(
395  workloadFactory, memoryManager, tensorHandleFactory, 4.0f, 3);
396 }

◆ EluInt16Test()

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

Definition at line 1142 of file ActivationTestImpl.cpp.

Referenced by TEST_SUITE().

1146 {
1147  return EluTestCommon<armnn::DataType::QSymmS16>(workloadFactory, memoryManager, tensorHandleFactory, 0.1f, 0);
1148 }

◆ EluTest()

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

Definition at line 1126 of file ActivationTestImpl.cpp.

Referenced by TEST_SUITE().

1130 {
1131  return EluTestCommon<armnn::DataType::Float32>(workloadFactory, memoryManager, tensorHandleFactory, 0.1f, 0);
1132 }

◆ EluUint8Test()

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

Definition at line 1134 of file ActivationTestImpl.cpp.

Referenced by TEST_SUITE().

1138 {
1139  return EluTestCommon<armnn::DataType::QAsymmU8>(workloadFactory, memoryManager, tensorHandleFactory, 0.1f, 64);
1140 }

◆ HardSwishInt16Test()

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

Definition at line 1211 of file ActivationTestImpl.cpp.

Referenced by TEST_SUITE().

1215 {
1216  return HardSwishTestCommon<armnn::DataType::QSymmS16>(workloadFactory, memoryManager, tensorHandleFactory, 0.1f, 0);
1217 }

◆ HardSwishTest()

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

Definition at line 1194 of file ActivationTestImpl.cpp.

Referenced by TEST_SUITE().

1198 {
1199  return HardSwishTestCommon<armnn::DataType::Float32>(workloadFactory, memoryManager, tensorHandleFactory, 0.1f, 0);
1200 }

◆ HardSwishUint8Test()

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

Definition at line 1202 of file ActivationTestImpl.cpp.

Referenced by TEST_SUITE().

1206 {
1207  return HardSwishTestCommon<armnn::DataType::QAsymmU8>(workloadFactory, memoryManager,
1208  tensorHandleFactory, 0.1f, 64);
1209 }

◆ LeakyReLuInt16Test()

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

Definition at line 775 of file ActivationTestImpl.cpp.

Referenced by TEST_SUITE().

779 {
780  return LeakyReLuTestCommon<armnn::DataType::QSymmS16>(workloadFactory, memoryManager, tensorHandleFactory, 0.1f, 0);
781 }

◆ LeakyReLuTest()

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

Definition at line 758 of file ActivationTestImpl.cpp.

Referenced by TEST_SUITE().

762 {
763  return LeakyReLuTestCommon<armnn::DataType::Float32>(workloadFactory, memoryManager, tensorHandleFactory, 0.1f, 0);
764 }

◆ LeakyReLuUint8Test()

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

Definition at line 766 of file ActivationTestImpl.cpp.

Referenced by TEST_SUITE().

770 {
771  return LeakyReLuTestCommon<armnn::DataType::QAsymmU8>(workloadFactory, memoryManager,
772  tensorHandleFactory, 0.0625f, 64);
773 }

◆ ReLuInt16Test()

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

Definition at line 584 of file ActivationTestImpl.cpp.

Referenced by TEST_SUITE().

588 {
589  return ReLuTestCommon<armnn::DataType::QSymmS16>(workloadFactory, memoryManager, tensorHandleFactory, 0.1f, 0);
590 }

◆ ReLuTest()

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

Definition at line 601 of file ActivationTestImpl.cpp.

Referenced by TEST_SUITE().

605 {
606  return ReLuTestCommon<armnn::DataType::Float32>(workloadFactory, memoryManager, tensorHandleFactory, 0.1f, 0);
607 }

◆ ReLuUint8Test()

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

Definition at line 593 of file ActivationTestImpl.cpp.

Referenced by TEST_SUITE().

597 {
598  return ReLuTestCommon<armnn::DataType::QAsymmU8>(workloadFactory, memoryManager, tensorHandleFactory, 0.1f, 0);
599 }

◆ SimpleSigmoidInt16Test()

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

Definition at line 538 of file ActivationTestImpl.cpp.

Referenced by TEST_SUITE().

542 {
543  return SimpleSigmoidTestCommon<armnn::DataType::QSymmS16>(workloadFactory, memoryManager,
544  tensorHandleFactory, 0.1f, 0);
545 }

◆ SimpleSigmoidTest()

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

Definition at line 520 of file ActivationTestImpl.cpp.

Referenced by TEST_SUITE().

524 {
525  return SimpleSigmoidTestCommon<armnn::DataType::Float32>(workloadFactory, memoryManager,
526  tensorHandleFactory, 0.0f, 0);
527 }

◆ SimpleSigmoidUint8Test()

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

Definition at line 529 of file ActivationTestImpl.cpp.

Referenced by TEST_SUITE().

533 {
534  return SimpleSigmoidTestCommon<armnn::DataType::QAsymmU8>(workloadFactory, memoryManager,
535  tensorHandleFactory, 0.1f, 50);
536 }

◆ SoftReLuInt16Test()

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

Definition at line 712 of file ActivationTestImpl.cpp.

Referenced by TEST_SUITE().

716 {
717  return SoftReLuTestCommon<armnn::DataType::QSymmS16>(workloadFactory, memoryManager, tensorHandleFactory, 0.1f, 0);
718 }

◆ SoftReLuTest()

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

Definition at line 695 of file ActivationTestImpl.cpp.

Referenced by TEST_SUITE().

699 {
700  return SoftReLuTestCommon<armnn::DataType::Float32>(workloadFactory, memoryManager, tensorHandleFactory, 0.1f, 0);
701 }

◆ SoftReLuUint8Test()

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

Definition at line 703 of file ActivationTestImpl.cpp.

Referenced by TEST_SUITE().

707 {
708  return SoftReLuTestCommon<armnn::DataType::QAsymmU8>(workloadFactory, memoryManager,
709  tensorHandleFactory, 0.0625f, 64);
710 }

◆ SqrtInt16Test()

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

Definition at line 953 of file ActivationTestImpl.cpp.

Referenced by TEST_SUITE().

957 {
958  return SqrtTestCommon<armnn::DataType::QSymmS16>(workloadFactory, memoryManager, tensorHandleFactory, 0.1f, 0);
959 }

◆ SqrtNNTest()

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

Definition at line 844 of file ActivationTestImpl.cpp.

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

Referenced by TEST_SUITE().

848 {
849  IgnoreUnused(memoryManager);
850  const int inputDataSize = 120;
851  std::vector<float> inputData(inputDataSize);
852 
853  for (unsigned int i = 0u; i < inputDataSize; ++i)
854  {
855  inputData[i] = static_cast<float>(i) / 10;
856  }
857 
858  auto f = [](float value)
859  {
860  return std::sqrt(value);
861  };
862  std::vector<float> expectedOutput(inputDataSize);
863  std::transform(inputData.begin(), inputData.end(), expectedOutput.begin(), f);
864 
865  armnn::TensorInfo inputTensorInfo(
866  { 1u, 2u, 3u, 4u, 5u }, armnn::DataType::Float32);
867  armnn::TensorInfo outputTensorInfo(
868  { 1u, 2u, 3u, 4u, 5u }, armnn::DataType::Float32);
869 
870  std::vector<float> actualOutput(outputTensorInfo.GetNumElements());
871 
872  std::unique_ptr<armnn::ITensorHandle> inputHandle = tensorHandleFactory.CreateTensorHandle(inputTensorInfo);
873  std::unique_ptr<armnn::ITensorHandle> outputHandle = tensorHandleFactory.CreateTensorHandle(outputTensorInfo);
874 
876  armnn::WorkloadInfo workloadInfo;
877  AddInputToWorkload(descriptor, workloadInfo, inputTensorInfo, inputHandle.get());
878  AddOutputToWorkload(descriptor, workloadInfo, outputTensorInfo, outputHandle.get());
879 
881 
882  std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreateWorkload(armnn::LayerType::Activation,
883  descriptor, workloadInfo);
884 
885  inputHandle->Allocate();
886  outputHandle->Allocate();
887 
888  CopyDataToITensorHandle(inputHandle.get(), inputData.data());
889 
890  workload->Execute();
891 
892  CopyDataFromITensorHandle(actualOutput.data(), outputHandle.get());
893 
894  return LayerTestResult<float, 5>(actualOutput,
895  expectedOutput,
896  outputHandle->GetShape(),
897  outputTensorInfo.GetShape());
898 };
void IgnoreUnused(Ts &&...)
void CopyDataFromITensorHandle(void *mem, const armnn::ITensorHandle *tensorHandle)
void CopyDataToITensorHandle(armnn::ITensorHandle *tensorHandle, const void *memory)
Contains information about TensorInfos of a layer.
virtual std::unique_ptr< IWorkload > CreateWorkload(LayerType type, const QueueDescriptor &descriptor, const WorkloadInfo &info) const
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:59

◆ SqrtTest()

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

Definition at line 937 of file ActivationTestImpl.cpp.

Referenced by TEST_SUITE().

941 {
942  return SqrtTestCommon<armnn::DataType::Float32>(workloadFactory, memoryManager, tensorHandleFactory, 0.1f, 0);
943 }

◆ SqrtUint8Test()

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

Definition at line 945 of file ActivationTestImpl.cpp.

Referenced by TEST_SUITE().

949 {
950  return SqrtTestCommon<armnn::DataType::QAsymmU8>(workloadFactory, memoryManager, tensorHandleFactory, 0.0625f, 64);
951 }

◆ SquareInt16Test()

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

Definition at line 1015 of file ActivationTestImpl.cpp.

Referenced by TEST_SUITE().

1019 {
1020  return SquareTestCommon<armnn::DataType::QSymmS16>(workloadFactory, memoryManager, tensorHandleFactory, 0.1f, 0);
1021 }

◆ SquareTest()

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

Definition at line 998 of file ActivationTestImpl.cpp.

Referenced by TEST_SUITE().

1002 {
1003  return SquareTestCommon<armnn::DataType::Float32>(workloadFactory, memoryManager, tensorHandleFactory, 0.1f, 0);
1004 }

◆ SquareUint8Test()

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

Definition at line 1006 of file ActivationTestImpl.cpp.

Referenced by TEST_SUITE().

1010 {
1011  return SquareTestCommon<armnn::DataType::QAsymmU8>(workloadFactory, memoryManager,
1012  tensorHandleFactory, 0.0625f, 64);
1013 }

◆ TanhInt16Test()

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

Definition at line 1078 of file ActivationTestImpl.cpp.

Referenced by TEST_SUITE().

1082 {
1083  return TanhTestCommon<armnn::DataType::QSymmS16>(workloadFactory, memoryManager, tensorHandleFactory, 0.1f, 0);
1084 }

◆ TanhTest()

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

Definition at line 1062 of file ActivationTestImpl.cpp.

Referenced by TEST_SUITE().

1066 {
1067  return TanhTestCommon<armnn::DataType::Float32>(workloadFactory, memoryManager, tensorHandleFactory, 0.1f, 0);
1068 }

◆ TanhUint8Test()

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

Definition at line 1070 of file ActivationTestImpl.cpp.

Referenced by TEST_SUITE().

1074 {
1075  return TanhTestCommon<armnn::DataType::QAsymmU8>(workloadFactory, memoryManager, tensorHandleFactory, 0.1f, 64);
1076 }