Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1 | // |
Teresa Charlin | fbf0e5b | 2020-08-17 01:01:06 +0100 | [diff] [blame] | 2 | // Copyright © 2017 Arm Ltd and Contributors. All rights reserved. |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | |
| 6 | #include "SoftmaxTestImpl.hpp" |
| 7 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 8 | #include <QuantizeHelper.hpp> |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 9 | #include <ResolveType.hpp> |
| 10 | |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 11 | |
Colm Donelan | 0c47974 | 2021-12-10 12:43:54 +0000 | [diff] [blame] | 12 | #include <armnn/backends/TensorHandle.hpp> |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 13 | |
Sadik Armagan | a097d2a | 2021-11-24 15:47:28 +0000 | [diff] [blame] | 14 | #include <armnnTestUtils/TensorCopyUtils.hpp> |
Colm Donelan | 0c47974 | 2021-12-10 12:43:54 +0000 | [diff] [blame] | 15 | #include <armnnTestUtils/WorkloadTestUtils.hpp> |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 16 | |
Sadik Armagan | a097d2a | 2021-11-24 15:47:28 +0000 | [diff] [blame] | 17 | #include <TensorHelpers.hpp> |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 18 | |
| 19 | #include <algorithm> |
| 20 | |
| 21 | namespace |
| 22 | { |
| 23 | |
| 24 | struct Simple3dSoftmaxOutputData |
| 25 | { |
| 26 | const std::vector<float> outputData = |
| 27 | { |
| 28 | 0.0964599f, 0.26220518f, 0.0964599f, 0.0964599f, |
| 29 | 0.15903549f, 0.0964599f, 0.0964599f, 0.0964599f |
| 30 | }; |
| 31 | |
| 32 | const armnn::TensorShape inputShape{ 1, 8, 1 }; |
| 33 | |
| 34 | const std::vector<float> inputData = |
| 35 | { |
| 36 | 0.0f, 1.0f, 0.0f, 0.0f, |
| 37 | 0.5f, 0.0f, 0.0f, 0.0f, |
| 38 | }; |
| 39 | }; |
| 40 | |
| 41 | struct Simple4dSoftmaxData |
| 42 | { |
| 43 | const armnn::TensorShape inputShape{ 1, 8, 1, 1 }; |
| 44 | |
| 45 | const std::vector<float> outputData = |
| 46 | { |
| 47 | 0.0964599f, 0.26220518f, 0.0964599f, 0.0964599f, |
| 48 | 0.15903549f, 0.0964599f, 0.0964599f, 0.0964599f |
| 49 | }; |
| 50 | |
| 51 | const std::vector<float> inputData = |
| 52 | { |
| 53 | 0.0f, 1.0f, 0.0f, 0.0f, |
| 54 | 0.5f, 0.0f, 0.0f, 0.0f |
| 55 | }; |
| 56 | }; |
| 57 | |
| 58 | template<armnn::DataType ArmnnType, std::size_t n, typename T = armnn::ResolveType<ArmnnType>> |
| 59 | LayerTestResult<T, n> SimpleSoftmaxBaseTestImpl( |
| 60 | armnn::IWorkloadFactory& workloadFactory, |
| 61 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Sadik Armagan | 89de3b4 | 2020-08-28 10:38:53 +0100 | [diff] [blame] | 62 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 63 | float beta, |
| 64 | const armnn::TensorShape& inputShape, |
| 65 | const std::vector<float>& outputData, |
| 66 | const std::vector<float>& inputData, |
David Monahan | 9b14bfc | 2020-06-30 15:57:56 +0100 | [diff] [blame] | 67 | int axis = -1) |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 68 | { |
| 69 | using std::exp; |
| 70 | |
| 71 | const float qScale = 1.f / 256.f; |
| 72 | const int qOffset = 0; |
| 73 | |
| 74 | armnn::TensorInfo inputTensorInfo; |
| 75 | armnn::TensorInfo outputTensorInfo; |
| 76 | |
| 77 | inputTensorInfo = armnn::TensorInfo(inputShape, ArmnnType); |
| 78 | inputTensorInfo.SetQuantizationScale(qScale); |
| 79 | inputTensorInfo.SetQuantizationOffset(qOffset); |
| 80 | |
| 81 | outputTensorInfo = armnn::TensorInfo(inputShape, ArmnnType); |
| 82 | outputTensorInfo.SetQuantizationScale(qScale); |
| 83 | outputTensorInfo.SetQuantizationOffset(qOffset); |
| 84 | |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 85 | // Each row is independently softmax'd. |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 86 | std::vector<T> input = armnnUtils::QuantizedVector<T>(inputData, qScale, qOffset); |
| 87 | std::vector<T> expectedOutput = armnnUtils::QuantizedVector<T>(outputData, qScale, qOffset); |
| 88 | std::vector<T> actualOutput(outputTensorInfo.GetNumElements()); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 89 | |
Sadik Armagan | 89de3b4 | 2020-08-28 10:38:53 +0100 | [diff] [blame] | 90 | std::unique_ptr<armnn::ITensorHandle> inputHandle = tensorHandleFactory.CreateTensorHandle(inputTensorInfo); |
| 91 | std::unique_ptr<armnn::ITensorHandle> outputHandle = tensorHandleFactory.CreateTensorHandle(outputTensorInfo); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 92 | |
| 93 | armnn::SoftmaxQueueDescriptor data; |
| 94 | data.m_Parameters.m_Beta = beta; |
| 95 | data.m_Parameters.m_Axis = axis; |
| 96 | |
| 97 | armnn::WorkloadInfo info; |
| 98 | AddInputToWorkload(data, info, inputTensorInfo, inputHandle.get()); |
| 99 | AddOutputToWorkload(data, info, outputTensorInfo, outputHandle.get()); |
| 100 | |
| 101 | std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreateSoftmax(data, info); |
| 102 | |
| 103 | inputHandle->Allocate(); |
| 104 | outputHandle->Allocate(); |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 105 | CopyDataToITensorHandle(inputHandle.get(), input.data()); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 106 | |
Narumol Prangnawarat | ac2770a | 2020-04-01 16:51:23 +0100 | [diff] [blame] | 107 | ARMNN_ASSERT(workload); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 108 | |
| 109 | ExecuteWorkload(*workload, memoryManager); |
| 110 | |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 111 | CopyDataFromITensorHandle(actualOutput.data(), outputHandle.get()); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 112 | |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 113 | return LayerTestResult<T, n>(actualOutput, |
| 114 | expectedOutput, |
| 115 | outputHandle->GetShape(), |
| 116 | outputTensorInfo.GetShape()); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 117 | } |
| 118 | |
| 119 | template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>> |
| 120 | LayerTestResult<T, 2> SimpleSoftmaxTestImpl( |
| 121 | armnn::IWorkloadFactory& workloadFactory, |
| 122 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Sadik Armagan | 89de3b4 | 2020-08-28 10:38:53 +0100 | [diff] [blame] | 123 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 124 | float beta) |
| 125 | { |
| 126 | using std::exp; |
| 127 | const armnn::TensorShape inputShape{ 2, 4 }; |
| 128 | |
| 129 | float x0[4] = { exp((0.f - 1.0f) * beta), exp((1.0f - 1.0f) * beta), |
| 130 | exp((0.0f - 1.0f) * beta), exp((0.0f - 1.0f) * beta) }; |
| 131 | float sum0 = x0[0] + x0[1] + x0[2] + x0[3]; |
| 132 | float x1[4] = { exp((0.5f - 0.5f) * beta), exp((0.0f - 0.5f) * beta), |
| 133 | exp((0.0f - 0.5f) * beta), exp((0.0f - 0.5f) * beta) }; |
| 134 | float sum1 = x1[0] + x1[1] + x1[2] + x1[3]; |
| 135 | |
| 136 | const std::vector<float> outputData = { x0[0] / sum0, x0[1] / sum0, x0[2] / sum0, x0[3] / sum0, |
| 137 | x1[0] / sum1, x1[1] / sum1, x1[2] / sum1, x1[3] / sum1 }; |
| 138 | |
| 139 | const std::vector<float> inputData = |
| 140 | { |
| 141 | 0.f, 1.f, 0.f, 0.f, |
| 142 | .5f, 0.f, 0.f, 0.f, |
| 143 | }; |
| 144 | |
Sadik Armagan | 56785c7 | 2020-08-27 12:57:20 +0100 | [diff] [blame] | 145 | return SimpleSoftmaxBaseTestImpl<ArmnnType, 2>(workloadFactory, memoryManager, tensorHandleFactory, beta, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 146 | inputShape, outputData, inputData); |
| 147 | } |
| 148 | |
| 149 | template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>> |
| 150 | LayerTestResult<T, 2> SimpleSoftmaxTestImpl( |
| 151 | armnn::IWorkloadFactory& workloadFactory, |
| 152 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Sadik Armagan | 89de3b4 | 2020-08-28 10:38:53 +0100 | [diff] [blame] | 153 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 154 | float beta, |
| 155 | int axis) |
| 156 | { |
| 157 | armnn::TensorShape inputShape; |
| 158 | std::vector<float> inputData; |
| 159 | std::vector<float> outputData; |
| 160 | switch (axis) |
| 161 | { |
| 162 | case -2: |
| 163 | case 0: |
| 164 | { |
| 165 | inputShape = {5, 2}; |
| 166 | |
| 167 | inputData = |
| 168 | { |
| 169 | 17.0f, -1.0f, 16.0f, -2.0f, 15.0f, -3.0f, 14.0f, -4.0f, 1.0f, -17.0f |
| 170 | }; |
| 171 | |
| 172 | outputData = |
| 173 | { |
| 174 | 0.643914213228014f, 0.643914213228014f, 0.236882800924671f, 0.236882800924671f, |
| 175 | 0.087144312427294f, |
| 176 | 0.087144312427294f, 0.032058600957022f, 0.032058600957022f, 7.246299848982885e-08f, |
| 177 | 7.246299848982885e-08f |
| 178 | }; |
| 179 | break; |
| 180 | } |
| 181 | case -1: |
| 182 | case 1: |
| 183 | { |
| 184 | inputShape = {2, 5}; |
| 185 | |
| 186 | inputData = |
| 187 | { |
| 188 | 17.0f, 16.0f, 15.0f, 14.0f, 1.0f, -1.0f, -2.0f, -3.0f, -4.0f, -17.0f |
| 189 | }; |
| 190 | |
| 191 | outputData = |
| 192 | { |
| 193 | 0.643914213228014f, 0.236882800924671f, 0.087144312427294f, 0.032058600957022f, |
| 194 | 7.246299848982885e-08f, |
| 195 | 0.643914213228014f, 0.236882800924671f, 0.087144312427294f, 0.032058600957022f, |
| 196 | 7.246299848982885e-08f |
| 197 | }; |
| 198 | break; |
| 199 | } |
| 200 | } |
Sadik Armagan | 56785c7 | 2020-08-27 12:57:20 +0100 | [diff] [blame] | 201 | return SimpleSoftmaxBaseTestImpl<ArmnnType, 2>(workloadFactory, memoryManager, tensorHandleFactory, beta, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 202 | inputShape, outputData, inputData, axis); |
| 203 | } |
| 204 | |
| 205 | template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>> |
| 206 | LayerTestResult<T, 3> Simple3dSoftmaxTestImpl( |
| 207 | armnn::IWorkloadFactory& workloadFactory, |
| 208 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Sadik Armagan | 89de3b4 | 2020-08-28 10:38:53 +0100 | [diff] [blame] | 209 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 210 | float beta, |
| 211 | const armnn::TensorShape& inputShape, |
| 212 | const std::vector<float>& outputData, |
| 213 | const std::vector<float>& inputData, |
| 214 | int axis = 1) |
| 215 | { |
Sadik Armagan | 56785c7 | 2020-08-27 12:57:20 +0100 | [diff] [blame] | 216 | return SimpleSoftmaxBaseTestImpl<ArmnnType, 3>(workloadFactory, memoryManager, tensorHandleFactory, beta, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 217 | inputShape, outputData, inputData, axis); |
| 218 | } |
| 219 | |
| 220 | template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>> |
| 221 | LayerTestResult<T, 4> Simple4dSoftmaxTestImpl( |
| 222 | armnn::IWorkloadFactory& workloadFactory, |
| 223 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Sadik Armagan | 89de3b4 | 2020-08-28 10:38:53 +0100 | [diff] [blame] | 224 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 225 | float beta, |
| 226 | const armnn::TensorShape& inputShape, |
| 227 | const std::vector<float>& outputData, |
| 228 | const std::vector<float>& inputData, |
| 229 | int axis = 1) |
| 230 | { |
| 231 | |
Sadik Armagan | 56785c7 | 2020-08-27 12:57:20 +0100 | [diff] [blame] | 232 | return SimpleSoftmaxBaseTestImpl<ArmnnType, 4>(workloadFactory, memoryManager, tensorHandleFactory, beta, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 233 | inputShape, outputData, inputData, axis); |
| 234 | } |
| 235 | |
| 236 | template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>> |
| 237 | LayerTestResult<T, 2> CompareSoftmaxTestImpl( |
| 238 | armnn::IWorkloadFactory& workloadFactory, |
| 239 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 240 | armnn::IWorkloadFactory& refWorkloadFactory, |
Sadik Armagan | 89de3b4 | 2020-08-28 10:38:53 +0100 | [diff] [blame] | 241 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
| 242 | const armnn::ITensorHandleFactory& refTensorHandleFactory, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 243 | float beta) |
| 244 | { |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 245 | const int batchSize = 20; |
| 246 | const int channels = 30; |
| 247 | |
| 248 | armnn::TensorInfo inputTensorInfo; |
| 249 | armnn::TensorInfo outputTensorInfo; |
| 250 | |
| 251 | unsigned int inputShape[] = { batchSize, channels }; |
| 252 | |
| 253 | inputTensorInfo = armnn::TensorInfo(2, inputShape, ArmnnType); |
| 254 | outputTensorInfo = armnn::TensorInfo(2, inputShape, ArmnnType); |
| 255 | float qScale = 1.f / 256.f; |
| 256 | int qOffset = 0; |
| 257 | inputTensorInfo.SetQuantizationScale(qScale); |
| 258 | inputTensorInfo.SetQuantizationOffset(qOffset); |
| 259 | outputTensorInfo.SetQuantizationScale(qScale); |
| 260 | outputTensorInfo.SetQuantizationOffset(qOffset); |
| 261 | |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 262 | auto input = MakeRandomTensor<T>(inputTensorInfo, 0xF00D, 0.0f, 1.0f); |
| 263 | std::vector<T> actualOutput(outputTensorInfo.GetNumElements()); |
| 264 | std::vector<T> expectedOutput(outputTensorInfo.GetNumElements()); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 265 | |
Sadik Armagan | 89de3b4 | 2020-08-28 10:38:53 +0100 | [diff] [blame] | 266 | std::unique_ptr<armnn::ITensorHandle> inputHandle = tensorHandleFactory.CreateTensorHandle(inputTensorInfo); |
| 267 | std::unique_ptr<armnn::ITensorHandle> outputHandle = tensorHandleFactory.CreateTensorHandle(outputTensorInfo); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 268 | |
| 269 | armnn::SoftmaxQueueDescriptor data; |
| 270 | data.m_Parameters.m_Beta = beta; |
| 271 | |
| 272 | armnn::WorkloadInfo info; |
| 273 | AddInputToWorkload(data, info, inputTensorInfo, inputHandle.get()); |
| 274 | AddOutputToWorkload(data, info, outputTensorInfo, outputHandle.get()); |
| 275 | |
Sadik Armagan | 56785c7 | 2020-08-27 12:57:20 +0100 | [diff] [blame] | 276 | std::unique_ptr<armnn::ITensorHandle> outputHandleRef = |
Sadik Armagan | 89de3b4 | 2020-08-28 10:38:53 +0100 | [diff] [blame] | 277 | refTensorHandleFactory.CreateTensorHandle(outputTensorInfo); |
Sadik Armagan | 56785c7 | 2020-08-27 12:57:20 +0100 | [diff] [blame] | 278 | std::unique_ptr<armnn::ITensorHandle> inputHandleRef = |
Sadik Armagan | 89de3b4 | 2020-08-28 10:38:53 +0100 | [diff] [blame] | 279 | refTensorHandleFactory.CreateTensorHandle(inputTensorInfo); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 280 | |
| 281 | armnn::SoftmaxQueueDescriptor refData = data; |
| 282 | armnn::WorkloadInfo refInfo = info; |
| 283 | SetWorkloadInput(refData, refInfo, 0, inputTensorInfo, inputHandleRef.get()); |
| 284 | SetWorkloadOutput(refData, refInfo, 0, outputTensorInfo, outputHandleRef.get()); |
| 285 | |
| 286 | std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreateSoftmax(data, info); |
| 287 | std::unique_ptr<armnn::IWorkload> workloadRef = refWorkloadFactory.CreateSoftmax(refData, refInfo); |
| 288 | |
| 289 | outputHandleRef->Allocate(); |
| 290 | inputHandleRef->Allocate(); |
| 291 | |
| 292 | inputHandle->Allocate(); |
| 293 | outputHandle->Allocate(); |
| 294 | |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 295 | CopyDataToITensorHandle(inputHandle.get(), input.data()); |
| 296 | CopyDataToITensorHandle(inputHandleRef.get(), input.data()); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 297 | |
| 298 | ExecuteWorkload(*workload, memoryManager); |
| 299 | |
| 300 | workloadRef->Execute(); |
| 301 | |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 302 | CopyDataFromITensorHandle(actualOutput.data(), outputHandle.get()); |
| 303 | CopyDataFromITensorHandle(expectedOutput.data(), outputHandleRef.get()); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 304 | |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 305 | return LayerTestResult<T, 2>(actualOutput, |
| 306 | expectedOutput, |
| 307 | outputHandle->GetShape(), |
| 308 | outputTensorInfo.GetShape()); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 309 | } |
| 310 | |
| 311 | } // anonymous namespace |
| 312 | |
| 313 | LayerTestResult<float,2> SimpleSoftmaxTest( |
| 314 | armnn::IWorkloadFactory& workloadFactory, |
| 315 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Sadik Armagan | 89de3b4 | 2020-08-28 10:38:53 +0100 | [diff] [blame] | 316 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 317 | float beta) |
| 318 | { |
Sadik Armagan | 56785c7 | 2020-08-27 12:57:20 +0100 | [diff] [blame] | 319 | return SimpleSoftmaxTestImpl<armnn::DataType::Float32>(workloadFactory, memoryManager, tensorHandleFactory, beta); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 320 | } |
| 321 | |
| 322 | LayerTestResult<float,2> SimpleAxisSoftmaxTest( |
| 323 | armnn::IWorkloadFactory& workloadFactory, |
| 324 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Sadik Armagan | 89de3b4 | 2020-08-28 10:38:53 +0100 | [diff] [blame] | 325 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 326 | float beta, |
| 327 | int axis) |
| 328 | { |
Sadik Armagan | 56785c7 | 2020-08-27 12:57:20 +0100 | [diff] [blame] | 329 | return SimpleSoftmaxTestImpl<armnn::DataType::Float32>(workloadFactory, memoryManager, |
| 330 | tensorHandleFactory, beta, axis); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 331 | } |
| 332 | |
| 333 | LayerTestResult<float,3> Simple3dSoftmaxTest( |
| 334 | armnn::IWorkloadFactory& workloadFactory, |
| 335 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Sadik Armagan | 89de3b4 | 2020-08-28 10:38:53 +0100 | [diff] [blame] | 336 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 337 | float beta) |
| 338 | { |
| 339 | Simple3dSoftmaxOutputData data; |
Sadik Armagan | 56785c7 | 2020-08-27 12:57:20 +0100 | [diff] [blame] | 340 | return Simple3dSoftmaxTestImpl<armnn::DataType::Float32>(workloadFactory, memoryManager, tensorHandleFactory, beta, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 341 | data.inputShape, data.outputData, data.inputData); |
| 342 | } |
| 343 | |
| 344 | LayerTestResult<float,3> Simple3dAxisSoftmaxTest( |
| 345 | armnn::IWorkloadFactory& workloadFactory, |
| 346 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Sadik Armagan | 89de3b4 | 2020-08-28 10:38:53 +0100 | [diff] [blame] | 347 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 348 | float beta, |
| 349 | int axis) |
| 350 | { |
| 351 | armnn::TensorShape inputShape; |
| 352 | std::vector<float> inputData; |
| 353 | std::vector<float> outputData; |
| 354 | switch (axis) |
| 355 | { |
| 356 | case -3: |
| 357 | case 0: |
| 358 | { |
| 359 | inputShape = {5, 2, 2}; |
| 360 | |
| 361 | inputData = |
| 362 | { |
| 363 | 17.0f, -1.0f, 17.0f, -1.0f, 16.0f, -2.0f, 16.0f, -2.0f, 15.0f, -3.0f, |
| 364 | |
| 365 | 15.0f, -3.0f, 14.0f, -4.0f, 14.0f, -4.0f, 1.0f, -17.0f, 1.0f, -17.0f |
| 366 | }; |
| 367 | |
| 368 | outputData = |
| 369 | { |
| 370 | 0.643914213228014f, 0.643914213228014f, 0.643914213228014f, 0.643914213228014f, |
| 371 | 0.236882800924671f, |
| 372 | 0.236882800924671f, 0.236882800924671f, 0.236882800924671f, 0.087144312427294f, |
| 373 | 0.087144312427294f, |
| 374 | |
| 375 | 0.087144312427294f, 0.087144312427294f, 0.032058600957022f, 0.032058600957022f, |
| 376 | 0.032058600957022f, |
| 377 | 0.032058600957022f, 7.246299848982885e-08f, 7.246299848982885e-08f, 7.246299848982885e-08f, |
| 378 | 7.246299848982885e-08f |
| 379 | }; |
| 380 | break; |
| 381 | } |
| 382 | case -2: |
| 383 | case 1: |
| 384 | { |
| 385 | inputShape = {2, 5, 2}; |
| 386 | |
| 387 | inputData = |
| 388 | { |
| 389 | 17.0f, -1.0f, 16.0f, -2.0f, 15.0f, -3.0f, 14.0f, -4.0f, 1.0f, -17.0f, |
| 390 | |
| 391 | 17.0f, -1.0f, 16.0f, -2.0f, 15.0f, -3.0f, 14.0f, -4.0f, 1.0f, -17.0f |
| 392 | }; |
| 393 | |
| 394 | outputData = |
| 395 | { |
| 396 | 0.643914213228014f, 0.643914213228014f, 0.236882800924671f, 0.236882800924671f, |
| 397 | 0.087144312427294f, |
| 398 | 0.087144312427294f, 0.032058600957022f, 0.032058600957022f, 7.246299848982885e-08f, |
| 399 | 7.246299848982885e-08f, |
| 400 | |
| 401 | 0.643914213228014f, 0.643914213228014f, 0.236882800924671f, 0.236882800924671f, |
| 402 | 0.087144312427294f, |
| 403 | 0.087144312427294f, 0.032058600957022f, 0.032058600957022f, 7.246299848982885e-08f, |
| 404 | 7.246299848982885e-08f |
| 405 | }; |
| 406 | break; |
| 407 | } |
| 408 | case -1: |
| 409 | case 2: |
| 410 | { |
| 411 | inputShape = {2, 2, 5}; |
| 412 | |
| 413 | inputData = |
| 414 | { |
| 415 | 17.0f, 16.0f, 15.0f, 14.0f, 1.0f, -1.0f, -2.0f, -3.0f, -4.0f, -17.0f, |
| 416 | 17.0f, 16.0f, 15.0f, 14.0f, 1.0f, -1.0f, -2.0f, -3.0f, -4.0f, -17.0f |
| 417 | }; |
| 418 | |
| 419 | outputData = |
| 420 | { |
| 421 | 0.643914213228014f, 0.236882800924671f, 0.087144312427294f, 0.032058600957022f, |
| 422 | 7.246299848982885e-08f, |
| 423 | 0.643914213228014f, 0.236882800924671f, 0.087144312427294f, 0.032058600957022f, |
| 424 | 7.246299848982885e-08f, |
| 425 | |
| 426 | 0.643914213228014f, 0.236882800924671f, 0.087144312427294f, 0.032058600957022f, |
| 427 | 7.246299848982885e-08f, |
| 428 | 0.643914213228014f, 0.236882800924671f, 0.087144312427294f, 0.032058600957022f, |
| 429 | 7.246299848982885e-08f |
| 430 | }; |
| 431 | break; |
| 432 | } |
| 433 | } |
| 434 | |
Sadik Armagan | 56785c7 | 2020-08-27 12:57:20 +0100 | [diff] [blame] | 435 | return Simple3dSoftmaxTestImpl<armnn::DataType::Float32>(workloadFactory, memoryManager, tensorHandleFactory, beta, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 436 | inputShape, outputData, inputData, axis); |
| 437 | } |
| 438 | |
| 439 | LayerTestResult<float,4> Simple4dSoftmaxTest( |
| 440 | armnn::IWorkloadFactory& workloadFactory, |
| 441 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Sadik Armagan | 89de3b4 | 2020-08-28 10:38:53 +0100 | [diff] [blame] | 442 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 443 | float beta) |
| 444 | { |
| 445 | Simple4dSoftmaxData data; |
Sadik Armagan | 56785c7 | 2020-08-27 12:57:20 +0100 | [diff] [blame] | 446 | return Simple4dSoftmaxTestImpl<armnn::DataType::Float32>(workloadFactory, memoryManager, tensorHandleFactory, |
| 447 | beta, data.inputShape, data.outputData, data.inputData); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 448 | } |
| 449 | |
| 450 | LayerTestResult<float,4> Simple4dAxisSoftmaxTest( |
| 451 | armnn::IWorkloadFactory& workloadFactory, |
| 452 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Sadik Armagan | 89de3b4 | 2020-08-28 10:38:53 +0100 | [diff] [blame] | 453 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 454 | float beta, |
| 455 | int axis) |
| 456 | { |
| 457 | armnn::TensorShape inputShape; |
| 458 | std::vector<float> inputData; |
| 459 | std::vector<float> outputData; |
| 460 | switch (axis) |
| 461 | { |
| 462 | case -4: |
| 463 | case 0: |
| 464 | { |
| 465 | inputShape = {5, 2, 2, 2}; |
| 466 | |
| 467 | inputData = |
| 468 | { |
| 469 | 17.0f, -1.0f, 17.0f, -1.0f, 17.0f, -1.0f, 17.0f, -1.0f, 16.0f, -2.0f, |
| 470 | 16.0f, -2.0f, 16.0f, -2.0f, 16.0f, -2.0f, 15.0f, -3.0f, 15.0f, -3.0f, |
| 471 | 15.0f, -3.0f, 15.0f, -3.0f, 14.0f, -4.0f, 14.0f, -4.0f, 14.0f, -4.0f, |
| 472 | 14.0f, -4.0f, 1.0f, -17.0f, 1.0f, -17.0f, 1.0f, -17.0f, 1.0f, -17.0f |
| 473 | }; |
| 474 | |
| 475 | outputData = |
| 476 | { |
| 477 | 0.643914213228014f, 0.643914213228014f, 0.643914213228014f, 0.643914213228014f, |
| 478 | 0.643914213228014f, |
| 479 | 0.643914213228014f, 0.643914213228014f, 0.643914213228014f, 0.236882800924671f, |
| 480 | 0.236882800924671f, |
| 481 | 0.236882800924671f, 0.236882800924671f, 0.236882800924671f, 0.236882800924671f, |
| 482 | 0.236882800924671f, |
| 483 | 0.236882800924671f, 0.087144312427294f, 0.087144312427294f, 0.087144312427294f, |
| 484 | 0.087144312427294f, |
| 485 | |
| 486 | 0.087144312427294f, 0.087144312427294f, 0.087144312427294f, 0.087144312427294f, |
| 487 | 0.032058600957022f, |
| 488 | 0.032058600957022f, 0.032058600957022f, 0.032058600957022f, 0.032058600957022f, |
| 489 | 0.032058600957022f, |
| 490 | 0.032058600957022f, 0.032058600957022f, 7.246299848982885e-08f, 7.246299848982885e-08f, |
| 491 | 7.246299848982885e-08f, |
| 492 | 7.246299848982885e-08f, 7.246299848982885e-08f, 7.246299848982885e-08f, |
| 493 | 7.246299848982885e-08f, 7.246299848982885e-08f |
| 494 | }; |
| 495 | break; |
| 496 | } |
| 497 | case -3: |
| 498 | case 1: |
| 499 | { |
| 500 | inputShape = {2, 5, 2, 2}; |
| 501 | |
| 502 | inputData = |
| 503 | { |
| 504 | 17.0f, -1.0f, 17.0f, -1.0f, 16.0f, -2.0f, 16.0f, -2.0f, 15.0f, -3.0f, |
| 505 | 15.0f, -3.0f, 14.0f, -4.0f, 14.0f, -4.0f, 1.0f, -17.0f, 1.0f, -17.0f, |
| 506 | 17.0f, -1.0f, 17.0f, -1.0f, 16.0f, -2.0f, 16.0f, -2.0f, 15.0f, -3.0f, |
| 507 | 15.0f, -3.0f, 14.0f, -4.0f, 14.0f, -4.0f, 1.0f, -17.0f, 1.0f, -17.0f |
| 508 | }; |
| 509 | |
| 510 | outputData = |
| 511 | { |
| 512 | 0.643914213228014f, 0.643914213228014f, 0.643914213228014f, 0.643914213228014f, |
| 513 | 0.236882800924671f, |
| 514 | 0.236882800924671f, 0.236882800924671f, 0.236882800924671f, 0.087144312427294f, |
| 515 | 0.087144312427294f, |
| 516 | 0.087144312427294f, 0.087144312427294f, 0.032058600957022f, 0.032058600957022f, |
| 517 | 0.032058600957022f, |
| 518 | 0.032058600957022f, 7.246299848982885e-08f, 7.246299848982885e-08f, 7.246299848982885e-08f, |
| 519 | 7.246299848982885e-08f, |
| 520 | |
| 521 | |
| 522 | 0.643914213228014f, 0.643914213228014f, 0.643914213228014f, 0.643914213228014f, |
| 523 | 0.236882800924671f, |
| 524 | 0.236882800924671f, 0.236882800924671f, 0.236882800924671f, 0.087144312427294f, |
| 525 | 0.087144312427294f, |
| 526 | 0.087144312427294f, 0.087144312427294f, 0.032058600957022f, 0.032058600957022f, |
| 527 | 0.032058600957022f, |
| 528 | 0.032058600957022f, 7.246299848982885e-08f, 7.246299848982885e-08f, 7.246299848982885e-08f, |
| 529 | 7.246299848982885e-08f |
| 530 | }; |
| 531 | break; |
| 532 | } |
| 533 | case -2: |
| 534 | case 2: |
| 535 | { |
| 536 | inputShape = {2, 2, 5, 2}; |
| 537 | |
| 538 | inputData = |
| 539 | { |
| 540 | 17.0f, -1.0f, 16.0f, -2.0f, 15.0f, -3.0f, 14.0f, -4.0f, 1.0f, -17.0f, |
| 541 | 17.0f, -1.0f, 16.0f, -2.0f, 15.0f, -3.0f, 14.0f, -4.0f, 1.0f, -17.0f, |
| 542 | 17.0f, -1.0f, 16.0f, -2.0f, 15.0f, -3.0f, 14.0f, -4.0f, 1.0f, -17.0f, |
| 543 | 17.0f, -1.0f, 16.0f, -2.0f, 15.0f, -3.0f, 14.0f, -4.0f, 1.0f, -17.0f |
| 544 | }; |
| 545 | |
| 546 | outputData = |
| 547 | { |
| 548 | 0.643914213228014f, 0.643914213228014f, 0.236882800924671f, 0.236882800924671f, |
| 549 | 0.087144312427294f, |
| 550 | 0.087144312427294f, 0.032058600957022f, 0.032058600957022f, 7.246299848982885e-08f, |
| 551 | 7.246299848982885e-08f, |
| 552 | 0.643914213228014f, 0.643914213228014f, 0.236882800924671f, 0.236882800924671f, |
| 553 | 0.087144312427294f, |
| 554 | 0.087144312427294f, 0.032058600957022f, 0.032058600957022f, 7.246299848982885e-08f, |
| 555 | 7.246299848982885e-08f, |
| 556 | |
| 557 | 0.643914213228014f, 0.643914213228014f, 0.236882800924671f, 0.236882800924671f, |
| 558 | 0.087144312427294f, |
| 559 | 0.087144312427294f, 0.032058600957022f, 0.032058600957022f, 7.246299848982885e-08f, |
| 560 | 7.246299848982885e-08f, |
| 561 | 0.643914213228014f, 0.643914213228014f, 0.236882800924671f, 0.236882800924671f, |
| 562 | 0.087144312427294f, |
| 563 | 0.087144312427294f, 0.032058600957022f, 0.032058600957022f, 7.246299848982885e-08f, |
| 564 | 7.246299848982885e-08f |
| 565 | }; |
| 566 | break; |
| 567 | } |
| 568 | case -1: |
| 569 | case 3: |
| 570 | { |
| 571 | inputShape = {2, 2, 2, 5}; |
| 572 | |
| 573 | inputData = |
| 574 | { |
| 575 | 17.0f, 16.0f, 15.0f, 14.0f, 1.0f, -1.0f, -2.0f, -3.0f, -4.0f, -17.0f, |
| 576 | 17.0f, 16.0f, 15.0f, 14.0f, 1.0f, -1.0f, -2.0f, -3.0f, -4.0f, -17.0f, |
| 577 | 17.0f, 16.0f, 15.0f, 14.0f, 1.0f, -1.0f, -2.0f, -3.0f, -4.0f, -17.0f, |
| 578 | 17.0f, 16.0f, 15.0f, 14.0f, 1.0f, -1.0f, -2.0f, -3.0f, -4.0f, -17.0f |
| 579 | }; |
| 580 | |
| 581 | outputData = |
| 582 | { |
| 583 | 0.643914213228014f, 0.236882800924671f, 0.087144312427294f, 0.032058600957022f, |
| 584 | 7.246299848982885e-08f, |
| 585 | 0.643914213228014f, 0.236882800924671f, 0.087144312427294f, 0.032058600957022f, |
| 586 | 7.246299848982885e-08f, |
| 587 | 0.643914213228014f, 0.236882800924671f, 0.087144312427294f, 0.032058600957022f, |
| 588 | 7.246299848982885e-08f, |
| 589 | 0.643914213228014f, 0.236882800924671f, 0.087144312427294f, 0.032058600957022f, |
| 590 | 7.246299848982885e-08f, |
| 591 | |
| 592 | 0.643914213228014f, 0.236882800924671f, 0.087144312427294f, 0.032058600957022f, |
| 593 | 7.246299848982885e-08f, |
| 594 | 0.643914213228014f, 0.236882800924671f, 0.087144312427294f, 0.032058600957022f, |
| 595 | 7.246299848982885e-08f, |
| 596 | 0.643914213228014f, 0.236882800924671f, 0.087144312427294f, 0.032058600957022f, |
| 597 | 7.246299848982885e-08f, |
| 598 | 0.643914213228014f, 0.236882800924671f, 0.087144312427294f, 0.032058600957022f, |
| 599 | 7.246299848982885e-08f |
| 600 | }; |
| 601 | break; |
| 602 | } |
| 603 | } |
| 604 | |
| 605 | return Simple4dSoftmaxTestImpl<armnn::DataType::Float32>( |
| 606 | workloadFactory, |
| 607 | memoryManager, |
Sadik Armagan | 56785c7 | 2020-08-27 12:57:20 +0100 | [diff] [blame] | 608 | tensorHandleFactory, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 609 | beta, |
| 610 | inputShape, |
| 611 | outputData, |
| 612 | inputData, |
| 613 | axis); |
| 614 | } |
| 615 | |
| 616 | LayerTestResult<uint8_t,2> SimpleSoftmaxUint8Test( |
| 617 | armnn::IWorkloadFactory& workloadFactory, |
| 618 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Sadik Armagan | 89de3b4 | 2020-08-28 10:38:53 +0100 | [diff] [blame] | 619 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 620 | float beta) |
| 621 | { |
Sadik Armagan | 56785c7 | 2020-08-27 12:57:20 +0100 | [diff] [blame] | 622 | return SimpleSoftmaxTestImpl<armnn::DataType::QAsymmU8>(workloadFactory, memoryManager, tensorHandleFactory, beta); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 623 | } |
| 624 | |
| 625 | LayerTestResult<uint8_t,3> Simple3dSoftmaxUint8Test( |
| 626 | armnn::IWorkloadFactory& workloadFactory, |
| 627 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Sadik Armagan | 89de3b4 | 2020-08-28 10:38:53 +0100 | [diff] [blame] | 628 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 629 | float beta) |
| 630 | { |
| 631 | Simple3dSoftmaxOutputData data; |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 632 | return Simple3dSoftmaxTestImpl<armnn::DataType::QAsymmU8>( |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 633 | workloadFactory, |
| 634 | memoryManager, |
Sadik Armagan | 56785c7 | 2020-08-27 12:57:20 +0100 | [diff] [blame] | 635 | tensorHandleFactory, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 636 | beta, |
| 637 | data.inputShape, |
| 638 | data.outputData, |
| 639 | data.inputData); |
| 640 | } |
| 641 | |
| 642 | LayerTestResult<uint8_t,4> Simple4dSoftmaxUint8Test( |
| 643 | armnn::IWorkloadFactory& workloadFactory, |
| 644 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Sadik Armagan | 89de3b4 | 2020-08-28 10:38:53 +0100 | [diff] [blame] | 645 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 646 | float beta) |
| 647 | { |
| 648 | Simple4dSoftmaxData data; |
| 649 | |
Sadik Armagan | 56785c7 | 2020-08-27 12:57:20 +0100 | [diff] [blame] | 650 | return Simple4dSoftmaxTestImpl<armnn::DataType::QAsymmU8>(workloadFactory, memoryManager, tensorHandleFactory, beta, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 651 | data.inputShape, data.outputData, data.inputData); |
| 652 | } |
| 653 | |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 654 | LayerTestResult<armnn::Half,2> SimpleSoftmaxFloat16Test( |
| 655 | armnn::IWorkloadFactory& workloadFactory, |
| 656 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Sadik Armagan | 89de3b4 | 2020-08-28 10:38:53 +0100 | [diff] [blame] | 657 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 658 | float beta) |
| 659 | { |
Sadik Armagan | 56785c7 | 2020-08-27 12:57:20 +0100 | [diff] [blame] | 660 | return SimpleSoftmaxTestImpl<armnn::DataType::Float16>(workloadFactory, memoryManager, tensorHandleFactory, beta); |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 661 | } |
| 662 | |
| 663 | LayerTestResult<armnn::Half,3> Simple3dSoftmaxFloat16Test( |
| 664 | armnn::IWorkloadFactory& workloadFactory, |
| 665 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Sadik Armagan | 89de3b4 | 2020-08-28 10:38:53 +0100 | [diff] [blame] | 666 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 667 | float beta) |
| 668 | { |
| 669 | Simple3dSoftmaxOutputData data; |
Sadik Armagan | 56785c7 | 2020-08-27 12:57:20 +0100 | [diff] [blame] | 670 | return Simple3dSoftmaxTestImpl<armnn::DataType::Float16>(workloadFactory, memoryManager, tensorHandleFactory, beta, |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 671 | data.inputShape, data.outputData, data.inputData); |
| 672 | } |
| 673 | |
| 674 | LayerTestResult<armnn::Half,4> Simple4dSoftmaxFloat16Test( |
| 675 | armnn::IWorkloadFactory& workloadFactory, |
| 676 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Sadik Armagan | 89de3b4 | 2020-08-28 10:38:53 +0100 | [diff] [blame] | 677 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 678 | float beta) |
| 679 | { |
| 680 | Simple4dSoftmaxData data; |
Sadik Armagan | 56785c7 | 2020-08-27 12:57:20 +0100 | [diff] [blame] | 681 | return Simple4dSoftmaxTestImpl<armnn::DataType::Float16>(workloadFactory, memoryManager, tensorHandleFactory, beta, |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 682 | data.inputShape, data.outputData, data.inputData); |
| 683 | } |
| 684 | |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 685 | LayerTestResult<int16_t,2> SimpleSoftmaxUint16Test( |
| 686 | armnn::IWorkloadFactory& workloadFactory, |
| 687 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Sadik Armagan | 89de3b4 | 2020-08-28 10:38:53 +0100 | [diff] [blame] | 688 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 689 | float beta) |
| 690 | { |
Sadik Armagan | 56785c7 | 2020-08-27 12:57:20 +0100 | [diff] [blame] | 691 | return SimpleSoftmaxTestImpl<armnn::DataType::QSymmS16>(workloadFactory, memoryManager, tensorHandleFactory, beta); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 692 | } |
| 693 | |
| 694 | LayerTestResult<int16_t,3> Simple3dSoftmaxUint16Test( |
| 695 | armnn::IWorkloadFactory& workloadFactory, |
| 696 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Sadik Armagan | 89de3b4 | 2020-08-28 10:38:53 +0100 | [diff] [blame] | 697 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 698 | float beta) |
| 699 | { |
| 700 | Simple3dSoftmaxOutputData data; |
Sadik Armagan | 56785c7 | 2020-08-27 12:57:20 +0100 | [diff] [blame] | 701 | return Simple3dSoftmaxTestImpl<armnn::DataType::QSymmS16>(workloadFactory, memoryManager, tensorHandleFactory, beta, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 702 | data.inputShape, data.outputData, data.inputData); |
| 703 | } |
| 704 | |
| 705 | LayerTestResult<int16_t,4> Simple4dSoftmaxUint16Test( |
| 706 | armnn::IWorkloadFactory& workloadFactory, |
| 707 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Sadik Armagan | 89de3b4 | 2020-08-28 10:38:53 +0100 | [diff] [blame] | 708 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 709 | float beta) |
| 710 | { |
| 711 | Simple4dSoftmaxData data; |
| 712 | |
Sadik Armagan | 56785c7 | 2020-08-27 12:57:20 +0100 | [diff] [blame] | 713 | return Simple4dSoftmaxTestImpl<armnn::DataType::QSymmS16>(workloadFactory, memoryManager, tensorHandleFactory, beta, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 714 | data.inputShape, data.outputData, data.inputData); |
| 715 | } |
| 716 | |
| 717 | LayerTestResult<float,2> CompareSoftmaxTest( |
| 718 | armnn::IWorkloadFactory& workloadFactory, |
| 719 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 720 | armnn::IWorkloadFactory& refWorkloadFactory, |
Sadik Armagan | 89de3b4 | 2020-08-28 10:38:53 +0100 | [diff] [blame] | 721 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
| 722 | const armnn::ITensorHandleFactory& refTensorHandleFactory, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 723 | float beta) |
| 724 | { |
| 725 | return CompareSoftmaxTestImpl<armnn::DataType::Float32>( |
Sadik Armagan | 56785c7 | 2020-08-27 12:57:20 +0100 | [diff] [blame] | 726 | workloadFactory, memoryManager, refWorkloadFactory, tensorHandleFactory, refTensorHandleFactory, beta); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 727 | } |
| 728 | |
| 729 | LayerTestResult<uint8_t,2> CompareSoftmaxUint8Test( |
| 730 | armnn::IWorkloadFactory& workloadFactory, |
| 731 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 732 | armnn::IWorkloadFactory& refWorkloadFactory, |
Sadik Armagan | 89de3b4 | 2020-08-28 10:38:53 +0100 | [diff] [blame] | 733 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
| 734 | const armnn::ITensorHandleFactory& refTensorHandleFactory, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 735 | float beta) |
| 736 | { |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 737 | return CompareSoftmaxTestImpl<armnn::DataType::QAsymmU8>( |
Sadik Armagan | 56785c7 | 2020-08-27 12:57:20 +0100 | [diff] [blame] | 738 | workloadFactory, memoryManager, refWorkloadFactory, tensorHandleFactory, refTensorHandleFactory, beta); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 739 | } |