telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1 | // |
| 2 | // Copyright © 2017 Arm Ltd. All rights reserved. |
David Beck | ecb56cd | 2018-09-05 12:52:57 +0100 | [diff] [blame] | 3 | // SPDX-License-Identifier: MIT |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 4 | // |
arovir01 | 43095f3 | 2018-10-09 18:04:24 +0100 | [diff] [blame] | 5 | |
Aron Virginas-Tar | c9cc804 | 2018-11-01 16:15:57 +0000 | [diff] [blame] | 6 | #include <test/CreateWorkload.hpp> |
arovir01 | 43095f3 | 2018-10-09 18:04:24 +0100 | [diff] [blame] | 7 | |
Jan Eilers | bb446e5 | 2020-04-02 13:56:54 +0100 | [diff] [blame] | 8 | #include <armnn/utility/PolymorphicDowncast.hpp> |
Matthew Bentham | 4cefc41 | 2019-06-18 16:14:34 +0100 | [diff] [blame] | 9 | #include <reference/RefTensorHandle.hpp> |
Aron Virginas-Tar | c9cc804 | 2018-11-01 16:15:57 +0000 | [diff] [blame] | 10 | #include <reference/RefWorkloadFactory.hpp> |
| 11 | #include <reference/workloads/RefWorkloads.hpp> |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 12 | |
| 13 | namespace |
| 14 | { |
| 15 | |
| 16 | template<typename Workload> |
| 17 | void CheckInputOutput(std::unique_ptr<Workload> workload, const TensorInfo& inputInfo, const TensorInfo& outputInfo) |
| 18 | { |
| 19 | auto queueDescriptor = workload->GetData(); |
Jan Eilers | bb446e5 | 2020-04-02 13:56:54 +0100 | [diff] [blame] | 20 | auto inputHandle = PolymorphicDowncast<RefTensorHandle*>(queueDescriptor.m_Inputs[0]); |
| 21 | auto outputHandle = PolymorphicDowncast<RefTensorHandle*>(queueDescriptor.m_Outputs[0]); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 22 | BOOST_TEST((inputHandle->GetTensorInfo() == inputInfo)); |
| 23 | BOOST_TEST((outputHandle->GetTensorInfo() == outputInfo)); |
| 24 | } |
| 25 | |
| 26 | template <typename Workload> |
| 27 | void CheckInputsOutput(std::unique_ptr<Workload> workload, |
| 28 | const TensorInfo& inputInfo0, |
| 29 | const TensorInfo& inputInfo1, |
| 30 | const TensorInfo& outputInfo) |
| 31 | { |
| 32 | auto queueDescriptor = workload->GetData(); |
Jan Eilers | bb446e5 | 2020-04-02 13:56:54 +0100 | [diff] [blame] | 33 | auto inputHandle0 = PolymorphicDowncast<RefTensorHandle*>(queueDescriptor.m_Inputs[0]); |
| 34 | auto inputHandle1 = PolymorphicDowncast<RefTensorHandle*>(queueDescriptor.m_Inputs[1]); |
| 35 | auto outputHandle = PolymorphicDowncast<RefTensorHandle*>(queueDescriptor.m_Outputs[0]); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 36 | BOOST_TEST((inputHandle0->GetTensorInfo() == inputInfo0)); |
| 37 | BOOST_TEST((inputHandle1->GetTensorInfo() == inputInfo1)); |
| 38 | BOOST_TEST((outputHandle->GetTensorInfo() == outputInfo)); |
| 39 | } |
Matthew Bentham | 7c1603a | 2019-06-21 17:22:23 +0100 | [diff] [blame] | 40 | |
| 41 | armnn::RefWorkloadFactory GetFactory() |
| 42 | { |
| 43 | std::shared_ptr<RefMemoryManager> memoryManager = std::make_shared<RefMemoryManager>(); |
| 44 | return RefWorkloadFactory(memoryManager); |
| 45 | } |
| 46 | |
| 47 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 48 | } |
| 49 | |
| 50 | BOOST_AUTO_TEST_SUITE(CreateWorkloadRef) |
| 51 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 52 | template <typename ActivationWorkloadType, armnn::DataType DataType> |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 53 | static void RefCreateActivationWorkloadTest() |
| 54 | { |
| 55 | Graph graph; |
Matthew Bentham | 7c1603a | 2019-06-21 17:22:23 +0100 | [diff] [blame] | 56 | RefWorkloadFactory factory = GetFactory(); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 57 | auto workload = CreateActivationWorkloadTest<ActivationWorkloadType, DataType>(factory, graph); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 58 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 59 | // Checks that outputs are as we expect them (see definition of CreateActivationWorkloadTest). |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 60 | CheckInputOutput(std::move(workload), |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 61 | TensorInfo({ 1, 1 }, DataType), |
| 62 | TensorInfo({ 1, 1 }, DataType)); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 63 | } |
| 64 | |
| 65 | BOOST_AUTO_TEST_CASE(CreateActivationFloat32Workload) |
| 66 | { |
Nattapat Chaimanowong | ae2c5f0 | 2019-04-24 16:19:57 +0100 | [diff] [blame] | 67 | RefCreateActivationWorkloadTest<RefActivationWorkload, armnn::DataType::Float32>(); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 68 | } |
| 69 | |
| 70 | BOOST_AUTO_TEST_CASE(CreateActivationUint8Workload) |
| 71 | { |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 72 | RefCreateActivationWorkloadTest<RefActivationWorkload, armnn::DataType::QAsymmU8>(); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 73 | } |
| 74 | |
David Beck | bc39245 | 2018-09-10 14:47:28 +0100 | [diff] [blame] | 75 | template <typename WorkloadType, |
| 76 | typename DescriptorType, |
| 77 | typename LayerType, |
| 78 | armnn::DataType DataType> |
Éanna Ó Catháin | d57415d | 2018-11-28 16:24:38 +0000 | [diff] [blame] | 79 | static void RefCreateElementwiseWorkloadTest() |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 80 | { |
| 81 | Graph graph; |
Matthew Bentham | 7c1603a | 2019-06-21 17:22:23 +0100 | [diff] [blame] | 82 | RefWorkloadFactory factory = GetFactory(); |
Éanna Ó Catháin | d57415d | 2018-11-28 16:24:38 +0000 | [diff] [blame] | 83 | auto workload = CreateElementwiseWorkloadTest<WorkloadType, DescriptorType, LayerType, DataType>( |
| 84 | factory, graph); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 85 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 86 | CheckInputsOutput(std::move(workload), |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 87 | TensorInfo({ 2, 3 }, DataType), |
| 88 | TensorInfo({ 2, 3 }, DataType), |
| 89 | TensorInfo({ 2, 3 }, DataType)); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 90 | } |
| 91 | |
| 92 | BOOST_AUTO_TEST_CASE(CreateAdditionFloatWorkload) |
| 93 | { |
Sadik Armagan | 2e6dc3a | 2019-04-03 17:48:18 +0100 | [diff] [blame] | 94 | RefCreateElementwiseWorkloadTest<RefAdditionWorkload, |
Éanna Ó Catháin | d57415d | 2018-11-28 16:24:38 +0000 | [diff] [blame] | 95 | AdditionQueueDescriptor, |
| 96 | AdditionLayer, |
| 97 | armnn::DataType::Float32>(); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 98 | } |
| 99 | |
| 100 | BOOST_AUTO_TEST_CASE(CreateAdditionUint8Workload) |
| 101 | { |
Sadik Armagan | 2e6dc3a | 2019-04-03 17:48:18 +0100 | [diff] [blame] | 102 | RefCreateElementwiseWorkloadTest<RefAdditionWorkload, |
Éanna Ó Catháin | d57415d | 2018-11-28 16:24:38 +0000 | [diff] [blame] | 103 | AdditionQueueDescriptor, |
| 104 | AdditionLayer, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 105 | armnn::DataType::QAsymmU8>(); |
David Beck | bc39245 | 2018-09-10 14:47:28 +0100 | [diff] [blame] | 106 | } |
| 107 | |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 108 | BOOST_AUTO_TEST_CASE(CreateAdditionInt16Workload) |
| 109 | { |
| 110 | RefCreateElementwiseWorkloadTest<RefAdditionWorkload, |
| 111 | AdditionQueueDescriptor, |
| 112 | AdditionLayer, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 113 | armnn::DataType::QSymmS16>(); |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 114 | } |
| 115 | |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 116 | BOOST_AUTO_TEST_CASE(CreateSubtractionFloat32Workload) |
David Beck | bc39245 | 2018-09-10 14:47:28 +0100 | [diff] [blame] | 117 | { |
Sadik Armagan | 2e6dc3a | 2019-04-03 17:48:18 +0100 | [diff] [blame] | 118 | RefCreateElementwiseWorkloadTest<RefSubtractionWorkload, |
Éanna Ó Catháin | d57415d | 2018-11-28 16:24:38 +0000 | [diff] [blame] | 119 | SubtractionQueueDescriptor, |
| 120 | SubtractionLayer, |
| 121 | armnn::DataType::Float32>(); |
David Beck | bc39245 | 2018-09-10 14:47:28 +0100 | [diff] [blame] | 122 | } |
| 123 | |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 124 | BOOST_AUTO_TEST_CASE(CreateSubtractionFloat16Workload) |
| 125 | { |
| 126 | RefCreateElementwiseWorkloadTest<RefSubtractionWorkload, |
| 127 | SubtractionQueueDescriptor, |
| 128 | SubtractionLayer, |
| 129 | armnn::DataType::Float16>(); |
| 130 | } |
| 131 | |
David Beck | bc39245 | 2018-09-10 14:47:28 +0100 | [diff] [blame] | 132 | BOOST_AUTO_TEST_CASE(CreateSubtractionUint8Workload) |
| 133 | { |
Sadik Armagan | 2e6dc3a | 2019-04-03 17:48:18 +0100 | [diff] [blame] | 134 | RefCreateElementwiseWorkloadTest<RefSubtractionWorkload, |
Éanna Ó Catháin | d57415d | 2018-11-28 16:24:38 +0000 | [diff] [blame] | 135 | SubtractionQueueDescriptor, |
| 136 | SubtractionLayer, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 137 | armnn::DataType::QAsymmU8>(); |
David Beck | bc39245 | 2018-09-10 14:47:28 +0100 | [diff] [blame] | 138 | } |
| 139 | |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 140 | BOOST_AUTO_TEST_CASE(CreateSubtractionInt16Workload) |
| 141 | { |
| 142 | RefCreateElementwiseWorkloadTest<RefSubtractionWorkload, |
| 143 | SubtractionQueueDescriptor, |
| 144 | SubtractionLayer, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 145 | armnn::DataType::QSymmS16>(); |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 146 | } |
| 147 | |
David Beck | bc39245 | 2018-09-10 14:47:28 +0100 | [diff] [blame] | 148 | BOOST_AUTO_TEST_CASE(CreateMultiplicationFloatWorkload) |
| 149 | { |
Sadik Armagan | 2e6dc3a | 2019-04-03 17:48:18 +0100 | [diff] [blame] | 150 | RefCreateElementwiseWorkloadTest<RefMultiplicationWorkload, |
Éanna Ó Catháin | d57415d | 2018-11-28 16:24:38 +0000 | [diff] [blame] | 151 | MultiplicationQueueDescriptor, |
| 152 | MultiplicationLayer, |
| 153 | armnn::DataType::Float32>(); |
David Beck | bc39245 | 2018-09-10 14:47:28 +0100 | [diff] [blame] | 154 | } |
| 155 | |
| 156 | BOOST_AUTO_TEST_CASE(CreateMultiplicationUint8Workload) |
| 157 | { |
Sadik Armagan | 2e6dc3a | 2019-04-03 17:48:18 +0100 | [diff] [blame] | 158 | RefCreateElementwiseWorkloadTest<RefMultiplicationWorkload, |
Éanna Ó Catháin | d57415d | 2018-11-28 16:24:38 +0000 | [diff] [blame] | 159 | MultiplicationQueueDescriptor, |
| 160 | MultiplicationLayer, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 161 | armnn::DataType::QAsymmU8>(); |
David Beck | bc39245 | 2018-09-10 14:47:28 +0100 | [diff] [blame] | 162 | } |
| 163 | |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 164 | BOOST_AUTO_TEST_CASE(CreateMultiplicationInt16Workload) |
| 165 | { |
| 166 | RefCreateElementwiseWorkloadTest<RefMultiplicationWorkload, |
| 167 | MultiplicationQueueDescriptor, |
| 168 | MultiplicationLayer, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 169 | armnn::DataType::QSymmS16>(); |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 170 | } |
| 171 | |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 172 | BOOST_AUTO_TEST_CASE(CreateDivisionFloat32Workload) |
David Beck | bc39245 | 2018-09-10 14:47:28 +0100 | [diff] [blame] | 173 | { |
Sadik Armagan | 2e6dc3a | 2019-04-03 17:48:18 +0100 | [diff] [blame] | 174 | RefCreateElementwiseWorkloadTest<RefDivisionWorkload, |
Éanna Ó Catháin | d57415d | 2018-11-28 16:24:38 +0000 | [diff] [blame] | 175 | DivisionQueueDescriptor, |
| 176 | DivisionLayer, |
| 177 | armnn::DataType::Float32>(); |
David Beck | bc39245 | 2018-09-10 14:47:28 +0100 | [diff] [blame] | 178 | } |
| 179 | |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 180 | BOOST_AUTO_TEST_CASE(CreateDivisionFloat16Workload) |
| 181 | { |
| 182 | RefCreateElementwiseWorkloadTest<RefDivisionWorkload, |
| 183 | DivisionQueueDescriptor, |
| 184 | DivisionLayer, |
| 185 | armnn::DataType::Float16>(); |
| 186 | } |
| 187 | |
David Beck | bc39245 | 2018-09-10 14:47:28 +0100 | [diff] [blame] | 188 | BOOST_AUTO_TEST_CASE(CreateDivisionUint8Workload) |
| 189 | { |
Sadik Armagan | 2e6dc3a | 2019-04-03 17:48:18 +0100 | [diff] [blame] | 190 | RefCreateElementwiseWorkloadTest<RefDivisionWorkload, |
Éanna Ó Catháin | d57415d | 2018-11-28 16:24:38 +0000 | [diff] [blame] | 191 | DivisionQueueDescriptor, |
| 192 | DivisionLayer, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 193 | armnn::DataType::QAsymmU8>(); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 194 | } |
| 195 | |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 196 | BOOST_AUTO_TEST_CASE(CreateDivisionInt16Workload) |
| 197 | { |
| 198 | RefCreateElementwiseWorkloadTest<RefDivisionWorkload, |
| 199 | DivisionQueueDescriptor, |
| 200 | DivisionLayer, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 201 | armnn::DataType::QSymmS16>(); |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 202 | } |
| 203 | |
Matteo Martincigh | 3dc4303 | 2018-10-18 10:55:19 +0100 | [diff] [blame] | 204 | template <typename BatchNormalizationWorkloadType, armnn::DataType DataType> |
| 205 | static void RefCreateBatchNormalizationWorkloadTest(DataLayout dataLayout) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 206 | { |
Matteo Martincigh | 3dc4303 | 2018-10-18 10:55:19 +0100 | [diff] [blame] | 207 | Graph graph; |
Matthew Bentham | 7c1603a | 2019-06-21 17:22:23 +0100 | [diff] [blame] | 208 | RefWorkloadFactory factory = GetFactory(); |
Matteo Martincigh | 3122bd5 | 2019-06-03 16:54:25 +0100 | [diff] [blame] | 209 | auto workload = CreateBatchNormalizationWorkloadTest<BatchNormalizationWorkloadType, DataType>(factory, |
| 210 | graph, |
| 211 | dataLayout); |
Matteo Martincigh | 3dc4303 | 2018-10-18 10:55:19 +0100 | [diff] [blame] | 212 | |
| 213 | TensorShape inputShape; |
| 214 | TensorShape outputShape; |
| 215 | |
| 216 | switch (dataLayout) |
| 217 | { |
| 218 | case DataLayout::NHWC: |
Nikhil Raj | d134093 | 2018-10-18 14:27:50 +0100 | [diff] [blame] | 219 | inputShape = { 2, 4, 4, 3 }; |
| 220 | outputShape = { 2, 4, 4, 3 }; |
Matteo Martincigh | 3dc4303 | 2018-10-18 10:55:19 +0100 | [diff] [blame] | 221 | break; |
| 222 | case DataLayout::NCHW: |
| 223 | default: |
Nikhil Raj | d134093 | 2018-10-18 14:27:50 +0100 | [diff] [blame] | 224 | inputShape = { 2, 3, 4, 4 }; |
| 225 | outputShape = { 2, 3, 4, 4 }; |
Matteo Martincigh | 3dc4303 | 2018-10-18 10:55:19 +0100 | [diff] [blame] | 226 | break; |
| 227 | } |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 228 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 229 | // Checks that outputs and inputs are as we expect them (see definition of CreateBatchNormalizationWorkloadTest). |
Matteo Martincigh | 3dc4303 | 2018-10-18 10:55:19 +0100 | [diff] [blame] | 230 | CheckInputOutput(std::move(workload), TensorInfo(inputShape, DataType), TensorInfo(outputShape, DataType)); |
| 231 | } |
| 232 | |
| 233 | BOOST_AUTO_TEST_CASE(CreateBatchNormalizationFloat32Workload) |
| 234 | { |
Matteo Martincigh | 3122bd5 | 2019-06-03 16:54:25 +0100 | [diff] [blame] | 235 | RefCreateBatchNormalizationWorkloadTest<RefBatchNormalizationWorkload,armnn::DataType::Float32> |
Matteo Martincigh | 3dc4303 | 2018-10-18 10:55:19 +0100 | [diff] [blame] | 236 | (DataLayout::NCHW); |
| 237 | } |
| 238 | |
| 239 | BOOST_AUTO_TEST_CASE(CreateBatchNormalizationFloat32WorkloadNhwc) |
| 240 | { |
Matteo Martincigh | 3122bd5 | 2019-06-03 16:54:25 +0100 | [diff] [blame] | 241 | RefCreateBatchNormalizationWorkloadTest<RefBatchNormalizationWorkload, armnn::DataType::Float32> |
Matteo Martincigh | 3dc4303 | 2018-10-18 10:55:19 +0100 | [diff] [blame] | 242 | (DataLayout::NHWC); |
| 243 | } |
| 244 | |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 245 | BOOST_AUTO_TEST_CASE(CreateBatchNormalizationFloat16Workload) |
| 246 | { |
| 247 | RefCreateBatchNormalizationWorkloadTest<RefBatchNormalizationWorkload,armnn::DataType::Float16> |
| 248 | (DataLayout::NCHW); |
| 249 | } |
| 250 | |
| 251 | BOOST_AUTO_TEST_CASE(CreateBatchNormalizationFloat16WorkloadNhwc) |
| 252 | { |
| 253 | RefCreateBatchNormalizationWorkloadTest<RefBatchNormalizationWorkload, armnn::DataType::Float16> |
| 254 | (DataLayout::NHWC); |
| 255 | } |
| 256 | |
Matteo Martincigh | 3dc4303 | 2018-10-18 10:55:19 +0100 | [diff] [blame] | 257 | BOOST_AUTO_TEST_CASE(CreateBatchNormalizationUint8Workload) |
| 258 | { |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 259 | RefCreateBatchNormalizationWorkloadTest<RefBatchNormalizationWorkload, armnn::DataType::QAsymmU8> |
Matteo Martincigh | 3dc4303 | 2018-10-18 10:55:19 +0100 | [diff] [blame] | 260 | (DataLayout::NCHW); |
| 261 | } |
| 262 | |
| 263 | BOOST_AUTO_TEST_CASE(CreateBatchNormalizationUint8WorkloadNhwc) |
| 264 | { |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 265 | RefCreateBatchNormalizationWorkloadTest<RefBatchNormalizationWorkload, armnn::DataType::QAsymmU8> |
Matteo Martincigh | 3dc4303 | 2018-10-18 10:55:19 +0100 | [diff] [blame] | 266 | (DataLayout::NHWC); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 267 | } |
| 268 | |
Matteo Martincigh | f550713 | 2019-06-04 10:59:47 +0100 | [diff] [blame] | 269 | BOOST_AUTO_TEST_CASE(CreateBatchNormalizationInt16Workload) |
| 270 | { |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 271 | RefCreateBatchNormalizationWorkloadTest<RefBatchNormalizationWorkload, armnn::DataType::QSymmS16> |
Matteo Martincigh | f550713 | 2019-06-04 10:59:47 +0100 | [diff] [blame] | 272 | (DataLayout::NCHW); |
| 273 | } |
| 274 | |
| 275 | BOOST_AUTO_TEST_CASE(CreateBatchNormalizationInt16WorkloadNhwc) |
| 276 | { |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 277 | RefCreateBatchNormalizationWorkloadTest<RefBatchNormalizationWorkload, armnn::DataType::QSymmS16> |
Matteo Martincigh | f550713 | 2019-06-04 10:59:47 +0100 | [diff] [blame] | 278 | (DataLayout::NHWC); |
| 279 | } |
| 280 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 281 | BOOST_AUTO_TEST_CASE(CreateConvertFp16ToFp32Float32Workload) |
| 282 | { |
| 283 | Graph graph; |
Matthew Bentham | 7c1603a | 2019-06-21 17:22:23 +0100 | [diff] [blame] | 284 | RefWorkloadFactory factory = GetFactory(); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 285 | auto workload = CreateConvertFp16ToFp32WorkloadTest<RefConvertFp16ToFp32Workload>(factory, graph); |
| 286 | |
| 287 | // Checks that outputs and inputs are as we expect them |
| 288 | CheckInputOutput( |
| 289 | std::move(workload), TensorInfo({1, 3, 2, 3}, DataType::Float16), TensorInfo({1, 3, 2, 3}, DataType::Float32)); |
| 290 | } |
| 291 | |
| 292 | BOOST_AUTO_TEST_CASE(CreateConvertFp32ToFp16Float16Workload) |
| 293 | { |
| 294 | Graph graph; |
Matthew Bentham | 7c1603a | 2019-06-21 17:22:23 +0100 | [diff] [blame] | 295 | RefWorkloadFactory factory = GetFactory(); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 296 | auto workload = CreateConvertFp32ToFp16WorkloadTest<RefConvertFp32ToFp16Workload>(factory, graph); |
| 297 | |
| 298 | // Checks that outputs and inputs are as we expect them |
| 299 | CheckInputOutput( |
| 300 | std::move(workload), TensorInfo({1, 3, 2, 3}, DataType::Float32), TensorInfo({1, 3, 2, 3}, DataType::Float16)); |
| 301 | } |
| 302 | |
Nikhil Raj | e4dfd6e | 2018-10-18 10:11:04 +0100 | [diff] [blame] | 303 | static void RefCreateConvolution2dWorkloadTest(DataLayout dataLayout = DataLayout::NCHW) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 304 | { |
Nikhil Raj | e4dfd6e | 2018-10-18 10:11:04 +0100 | [diff] [blame] | 305 | Graph graph; |
Matthew Bentham | 7c1603a | 2019-06-21 17:22:23 +0100 | [diff] [blame] | 306 | RefWorkloadFactory factory = GetFactory(); |
Mike Kelly | 9b39832 | 2019-05-22 17:21:49 +0100 | [diff] [blame] | 307 | auto workload = CreateConvolution2dWorkloadTest<RefConvolution2dWorkload, DataType::Float32> |
Nikhil Raj | e4dfd6e | 2018-10-18 10:11:04 +0100 | [diff] [blame] | 308 | (factory, graph, dataLayout); |
| 309 | |
Mike Kelly | db48288 | 2019-06-14 12:35:24 +0100 | [diff] [blame] | 310 | TensorShape inputShape = (dataLayout == DataLayout::NCHW) ? std::initializer_list<unsigned int>({2, 3, 8, 16}) |
| 311 | : std::initializer_list<unsigned int>({2, 8, 16, 3}); |
| 312 | TensorShape outputShape = (dataLayout == DataLayout::NCHW) ? std::initializer_list<unsigned int>({2, 2, 2, 10}) |
| 313 | : std::initializer_list<unsigned int>({2, 2, 10, 2}); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 314 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 315 | // Checks that outputs and inputs are as we expect them (see definition of CreateConvolution2dWorkloadTest). |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 316 | CheckInputOutput(std::move(workload), |
Nikhil Raj | e4dfd6e | 2018-10-18 10:11:04 +0100 | [diff] [blame] | 317 | TensorInfo(inputShape, DataType::Float32), |
| 318 | TensorInfo(outputShape, DataType::Float32)); |
| 319 | } |
| 320 | |
| 321 | BOOST_AUTO_TEST_CASE(CreateConvolution2dFloatNchwWorkload) |
| 322 | { |
| 323 | RefCreateConvolution2dWorkloadTest(DataLayout::NCHW); |
| 324 | } |
| 325 | |
| 326 | BOOST_AUTO_TEST_CASE(CreateConvolution2dFloatNhwcWorkload) |
| 327 | { |
| 328 | RefCreateConvolution2dWorkloadTest(DataLayout::NHWC); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 329 | } |
| 330 | |
Ruomei Yan | 495852f | 2019-05-23 11:37:33 +0100 | [diff] [blame] | 331 | static void RefCreateDepthwiseConvolutionWorkloadTest(DataLayout dataLayout) |
| 332 | { |
| 333 | Graph graph; |
Matthew Bentham | 7c1603a | 2019-06-21 17:22:23 +0100 | [diff] [blame] | 334 | RefWorkloadFactory factory = GetFactory(); |
Ruomei Yan | 495852f | 2019-05-23 11:37:33 +0100 | [diff] [blame] | 335 | auto workload = CreateDepthwiseConvolution2dWorkloadTest<RefDepthwiseConvolution2dWorkload, DataType::Float32> |
| 336 | (factory, graph, dataLayout); |
| 337 | |
Mike Kelly | db48288 | 2019-06-14 12:35:24 +0100 | [diff] [blame] | 338 | TensorShape inputShape = (dataLayout == DataLayout::NCHW) ? std::initializer_list<unsigned int>({ 2, 2, 5, 5 }) |
| 339 | : std::initializer_list<unsigned int>({ 2, 5, 5, 2 }); |
| 340 | TensorShape outputShape = (dataLayout == DataLayout::NCHW) ? std::initializer_list<unsigned int>({ 2, 2, 5, 5 }) |
| 341 | : std::initializer_list<unsigned int>({ 2, 5, 5, 2 }); |
| 342 | |
Ruomei Yan | 495852f | 2019-05-23 11:37:33 +0100 | [diff] [blame] | 343 | // Checks that inputs/outputs are as we expect them (see definition of CreateDepthwiseConvolution2dWorkloadTest). |
| 344 | CheckInputOutput(std::move(workload), |
| 345 | TensorInfo(inputShape, DataType::Float32), |
| 346 | TensorInfo(outputShape, DataType::Float32)); |
| 347 | } |
| 348 | |
| 349 | BOOST_AUTO_TEST_CASE(CreateDepthwiseConvolutionFloat32NhwcWorkload) |
| 350 | { |
| 351 | RefCreateDepthwiseConvolutionWorkloadTest(DataLayout::NHWC); |
| 352 | } |
| 353 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 354 | template <typename FullyConnectedWorkloadType, armnn::DataType DataType> |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 355 | static void RefCreateFullyConnectedWorkloadTest() |
| 356 | { |
| 357 | Graph graph; |
Matthew Bentham | 7c1603a | 2019-06-21 17:22:23 +0100 | [diff] [blame] | 358 | RefWorkloadFactory factory = GetFactory(); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 359 | auto workload = CreateFullyConnectedWorkloadTest<FullyConnectedWorkloadType, DataType>(factory, graph); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 360 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 361 | // Checks that outputs and inputs are as we expect them (see definition of CreateFullyConnectedWorkloadTest). |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 362 | float inputsQScale = DataType == armnn::DataType::QAsymmU8 ? 1.0f : 0.0; |
| 363 | float outputQScale = DataType == armnn::DataType::QAsymmU8 ? 2.0f : 0.0; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 364 | CheckInputOutput(std::move(workload), |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 365 | TensorInfo({ 3, 1, 4, 5 }, DataType, inputsQScale), |
| 366 | TensorInfo({ 3, 7 }, DataType, outputQScale)); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 367 | } |
| 368 | |
Francis Murtagh | 43aec58 | 2019-05-27 12:14:10 +0100 | [diff] [blame] | 369 | BOOST_AUTO_TEST_CASE(CreateFullyConnectedWorkloadFloat32) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 370 | { |
Francis Murtagh | 43aec58 | 2019-05-27 12:14:10 +0100 | [diff] [blame] | 371 | RefCreateFullyConnectedWorkloadTest<RefFullyConnectedWorkload, armnn::DataType::Float32>(); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 372 | } |
| 373 | |
Francis Murtagh | 43aec58 | 2019-05-27 12:14:10 +0100 | [diff] [blame] | 374 | BOOST_AUTO_TEST_CASE(CreateFullyConnectedWorkloadQuantisedAsymm8) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 375 | { |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 376 | RefCreateFullyConnectedWorkloadTest<RefFullyConnectedWorkload, armnn::DataType::QAsymmU8>(); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 377 | } |
| 378 | |
Francis Murtagh | d0dfe17 | 2019-06-25 10:57:10 +0100 | [diff] [blame] | 379 | BOOST_AUTO_TEST_CASE(CreateFullyConnectedWorkloadQuantisedSymm16) |
Francis Murtagh | 46c09d0 | 2019-05-28 08:15:28 +0100 | [diff] [blame] | 380 | { |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 381 | RefCreateFullyConnectedWorkloadTest<RefFullyConnectedWorkload, armnn::DataType::QSymmS16>(); |
Francis Murtagh | 46c09d0 | 2019-05-28 08:15:28 +0100 | [diff] [blame] | 382 | } |
| 383 | |
narpra01 | 55a97bc | 2018-10-02 14:35:53 +0100 | [diff] [blame] | 384 | template <typename NormalizationWorkloadType, armnn::DataType DataType> |
Matteo Martincigh | a160b24 | 2018-10-18 10:33:23 +0100 | [diff] [blame] | 385 | static void RefCreateNormalizationWorkloadTest(DataLayout dataLayout) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 386 | { |
narpra01 | 55a97bc | 2018-10-02 14:35:53 +0100 | [diff] [blame] | 387 | Graph graph; |
Matthew Bentham | 7c1603a | 2019-06-21 17:22:23 +0100 | [diff] [blame] | 388 | RefWorkloadFactory factory = GetFactory(); |
Matteo Martincigh | a160b24 | 2018-10-18 10:33:23 +0100 | [diff] [blame] | 389 | auto workload = CreateNormalizationWorkloadTest<NormalizationWorkloadType, DataType>(factory, graph, dataLayout); |
| 390 | |
| 391 | TensorShape inputShape; |
| 392 | TensorShape outputShape; |
| 393 | |
| 394 | switch (dataLayout) |
| 395 | { |
| 396 | case DataLayout::NHWC: |
| 397 | inputShape = { 3, 1, 5, 5 }; |
| 398 | outputShape = { 3, 1, 5, 5 }; |
| 399 | break; |
| 400 | case DataLayout::NCHW: |
| 401 | default: |
| 402 | inputShape = { 3, 5, 5, 1 }; |
| 403 | outputShape = { 3, 5, 5, 1 }; |
| 404 | break; |
| 405 | } |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 406 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 407 | // Checks that outputs and inputs are as we expect them (see definition of CreateNormalizationWorkloadTest). |
Matteo Martincigh | a160b24 | 2018-10-18 10:33:23 +0100 | [diff] [blame] | 408 | CheckInputOutput(std::move(workload), TensorInfo(inputShape, DataType), TensorInfo(outputShape, DataType)); |
narpra01 | 55a97bc | 2018-10-02 14:35:53 +0100 | [diff] [blame] | 409 | } |
| 410 | |
Matteo Martincigh | 2fc70c5 | 2019-06-05 14:12:48 +0100 | [diff] [blame] | 411 | BOOST_AUTO_TEST_CASE(CreateRefNormalizationFloat32NchwWorkload) |
narpra01 | 55a97bc | 2018-10-02 14:35:53 +0100 | [diff] [blame] | 412 | { |
Matteo Martincigh | 2fc70c5 | 2019-06-05 14:12:48 +0100 | [diff] [blame] | 413 | RefCreateNormalizationWorkloadTest<RefNormalizationWorkload, armnn::DataType::Float32>(DataLayout::NCHW); |
Matteo Martincigh | a160b24 | 2018-10-18 10:33:23 +0100 | [diff] [blame] | 414 | } |
| 415 | |
Matteo Martincigh | 2fc70c5 | 2019-06-05 14:12:48 +0100 | [diff] [blame] | 416 | BOOST_AUTO_TEST_CASE(CreateRefNormalizationFloat32NhwcWorkload) |
Matteo Martincigh | a160b24 | 2018-10-18 10:33:23 +0100 | [diff] [blame] | 417 | { |
Matteo Martincigh | 2fc70c5 | 2019-06-05 14:12:48 +0100 | [diff] [blame] | 418 | RefCreateNormalizationWorkloadTest<RefNormalizationWorkload, armnn::DataType::Float32>(DataLayout::NHWC); |
| 419 | } |
| 420 | |
| 421 | BOOST_AUTO_TEST_CASE(CreateRefNormalizationUint8NchwWorkload) |
| 422 | { |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 423 | RefCreateNormalizationWorkloadTest<RefNormalizationWorkload, armnn::DataType::QAsymmU8>(DataLayout::NCHW); |
Matteo Martincigh | 2fc70c5 | 2019-06-05 14:12:48 +0100 | [diff] [blame] | 424 | } |
| 425 | |
| 426 | BOOST_AUTO_TEST_CASE(CreateRefNormalizationUint8NhwcWorkload) |
| 427 | { |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 428 | RefCreateNormalizationWorkloadTest<RefNormalizationWorkload, armnn::DataType::QAsymmU8>(DataLayout::NHWC); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 429 | } |
| 430 | |
Matteo Martincigh | 6aeb771 | 2019-06-05 17:23:29 +0100 | [diff] [blame] | 431 | BOOST_AUTO_TEST_CASE(CreateRefNormalizationInt16NchwWorkload) |
| 432 | { |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 433 | RefCreateNormalizationWorkloadTest<RefNormalizationWorkload, armnn::DataType::QSymmS16>(DataLayout::NCHW); |
Matteo Martincigh | 6aeb771 | 2019-06-05 17:23:29 +0100 | [diff] [blame] | 434 | } |
| 435 | |
| 436 | BOOST_AUTO_TEST_CASE(CreateRefNormalizationInt16NhwcWorkload) |
| 437 | { |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 438 | RefCreateNormalizationWorkloadTest<RefNormalizationWorkload, armnn::DataType::QSymmS16>(DataLayout::NHWC); |
Matteo Martincigh | 6aeb771 | 2019-06-05 17:23:29 +0100 | [diff] [blame] | 439 | } |
| 440 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 441 | template <typename Pooling2dWorkloadType, armnn::DataType DataType> |
James Conroy | 6948227 | 2018-10-19 10:41:35 +0100 | [diff] [blame] | 442 | static void RefCreatePooling2dWorkloadTest(DataLayout dataLayout) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 443 | { |
| 444 | Graph graph; |
Matthew Bentham | 7c1603a | 2019-06-21 17:22:23 +0100 | [diff] [blame] | 445 | RefWorkloadFactory factory = GetFactory(); |
James Conroy | 6948227 | 2018-10-19 10:41:35 +0100 | [diff] [blame] | 446 | auto workload = CreatePooling2dWorkloadTest<Pooling2dWorkloadType, DataType>(factory, graph, dataLayout); |
| 447 | |
| 448 | TensorShape inputShape; |
| 449 | TensorShape outputShape; |
| 450 | |
| 451 | switch (dataLayout) |
| 452 | { |
| 453 | case DataLayout::NHWC: |
| 454 | inputShape = { 3, 5, 5, 2 }; |
| 455 | outputShape = { 3, 2, 4, 2 }; |
| 456 | break; |
| 457 | case DataLayout::NCHW: |
| 458 | default: |
| 459 | inputShape = { 3, 2, 5, 5 }; |
| 460 | outputShape = { 3, 2, 2, 4 }; |
| 461 | } |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 462 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 463 | // Checks that outputs and inputs are as we expect them (see definition of CreatePooling2dWorkloadTest). |
James Conroy | 6948227 | 2018-10-19 10:41:35 +0100 | [diff] [blame] | 464 | CheckInputOutput(std::move(workload), |
| 465 | TensorInfo(inputShape, DataType), |
| 466 | TensorInfo(outputShape, DataType)); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 467 | } |
| 468 | |
| 469 | BOOST_AUTO_TEST_CASE(CreatePooling2dFloat32Workload) |
| 470 | { |
Teresa Charlin | a3b2047 | 2019-06-06 11:12:32 +0100 | [diff] [blame] | 471 | RefCreatePooling2dWorkloadTest<RefPooling2dWorkload, armnn::DataType::Float32>(DataLayout::NCHW); |
James Conroy | 6948227 | 2018-10-19 10:41:35 +0100 | [diff] [blame] | 472 | } |
| 473 | |
| 474 | BOOST_AUTO_TEST_CASE(CreatePooling2dFloat32NhwcWorkload) |
| 475 | { |
Teresa Charlin | a3b2047 | 2019-06-06 11:12:32 +0100 | [diff] [blame] | 476 | RefCreatePooling2dWorkloadTest<RefPooling2dWorkload, armnn::DataType::Float32>(DataLayout::NHWC); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 477 | } |
| 478 | |
| 479 | BOOST_AUTO_TEST_CASE(CreatePooling2dUint8Workload) |
| 480 | { |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 481 | RefCreatePooling2dWorkloadTest<RefPooling2dWorkload, armnn::DataType::QAsymmU8>(DataLayout::NCHW); |
James Conroy | 6948227 | 2018-10-19 10:41:35 +0100 | [diff] [blame] | 482 | } |
| 483 | |
| 484 | BOOST_AUTO_TEST_CASE(CreatePooling2dUint8NhwcWorkload) |
| 485 | { |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 486 | RefCreatePooling2dWorkloadTest<RefPooling2dWorkload, armnn::DataType::QAsymmU8>(DataLayout::NHWC); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 487 | } |
| 488 | |
Teresa Charlin | 0434df6 | 2019-06-06 13:40:35 +0100 | [diff] [blame] | 489 | BOOST_AUTO_TEST_CASE(CreatePooling2dInt16Workload) |
| 490 | { |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 491 | RefCreatePooling2dWorkloadTest<RefPooling2dWorkload, armnn::DataType::QSymmS16>(DataLayout::NCHW); |
Teresa Charlin | 0434df6 | 2019-06-06 13:40:35 +0100 | [diff] [blame] | 492 | } |
| 493 | |
| 494 | BOOST_AUTO_TEST_CASE(CreatePooling2dInt16NhwcWorkload) |
| 495 | { |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 496 | RefCreatePooling2dWorkloadTest<RefPooling2dWorkload, armnn::DataType::QSymmS16>(DataLayout::NHWC); |
Teresa Charlin | 0434df6 | 2019-06-06 13:40:35 +0100 | [diff] [blame] | 497 | } |
| 498 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 499 | template <typename SoftmaxWorkloadType, armnn::DataType DataType> |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 500 | static void RefCreateSoftmaxWorkloadTest() |
| 501 | { |
| 502 | Graph graph; |
Matthew Bentham | 7c1603a | 2019-06-21 17:22:23 +0100 | [diff] [blame] | 503 | RefWorkloadFactory factory = GetFactory(); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 504 | auto workload = CreateSoftmaxWorkloadTest<SoftmaxWorkloadType, DataType>(factory, graph); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 505 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 506 | // Checks that outputs and inputs are as we expect them (see definition of CreateSoftmaxWorkloadTest). |
Sadik Armagan | be88a57 | 2020-04-30 11:39:37 +0100 | [diff] [blame] | 507 | |
| 508 | armnn::TensorInfo tensorInfo({4, 1}, DataType); |
| 509 | if (DataType == armnn::DataType::QAsymmU8) |
| 510 | { |
| 511 | tensorInfo.SetQuantizationOffset(0); |
| 512 | tensorInfo.SetQuantizationScale(1.f / 256); |
| 513 | } |
| 514 | else if (DataType == armnn::DataType::QAsymmS8) |
| 515 | { |
| 516 | tensorInfo.SetQuantizationOffset(-128); |
| 517 | tensorInfo.SetQuantizationScale(1.f / 256); |
| 518 | } |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 519 | CheckInputOutput( |
| 520 | std::move(workload), |
Sadik Armagan | be88a57 | 2020-04-30 11:39:37 +0100 | [diff] [blame] | 521 | tensorInfo, |
| 522 | tensorInfo); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 523 | } |
| 524 | |
| 525 | BOOST_AUTO_TEST_CASE(CreateSoftmaxFloat32Workload) |
| 526 | { |
nikraj01 | a121de3 | 2019-05-29 10:51:05 +0100 | [diff] [blame] | 527 | RefCreateSoftmaxWorkloadTest<RefSoftmaxWorkload, armnn::DataType::Float32>(); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 528 | } |
| 529 | |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 530 | BOOST_AUTO_TEST_CASE(CreateSoftmaxFloat16Workload) |
| 531 | { |
| 532 | RefCreateSoftmaxWorkloadTest<RefSoftmaxWorkload, armnn::DataType::Float16>(); |
| 533 | } |
| 534 | |
nikraj01 | a121de3 | 2019-05-29 10:51:05 +0100 | [diff] [blame] | 535 | BOOST_AUTO_TEST_CASE(CreateSoftmaxQuantisedAsymm8Workload) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 536 | { |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 537 | RefCreateSoftmaxWorkloadTest<RefSoftmaxWorkload, armnn::DataType::QAsymmU8>(); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 538 | } |
| 539 | |
nikraj01 | 248683f | 2019-05-29 16:46:50 +0100 | [diff] [blame] | 540 | BOOST_AUTO_TEST_CASE(CreateSoftmaxQuantisedSymm16Workload) |
| 541 | { |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 542 | RefCreateSoftmaxWorkloadTest<RefSoftmaxWorkload, armnn::DataType::QSymmS16>(); |
nikraj01 | 248683f | 2019-05-29 16:46:50 +0100 | [diff] [blame] | 543 | } |
| 544 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 545 | template <typename SplitterWorkloadType, armnn::DataType DataType> |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 546 | static void RefCreateSplitterWorkloadTest() |
| 547 | { |
| 548 | Graph graph; |
Matthew Bentham | 7c1603a | 2019-06-21 17:22:23 +0100 | [diff] [blame] | 549 | RefWorkloadFactory factory = GetFactory(); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 550 | auto workload = CreateSplitterWorkloadTest<SplitterWorkloadType, DataType>(factory, graph); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 551 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 552 | // Checks that outputs are as we expect them (see definition of CreateSplitterWorkloadTest). |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 553 | SplitterQueueDescriptor queueDescriptor = workload->GetData(); |
Jan Eilers | bb446e5 | 2020-04-02 13:56:54 +0100 | [diff] [blame] | 554 | auto inputHandle = PolymorphicDowncast<RefTensorHandle*>(queueDescriptor.m_Inputs[0]); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 555 | BOOST_TEST((inputHandle->GetTensorInfo() == TensorInfo({ 5, 7, 7 }, DataType))); |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 556 | |
Jan Eilers | bb446e5 | 2020-04-02 13:56:54 +0100 | [diff] [blame] | 557 | auto outputHandle0 = PolymorphicDowncast<RefTensorHandle*>(queueDescriptor.m_Outputs[0]); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 558 | BOOST_TEST((outputHandle0->GetTensorInfo() == TensorInfo({ 1, 7, 7 }, DataType))); |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 559 | |
Jan Eilers | bb446e5 | 2020-04-02 13:56:54 +0100 | [diff] [blame] | 560 | auto outputHandle1 = PolymorphicDowncast<RefTensorHandle*>(queueDescriptor.m_Outputs[1]); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 561 | BOOST_TEST((outputHandle1->GetTensorInfo() == TensorInfo({ 2, 7, 7 }, DataType))); |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 562 | |
Jan Eilers | bb446e5 | 2020-04-02 13:56:54 +0100 | [diff] [blame] | 563 | auto outputHandle2 = PolymorphicDowncast<RefTensorHandle*>(queueDescriptor.m_Outputs[2]); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 564 | BOOST_TEST((outputHandle2->GetTensorInfo() == TensorInfo({ 2, 7, 7 }, DataType))); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 565 | } |
| 566 | |
| 567 | BOOST_AUTO_TEST_CASE(CreateSplitterFloat32Workload) |
| 568 | { |
Ruomei Yan | 25339c3 | 2019-05-28 16:48:20 +0100 | [diff] [blame] | 569 | RefCreateSplitterWorkloadTest<RefSplitterWorkload, armnn::DataType::Float32>(); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 570 | } |
| 571 | |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 572 | BOOST_AUTO_TEST_CASE(CreateSplitterFloat16Workload) |
| 573 | { |
| 574 | RefCreateSplitterWorkloadTest<RefSplitterWorkload, armnn::DataType::Float16>(); |
| 575 | } |
| 576 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 577 | BOOST_AUTO_TEST_CASE(CreateSplitterUint8Workload) |
| 578 | { |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 579 | RefCreateSplitterWorkloadTest<RefSplitterWorkload, armnn::DataType::QAsymmU8>(); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 580 | } |
| 581 | |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 582 | template <typename SplitterWorkloadType, typename ConcatWorkloadType, armnn::DataType DataType> |
| 583 | static void RefCreateSplitterConcatWorkloadTest() |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 584 | { |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 585 | // Tests that it is possible to decide which output of the splitter layer |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 586 | // should be lined to which input of the concat layer. |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 587 | // We tested that is is possible to specify 0th output |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 588 | // of the splitter to be the 1st input to the concat and the 1st output of the splitter to be 0th input |
| 589 | // of the concat. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 590 | |
| 591 | Graph graph; |
Matthew Bentham | 7c1603a | 2019-06-21 17:22:23 +0100 | [diff] [blame] | 592 | RefWorkloadFactory factory = GetFactory(); |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 593 | auto workloads = CreateSplitterConcatWorkloadTest<SplitterWorkloadType, ConcatWorkloadType, DataType> |
| 594 | (factory, graph); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 595 | |
| 596 | auto wlSplitter = std::move(workloads.first); |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 597 | auto wlConcat = std::move(workloads.second); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 598 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 599 | //Checks that the index of inputs/outputs matches what we declared on InputDescriptor construction. |
Matthew Bentham | 4cefc41 | 2019-06-18 16:14:34 +0100 | [diff] [blame] | 600 | armnn::RefTensorHandle* sOut0 = dynamic_cast<armnn::RefTensorHandle*>(wlSplitter->GetData().m_Outputs[0]); |
| 601 | armnn::RefTensorHandle* sOut1 = dynamic_cast<armnn::RefTensorHandle*>(wlSplitter->GetData().m_Outputs[1]); |
| 602 | armnn::RefTensorHandle* mIn0 = dynamic_cast<armnn::RefTensorHandle*>(wlConcat->GetData().m_Inputs[0]); |
| 603 | armnn::RefTensorHandle* mIn1 = dynamic_cast<armnn::RefTensorHandle*>(wlConcat->GetData().m_Inputs[1]); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 604 | |
| 605 | BOOST_TEST(sOut0); |
| 606 | BOOST_TEST(sOut1); |
| 607 | BOOST_TEST(mIn0); |
| 608 | BOOST_TEST(mIn1); |
| 609 | |
| 610 | bool validDataPointers = (sOut0 == mIn1) && (sOut1 == mIn0); |
| 611 | |
| 612 | BOOST_TEST(validDataPointers); |
| 613 | } |
| 614 | |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 615 | BOOST_AUTO_TEST_CASE(CreateSplitterConcatFloat32) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 616 | { |
Ruomei Yan | 25339c3 | 2019-05-28 16:48:20 +0100 | [diff] [blame] | 617 | RefCreateSplitterConcatWorkloadTest<RefSplitterWorkload, RefConcatWorkload, DataType::Float32>(); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 618 | } |
| 619 | |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 620 | BOOST_AUTO_TEST_CASE(CreateSplitterConcatFloat16) |
| 621 | { |
| 622 | RefCreateSplitterConcatWorkloadTest<RefSplitterWorkload, RefConcatWorkload, DataType::Float16>(); |
| 623 | } |
| 624 | |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 625 | BOOST_AUTO_TEST_CASE(CreateSplitterConcatUint8) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 626 | { |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 627 | RefCreateSplitterConcatWorkloadTest<RefSplitterWorkload, RefConcatWorkload, DataType::QAsymmU8>(); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 628 | } |
| 629 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 630 | template <typename SplitterWorkloadType, typename ActivationWorkloadType, armnn::DataType DataType> |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 631 | static void RefCreateSingleOutputMultipleInputsTest() |
| 632 | { |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 633 | // Tests that it is possible to assign multiple (two) different layers to each of the outputs of a splitter layer. |
| 634 | // We created a splitter with two outputs. That each of those outputs is used by two different activation layers. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 635 | |
| 636 | Graph graph; |
Matthew Bentham | 7c1603a | 2019-06-21 17:22:23 +0100 | [diff] [blame] | 637 | RefWorkloadFactory factory = GetFactory(); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 638 | std::unique_ptr<SplitterWorkloadType> wlSplitter; |
| 639 | std::unique_ptr<ActivationWorkloadType> wlActiv0_0; |
| 640 | std::unique_ptr<ActivationWorkloadType> wlActiv0_1; |
| 641 | std::unique_ptr<ActivationWorkloadType> wlActiv1_0; |
| 642 | std::unique_ptr<ActivationWorkloadType> wlActiv1_1; |
| 643 | |
| 644 | CreateSplitterMultipleInputsOneOutputWorkloadTest<SplitterWorkloadType, |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 645 | ActivationWorkloadType, DataType>(factory, graph, wlSplitter, wlActiv0_0, wlActiv0_1, wlActiv1_0, wlActiv1_1); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 646 | |
Matthew Bentham | 4cefc41 | 2019-06-18 16:14:34 +0100 | [diff] [blame] | 647 | armnn::RefTensorHandle* sOut0 = dynamic_cast<armnn::RefTensorHandle*>(wlSplitter->GetData().m_Outputs[0]); |
| 648 | armnn::RefTensorHandle* sOut1 = dynamic_cast<armnn::RefTensorHandle*>(wlSplitter->GetData().m_Outputs[1]); |
| 649 | armnn::RefTensorHandle* activ0_0Im = dynamic_cast<armnn::RefTensorHandle*>(wlActiv0_0->GetData().m_Inputs[0]); |
| 650 | armnn::RefTensorHandle* activ0_1Im = dynamic_cast<armnn::RefTensorHandle*>(wlActiv0_1->GetData().m_Inputs[0]); |
| 651 | armnn::RefTensorHandle* activ1_0Im = dynamic_cast<armnn::RefTensorHandle*>(wlActiv1_0->GetData().m_Inputs[0]); |
| 652 | armnn::RefTensorHandle* activ1_1Im = dynamic_cast<armnn::RefTensorHandle*>(wlActiv1_1->GetData().m_Inputs[0]); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 653 | |
| 654 | |
| 655 | BOOST_TEST(sOut0); |
| 656 | BOOST_TEST(sOut1); |
| 657 | BOOST_TEST(activ0_0Im); |
| 658 | BOOST_TEST(activ0_1Im); |
| 659 | BOOST_TEST(activ1_0Im); |
| 660 | BOOST_TEST(activ1_1Im); |
| 661 | |
| 662 | bool validDataPointers = (sOut0 == activ0_0Im) && (sOut0 == activ0_1Im) && |
| 663 | (sOut1 == activ1_0Im) && (sOut1 == activ1_1Im); |
| 664 | |
| 665 | BOOST_TEST(validDataPointers); |
| 666 | } |
| 667 | |
| 668 | BOOST_AUTO_TEST_CASE(CreateSingleOutputMultipleInputsFloat32) |
| 669 | { |
Ruomei Yan | 25339c3 | 2019-05-28 16:48:20 +0100 | [diff] [blame] | 670 | RefCreateSingleOutputMultipleInputsTest<RefSplitterWorkload, RefActivationWorkload, |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 671 | armnn::DataType::Float32>(); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 672 | } |
| 673 | |
| 674 | BOOST_AUTO_TEST_CASE(CreateSingleOutputMultipleInputsUint8) |
| 675 | { |
Ruomei Yan | 25339c3 | 2019-05-28 16:48:20 +0100 | [diff] [blame] | 676 | RefCreateSingleOutputMultipleInputsTest<RefSplitterWorkload, RefActivationWorkload, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 677 | armnn::DataType::QAsymmU8>(); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 678 | } |
| 679 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 680 | template <typename ResizeBilinearWorkloadType, armnn::DataType DataType> |
James Conroy | 5954082 | 2018-10-11 12:39:05 +0100 | [diff] [blame] | 681 | static void RefCreateResizeBilinearTest(DataLayout dataLayout) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 682 | { |
| 683 | Graph graph; |
Matthew Bentham | 7c1603a | 2019-06-21 17:22:23 +0100 | [diff] [blame] | 684 | RefWorkloadFactory factory = GetFactory(); |
James Conroy | 5954082 | 2018-10-11 12:39:05 +0100 | [diff] [blame] | 685 | auto workload = CreateResizeBilinearWorkloadTest<ResizeBilinearWorkloadType, DataType>(factory, graph, dataLayout); |
| 686 | |
| 687 | TensorShape inputShape; |
| 688 | TensorShape outputShape; |
| 689 | |
| 690 | switch (dataLayout) |
| 691 | { |
| 692 | case DataLayout::NHWC: |
| 693 | inputShape = { 2, 4, 4, 3 }; |
| 694 | outputShape = { 2, 2, 2, 3 }; |
| 695 | break; |
James Conroy | 6948227 | 2018-10-19 10:41:35 +0100 | [diff] [blame] | 696 | case DataLayout::NCHW: |
| 697 | default: |
James Conroy | 5954082 | 2018-10-11 12:39:05 +0100 | [diff] [blame] | 698 | inputShape = { 2, 3, 4, 4 }; |
| 699 | outputShape = { 2, 3, 2, 2 }; |
| 700 | } |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 701 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 702 | // Checks that outputs and inputs are as we expect them (see definition of CreateResizeBilinearWorkloadTest). |
James Conroy | 6948227 | 2018-10-19 10:41:35 +0100 | [diff] [blame] | 703 | CheckInputOutput(std::move(workload), |
| 704 | TensorInfo(inputShape, DataType), |
| 705 | TensorInfo(outputShape, DataType)); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 706 | } |
| 707 | |
| 708 | BOOST_AUTO_TEST_CASE(CreateResizeBilinearFloat32) |
| 709 | { |
Aron Virginas-Tar | 169d2f1 | 2019-07-01 19:01:44 +0100 | [diff] [blame] | 710 | RefCreateResizeBilinearTest<RefResizeWorkload, armnn::DataType::Float32>(DataLayout::NCHW); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 711 | } |
| 712 | |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 713 | BOOST_AUTO_TEST_CASE(CreateResizeBilinearFloat16) |
| 714 | { |
| 715 | RefCreateResizeBilinearTest<RefResizeWorkload, armnn::DataType::Float16>(DataLayout::NCHW); |
| 716 | } |
| 717 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 718 | BOOST_AUTO_TEST_CASE(CreateResizeBilinearUint8) |
| 719 | { |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 720 | RefCreateResizeBilinearTest<RefResizeWorkload, armnn::DataType::QAsymmU8>(DataLayout::NCHW); |
James Conroy | 5954082 | 2018-10-11 12:39:05 +0100 | [diff] [blame] | 721 | } |
| 722 | |
Ellen Norris-Thompson | 3cb85f3 | 2019-06-17 11:32:49 +0100 | [diff] [blame] | 723 | BOOST_AUTO_TEST_CASE(CreateResizeBilinearQuantisedAsymm16) |
| 724 | { |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 725 | RefCreateResizeBilinearTest<RefResizeWorkload, armnn::DataType::QSymmS16>(DataLayout::NCHW); |
Ellen Norris-Thompson | 3cb85f3 | 2019-06-17 11:32:49 +0100 | [diff] [blame] | 726 | } |
| 727 | |
James Conroy | 5954082 | 2018-10-11 12:39:05 +0100 | [diff] [blame] | 728 | BOOST_AUTO_TEST_CASE(CreateResizeBilinearFloat32Nhwc) |
| 729 | { |
Aron Virginas-Tar | 169d2f1 | 2019-07-01 19:01:44 +0100 | [diff] [blame] | 730 | RefCreateResizeBilinearTest<RefResizeWorkload, armnn::DataType::Float32>(DataLayout::NHWC); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 731 | } |
| 732 | |
Francis Murtagh | 57f13d5 | 2019-06-24 14:24:36 +0100 | [diff] [blame] | 733 | template <typename BatchToSpaceNdWorkloadType, armnn::DataType DataType> |
| 734 | static void RefCreateBatchToSpaceNdTest() |
| 735 | { |
| 736 | Graph graph; |
| 737 | RefWorkloadFactory factory; |
| 738 | |
| 739 | auto workload = CreateBatchToSpaceNdWorkloadTest<BatchToSpaceNdWorkloadType, DataType>(factory, graph); |
| 740 | |
| 741 | CheckInputOutput(std::move(workload), |
Francis Murtagh | d0dfe17 | 2019-06-25 10:57:10 +0100 | [diff] [blame] | 742 | TensorInfo({ 1, 1, 1, 1 }, DataType), |
| 743 | TensorInfo({ 1, 1, 1, 1 }, DataType)); |
Francis Murtagh | 57f13d5 | 2019-06-24 14:24:36 +0100 | [diff] [blame] | 744 | } |
| 745 | |
| 746 | BOOST_AUTO_TEST_CASE(CreateBatchToSpaceNdFloat32) |
| 747 | { |
| 748 | RefCreateBatchToSpaceNdTest<RefBatchToSpaceNdWorkload, armnn::DataType::Float32>(); |
| 749 | } |
| 750 | |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 751 | BOOST_AUTO_TEST_CASE(CreateBatchToSpaceNdFloat16) |
| 752 | { |
| 753 | RefCreateBatchToSpaceNdTest<RefBatchToSpaceNdWorkload, armnn::DataType::Float16>(); |
| 754 | } |
| 755 | |
Francis Murtagh | 57f13d5 | 2019-06-24 14:24:36 +0100 | [diff] [blame] | 756 | BOOST_AUTO_TEST_CASE(CreateBatchToSpaceNdUint8) |
| 757 | { |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 758 | RefCreateBatchToSpaceNdTest<RefBatchToSpaceNdWorkload, armnn::DataType::QAsymmU8>(); |
Francis Murtagh | 57f13d5 | 2019-06-24 14:24:36 +0100 | [diff] [blame] | 759 | } |
| 760 | |
Francis Murtagh | d0dfe17 | 2019-06-25 10:57:10 +0100 | [diff] [blame] | 761 | BOOST_AUTO_TEST_CASE(CreateBatchToSpaceNdQSymm16) |
| 762 | { |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 763 | RefCreateBatchToSpaceNdTest<RefBatchToSpaceNdWorkload, armnn::DataType::QSymmS16>(); |
Francis Murtagh | d0dfe17 | 2019-06-25 10:57:10 +0100 | [diff] [blame] | 764 | } |
| 765 | |
Matteo Martincigh | b63973e | 2018-10-16 16:23:33 +0100 | [diff] [blame] | 766 | template <typename L2NormalizationWorkloadType, armnn::DataType DataType> |
| 767 | static void RefCreateL2NormalizationTest(DataLayout dataLayout) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 768 | { |
| 769 | Graph graph; |
Matthew Bentham | 7c1603a | 2019-06-21 17:22:23 +0100 | [diff] [blame] | 770 | RefWorkloadFactory factory = GetFactory(); |
Matteo Martincigh | b63973e | 2018-10-16 16:23:33 +0100 | [diff] [blame] | 771 | auto workload = |
| 772 | CreateL2NormalizationWorkloadTest<L2NormalizationWorkloadType, DataType>(factory, graph, dataLayout); |
| 773 | |
| 774 | TensorShape inputShape; |
| 775 | TensorShape outputShape; |
| 776 | |
| 777 | switch (dataLayout) |
| 778 | { |
| 779 | case DataLayout::NHWC: |
| 780 | inputShape = { 5, 50, 67, 20 }; |
| 781 | outputShape = { 5, 50, 67, 20 }; |
| 782 | break; |
| 783 | case DataLayout::NCHW: |
| 784 | default: |
| 785 | inputShape = { 5, 20, 50, 67 }; |
| 786 | outputShape = { 5, 20, 50, 67 }; |
| 787 | break; |
| 788 | } |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 789 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 790 | // Checks that outputs and inputs are as we expect them (see definition of CreateL2NormalizationWorkloadTest). |
Matteo Martincigh | b63973e | 2018-10-16 16:23:33 +0100 | [diff] [blame] | 791 | CheckInputOutput(std::move(workload), TensorInfo(inputShape, DataType), TensorInfo(outputShape, DataType)); |
| 792 | } |
| 793 | |
| 794 | BOOST_AUTO_TEST_CASE(CreateL2NormalizationFloat32) |
| 795 | { |
Ferran Balaguer | d73d14f | 2019-06-10 10:29:54 +0100 | [diff] [blame] | 796 | RefCreateL2NormalizationTest<RefL2NormalizationWorkload, armnn::DataType::Float32>(DataLayout::NCHW); |
Matteo Martincigh | b63973e | 2018-10-16 16:23:33 +0100 | [diff] [blame] | 797 | } |
| 798 | |
| 799 | BOOST_AUTO_TEST_CASE(CreateL2NormalizationFloat32Nhwc) |
| 800 | { |
Ferran Balaguer | d73d14f | 2019-06-10 10:29:54 +0100 | [diff] [blame] | 801 | RefCreateL2NormalizationTest<RefL2NormalizationWorkload, armnn::DataType::Float32>(DataLayout::NHWC); |
| 802 | } |
| 803 | |
| 804 | BOOST_AUTO_TEST_CASE(CreateL2NormalizationInt16) |
| 805 | { |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 806 | RefCreateL2NormalizationTest<RefL2NormalizationWorkload, armnn::DataType::QSymmS16>(DataLayout::NCHW); |
Ferran Balaguer | d73d14f | 2019-06-10 10:29:54 +0100 | [diff] [blame] | 807 | } |
| 808 | |
| 809 | BOOST_AUTO_TEST_CASE(CreateL2NormalizationInt16Nhwc) |
| 810 | { |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 811 | RefCreateL2NormalizationTest<RefL2NormalizationWorkload, armnn::DataType::QSymmS16>(DataLayout::NHWC); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 812 | } |
| 813 | |
Ferran Balaguer | c6138d8 | 2019-06-13 17:23:50 +0100 | [diff] [blame] | 814 | BOOST_AUTO_TEST_CASE(CreateL2NormalizationUint8) |
| 815 | { |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 816 | RefCreateL2NormalizationTest<RefL2NormalizationWorkload, armnn::DataType::QAsymmU8>(DataLayout::NCHW); |
Ferran Balaguer | c6138d8 | 2019-06-13 17:23:50 +0100 | [diff] [blame] | 817 | } |
| 818 | |
| 819 | BOOST_AUTO_TEST_CASE(CreateL2NormalizationUint8Nhwc) |
| 820 | { |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 821 | RefCreateL2NormalizationTest<RefL2NormalizationWorkload, armnn::DataType::QAsymmU8>(DataLayout::NHWC); |
Ferran Balaguer | c6138d8 | 2019-06-13 17:23:50 +0100 | [diff] [blame] | 822 | } |
| 823 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 824 | template <typename ReshapeWorkloadType, armnn::DataType DataType> |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 825 | static void RefCreateReshapeWorkloadTest() |
| 826 | { |
| 827 | Graph graph; |
Matthew Bentham | 7c1603a | 2019-06-21 17:22:23 +0100 | [diff] [blame] | 828 | RefWorkloadFactory factory = GetFactory(); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 829 | auto workload = CreateReshapeWorkloadTest<ReshapeWorkloadType, DataType>(factory, graph); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 830 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 831 | // Checks that outputs and inputs are as we expect them (see definition of CreateReshapeWorkloadTest). |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 832 | CheckInputOutput( |
| 833 | std::move(workload), |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 834 | TensorInfo({ 4, 1 }, DataType), |
| 835 | TensorInfo({ 1, 4 }, DataType)); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 836 | } |
| 837 | |
Nina Drozd | 8ed4b8c | 2019-05-29 10:41:04 +0100 | [diff] [blame] | 838 | BOOST_AUTO_TEST_CASE(CreateReshapeWorkloadFloat32) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 839 | { |
Nina Drozd | 2f2778f | 2019-05-27 10:37:05 +0100 | [diff] [blame] | 840 | RefCreateReshapeWorkloadTest<RefReshapeWorkload, armnn::DataType::Float32>(); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 841 | } |
| 842 | |
Nina Drozd | 8ed4b8c | 2019-05-29 10:41:04 +0100 | [diff] [blame] | 843 | BOOST_AUTO_TEST_CASE(CreateReshapeWorkloadQuantisedAsymm8) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 844 | { |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 845 | RefCreateReshapeWorkloadTest<RefReshapeWorkload, armnn::DataType::QAsymmU8>(); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 846 | } |
| 847 | |
Nina Drozd | 8ed4b8c | 2019-05-29 10:41:04 +0100 | [diff] [blame] | 848 | BOOST_AUTO_TEST_CASE(CreateReshapeWorkloadQuantisedSymm16) |
| 849 | { |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 850 | RefCreateReshapeWorkloadTest<RefReshapeWorkload, armnn::DataType::QSymmS16>(); |
Nina Drozd | 8ed4b8c | 2019-05-29 10:41:04 +0100 | [diff] [blame] | 851 | } |
| 852 | |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 853 | template <typename ConcatWorkloadType, armnn::DataType DataType> |
| 854 | static void RefCreateConcatWorkloadTest(const armnn::TensorShape& outputShape, |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 855 | unsigned int concatAxis) |
| 856 | { |
| 857 | Graph graph; |
Matthew Bentham | 7c1603a | 2019-06-21 17:22:23 +0100 | [diff] [blame] | 858 | RefWorkloadFactory factory = GetFactory(); |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 859 | auto workload = CreateConcatWorkloadTest<ConcatWorkloadType, DataType>(factory, graph, outputShape, concatAxis); |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 860 | |
| 861 | CheckInputsOutput(std::move(workload), |
| 862 | TensorInfo({ 2, 3, 2, 5 }, DataType), |
| 863 | TensorInfo({ 2, 3, 2, 5 }, DataType), |
| 864 | TensorInfo(outputShape, DataType)); |
| 865 | } |
| 866 | |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 867 | BOOST_AUTO_TEST_CASE(CreateConcatDim0Float32Workload) |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 868 | { |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 869 | RefCreateConcatWorkloadTest<RefConcatWorkload, armnn::DataType::Float32>({ 4, 3, 2, 5 }, 0); |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 870 | } |
| 871 | |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 872 | BOOST_AUTO_TEST_CASE(CreateConcatDim0Float16Workload) |
| 873 | { |
| 874 | RefCreateConcatWorkloadTest<RefConcatWorkload, armnn::DataType::Float16>({ 4, 3, 2, 5 }, 0); |
| 875 | } |
| 876 | |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 877 | BOOST_AUTO_TEST_CASE(CreateConcatDim0Uint8Workload) |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 878 | { |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 879 | RefCreateConcatWorkloadTest<RefConcatWorkload, armnn::DataType::QAsymmU8>({ 4, 3, 2, 5 }, 0); |
Jim Flynn | cbb66aa | 2019-05-15 13:03:54 +0100 | [diff] [blame] | 880 | } |
| 881 | |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 882 | BOOST_AUTO_TEST_CASE(CreateConcatDim0Uint16Workload) |
Jim Flynn | cbb66aa | 2019-05-15 13:03:54 +0100 | [diff] [blame] | 883 | { |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 884 | RefCreateConcatWorkloadTest<RefConcatWorkload, armnn::DataType::QSymmS16>({ 4, 3, 2, 5 }, 0); |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 885 | } |
| 886 | |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 887 | BOOST_AUTO_TEST_CASE(CreateConcatDim1Float32Workload) |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 888 | { |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 889 | RefCreateConcatWorkloadTest<RefConcatWorkload, armnn::DataType::Float32>({ 2, 6, 2, 5 }, 1); |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 890 | } |
| 891 | |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 892 | BOOST_AUTO_TEST_CASE(CreateConcatDim1Uint8Workload) |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 893 | { |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 894 | RefCreateConcatWorkloadTest<RefConcatWorkload, armnn::DataType::QAsymmU8>({ 2, 6, 2, 5 }, 1); |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 895 | } |
| 896 | |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 897 | BOOST_AUTO_TEST_CASE(CreateConcatDim2Float32Workload) |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 898 | { |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 899 | RefCreateConcatWorkloadTest<RefConcatWorkload, armnn::DataType::Float32>({ 2, 3, 4, 5 }, 2); |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 900 | } |
| 901 | |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 902 | BOOST_AUTO_TEST_CASE(CreateConcatDim2Uint8Workload) |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 903 | { |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 904 | RefCreateConcatWorkloadTest<RefConcatWorkload, armnn::DataType::QAsymmU8>({ 2, 3, 4, 5 }, 2); |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 905 | } |
| 906 | |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 907 | BOOST_AUTO_TEST_CASE(CreateConcatDim3Float32Workload) |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 908 | { |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 909 | RefCreateConcatWorkloadTest<RefConcatWorkload, armnn::DataType::Float32>({ 2, 3, 2, 10 }, 3); |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 910 | } |
| 911 | |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 912 | BOOST_AUTO_TEST_CASE(CreateConcatDim3Uint8Workload) |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 913 | { |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 914 | RefCreateConcatWorkloadTest<RefConcatWorkload, armnn::DataType::QAsymmU8>({ 2, 3, 2, 10 }, 3); |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 915 | } |
| 916 | |
Nina Drozd | 58ef2c6 | 2019-05-16 12:09:18 +0100 | [diff] [blame] | 917 | template <typename ConstantWorkloadType, armnn::DataType DataType> |
| 918 | static void RefCreateConstantWorkloadTest(const armnn::TensorShape& outputShape) |
| 919 | { |
| 920 | armnn::Graph graph; |
Matthew Bentham | 7c1603a | 2019-06-21 17:22:23 +0100 | [diff] [blame] | 921 | RefWorkloadFactory factory = GetFactory(); |
Nina Drozd | 58ef2c6 | 2019-05-16 12:09:18 +0100 | [diff] [blame] | 922 | auto workload = CreateConstantWorkloadTest<ConstantWorkloadType, DataType>(factory, graph, outputShape); |
| 923 | |
| 924 | // Check output is as expected |
| 925 | auto queueDescriptor = workload->GetData(); |
Jan Eilers | bb446e5 | 2020-04-02 13:56:54 +0100 | [diff] [blame] | 926 | auto outputHandle = PolymorphicDowncast<RefTensorHandle*>(queueDescriptor.m_Outputs[0]); |
Nina Drozd | 58ef2c6 | 2019-05-16 12:09:18 +0100 | [diff] [blame] | 927 | BOOST_TEST((outputHandle->GetTensorInfo() == TensorInfo(outputShape, DataType))); |
| 928 | } |
| 929 | |
| 930 | BOOST_AUTO_TEST_CASE(CreateConstantUint8Workload) |
| 931 | { |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 932 | RefCreateConstantWorkloadTest<RefConstantWorkload, armnn::DataType::QAsymmU8>({ 2, 3, 2, 10 }); |
Nina Drozd | 58ef2c6 | 2019-05-16 12:09:18 +0100 | [diff] [blame] | 933 | } |
| 934 | |
| 935 | BOOST_AUTO_TEST_CASE(CreateConstantInt16Workload) |
| 936 | { |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 937 | RefCreateConstantWorkloadTest<RefConstantWorkload, armnn::DataType::QSymmS16>({ 2, 3, 2, 10 }); |
Nina Drozd | 58ef2c6 | 2019-05-16 12:09:18 +0100 | [diff] [blame] | 938 | } |
| 939 | |
| 940 | BOOST_AUTO_TEST_CASE(CreateConstantFloat32Workload) |
| 941 | { |
| 942 | RefCreateConstantWorkloadTest<RefConstantWorkload, armnn::DataType::Float32>({ 2, 3, 2, 10 }); |
| 943 | } |
| 944 | |
| 945 | BOOST_AUTO_TEST_CASE(CreateConstantSigned32Workload) |
| 946 | { |
| 947 | RefCreateConstantWorkloadTest<RefConstantWorkload, armnn::DataType::Signed32>({ 2, 3, 2, 10 }); |
| 948 | } |
| 949 | |
Matteo Martincigh | bf0e722 | 2019-06-20 17:17:45 +0100 | [diff] [blame] | 950 | static void RefCreatePreluWorkloadTest(const armnn::TensorShape& inputShape, |
| 951 | const armnn::TensorShape& alphaShape, |
| 952 | const armnn::TensorShape& outputShape, |
| 953 | armnn::DataType dataType) |
Matteo Martincigh | ab9e525 | 2019-06-13 17:27:46 +0100 | [diff] [blame] | 954 | { |
| 955 | armnn::Graph graph; |
| 956 | RefWorkloadFactory factory; |
Matteo Martincigh | bf0e722 | 2019-06-20 17:17:45 +0100 | [diff] [blame] | 957 | auto workload = CreatePreluWorkloadTest<RefPreluWorkload>(factory, |
| 958 | graph, |
| 959 | inputShape, |
| 960 | alphaShape, |
| 961 | outputShape, |
| 962 | dataType); |
Matteo Martincigh | ab9e525 | 2019-06-13 17:27:46 +0100 | [diff] [blame] | 963 | |
| 964 | // Check output is as expected |
| 965 | auto queueDescriptor = workload->GetData(); |
Jan Eilers | bb446e5 | 2020-04-02 13:56:54 +0100 | [diff] [blame] | 966 | auto outputHandle = PolymorphicDowncast<RefTensorHandle*>(queueDescriptor.m_Outputs[0]); |
Matteo Martincigh | bf0e722 | 2019-06-20 17:17:45 +0100 | [diff] [blame] | 967 | BOOST_TEST((outputHandle->GetTensorInfo() == TensorInfo(outputShape, dataType))); |
Matteo Martincigh | ab9e525 | 2019-06-13 17:27:46 +0100 | [diff] [blame] | 968 | } |
| 969 | |
| 970 | BOOST_AUTO_TEST_CASE(CreatePreluFloat32Workload) |
| 971 | { |
Matteo Martincigh | bf0e722 | 2019-06-20 17:17:45 +0100 | [diff] [blame] | 972 | RefCreatePreluWorkloadTest({ 1, 4, 1, 2 }, { 5, 4, 3, 1 }, { 5, 4, 3, 2 }, armnn::DataType::Float32); |
Matteo Martincigh | ab9e525 | 2019-06-13 17:27:46 +0100 | [diff] [blame] | 973 | } |
| 974 | |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 975 | BOOST_AUTO_TEST_CASE(CreatePreluFloat16Workload) |
| 976 | { |
| 977 | RefCreatePreluWorkloadTest({ 1, 4, 1, 2 }, { 5, 4, 3, 1 }, { 5, 4, 3, 2 }, armnn::DataType::Float16); |
| 978 | } |
| 979 | |
Matteo Martincigh | ab9e525 | 2019-06-13 17:27:46 +0100 | [diff] [blame] | 980 | BOOST_AUTO_TEST_CASE(CreatePreluUint8Workload) |
| 981 | { |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 982 | RefCreatePreluWorkloadTest({ 1, 4, 1, 2 }, { 5, 4, 3, 1 }, { 5, 4, 3, 2 }, armnn::DataType::QAsymmU8); |
Matteo Martincigh | ab9e525 | 2019-06-13 17:27:46 +0100 | [diff] [blame] | 983 | } |
| 984 | |
| 985 | BOOST_AUTO_TEST_CASE(CreatePreluInt16Workload) |
| 986 | { |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 987 | RefCreatePreluWorkloadTest({ 1, 4, 1, 2 }, { 5, 4, 3, 1 }, { 5, 4, 3, 2 }, armnn::DataType::QSymmS16); |
Matteo Martincigh | bf0e722 | 2019-06-20 17:17:45 +0100 | [diff] [blame] | 988 | } |
| 989 | |
| 990 | BOOST_AUTO_TEST_CASE(CreatePreluFloat32NoBroadcastWorkload) |
| 991 | { |
| 992 | BOOST_CHECK_THROW(RefCreatePreluWorkloadTest({ 1, 4, 7, 2 }, { 5, 4, 3, 1 }, { 5, 4, 3, 2 }, |
| 993 | armnn::DataType::Float32), |
| 994 | armnn::InvalidArgumentException); |
| 995 | } |
| 996 | |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 997 | BOOST_AUTO_TEST_CASE(CreatePreluFloat16NoBroadcastWorkload) |
| 998 | { |
| 999 | BOOST_CHECK_THROW(RefCreatePreluWorkloadTest({ 1, 4, 7, 2 }, { 5, 4, 3, 1 }, { 5, 4, 3, 2 }, |
| 1000 | armnn::DataType::Float16), |
| 1001 | armnn::InvalidArgumentException); |
| 1002 | } |
| 1003 | |
Matteo Martincigh | bf0e722 | 2019-06-20 17:17:45 +0100 | [diff] [blame] | 1004 | BOOST_AUTO_TEST_CASE(CreatePreluUint8NoBroadcastWorkload) |
| 1005 | { |
| 1006 | BOOST_CHECK_THROW(RefCreatePreluWorkloadTest({ 1, 4, 7, 2 }, { 5, 4, 3, 1 }, { 5, 4, 3, 2 }, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 1007 | armnn::DataType::QAsymmU8), |
Matteo Martincigh | bf0e722 | 2019-06-20 17:17:45 +0100 | [diff] [blame] | 1008 | armnn::InvalidArgumentException); |
| 1009 | } |
| 1010 | |
| 1011 | BOOST_AUTO_TEST_CASE(CreatePreluInt16NoBroadcastWorkload) |
| 1012 | { |
| 1013 | BOOST_CHECK_THROW(RefCreatePreluWorkloadTest({ 1, 4, 7, 2 }, { 5, 4, 3, 1 }, { 5, 4, 3, 2 }, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 1014 | armnn::DataType::QSymmS16), |
Matteo Martincigh | bf0e722 | 2019-06-20 17:17:45 +0100 | [diff] [blame] | 1015 | armnn::InvalidArgumentException); |
Matteo Martincigh | ab9e525 | 2019-06-13 17:27:46 +0100 | [diff] [blame] | 1016 | } |
| 1017 | |
James Conroy | 6059784 | 2019-07-02 10:57:56 +0100 | [diff] [blame] | 1018 | template <typename SpaceToDepthWorkloadType, armnn::DataType DataType> |
| 1019 | static void RefCreateSpaceToDepthWorkloadTest() |
| 1020 | { |
| 1021 | Graph graph; |
| 1022 | RefWorkloadFactory factory; |
| 1023 | |
| 1024 | auto workload = CreateSpaceToDepthWorkloadTest<SpaceToDepthWorkloadType, DataType>(factory, graph); |
| 1025 | |
| 1026 | CheckInputOutput(std::move(workload), |
| 1027 | TensorInfo({ 1, 2, 2, 1 }, DataType), |
| 1028 | TensorInfo({ 1, 1, 1, 4 }, DataType)); |
| 1029 | } |
| 1030 | |
| 1031 | BOOST_AUTO_TEST_CASE(CreateSpaceToDepthWorkloadFloat32) |
| 1032 | { |
| 1033 | RefCreateSpaceToDepthWorkloadTest<RefSpaceToDepthWorkload, armnn::DataType::Float32>(); |
| 1034 | } |
| 1035 | |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 1036 | BOOST_AUTO_TEST_CASE(CreateSpaceToDepthWorkloadFloat16) |
| 1037 | { |
| 1038 | RefCreateSpaceToDepthWorkloadTest<RefSpaceToDepthWorkload, armnn::DataType::Float16>(); |
| 1039 | } |
| 1040 | |
James Conroy | 6059784 | 2019-07-02 10:57:56 +0100 | [diff] [blame] | 1041 | BOOST_AUTO_TEST_CASE(CreateSpaceToDepthWorkloadQASymm8) |
| 1042 | { |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 1043 | RefCreateSpaceToDepthWorkloadTest<RefSpaceToDepthWorkload, armnn::DataType::QAsymmU8>(); |
James Conroy | 6059784 | 2019-07-02 10:57:56 +0100 | [diff] [blame] | 1044 | } |
| 1045 | |
| 1046 | BOOST_AUTO_TEST_CASE(CreateSpaceToDepthWorkloadQSymm16) |
| 1047 | { |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 1048 | RefCreateSpaceToDepthWorkloadTest<RefSpaceToDepthWorkload, armnn::DataType::QSymmS16>(); |
James Conroy | 6059784 | 2019-07-02 10:57:56 +0100 | [diff] [blame] | 1049 | } |
| 1050 | |
Matthew Jackson | d516610 | 2019-07-31 14:06:28 +0100 | [diff] [blame] | 1051 | template <armnn::DataType DataType> |
Matthew Jackson | 81e601c | 2019-07-11 12:07:09 +0100 | [diff] [blame] | 1052 | static void RefCreateStackWorkloadTest(const armnn::TensorShape& inputShape, |
| 1053 | const armnn::TensorShape& outputShape, |
| 1054 | unsigned int axis, |
Matthew Jackson | d516610 | 2019-07-31 14:06:28 +0100 | [diff] [blame] | 1055 | unsigned int numInputs) |
Matthew Jackson | 81e601c | 2019-07-11 12:07:09 +0100 | [diff] [blame] | 1056 | { |
| 1057 | armnn::Graph graph; |
| 1058 | RefWorkloadFactory factory; |
Matthew Jackson | d516610 | 2019-07-31 14:06:28 +0100 | [diff] [blame] | 1059 | auto workload = CreateStackWorkloadTest<RefStackWorkload, DataType>(factory, |
| 1060 | graph, |
| 1061 | inputShape, |
| 1062 | outputShape, |
| 1063 | axis, |
| 1064 | numInputs); |
Matthew Jackson | 81e601c | 2019-07-11 12:07:09 +0100 | [diff] [blame] | 1065 | |
Matthew Jackson | d516610 | 2019-07-31 14:06:28 +0100 | [diff] [blame] | 1066 | // Check inputs and output are as expected |
| 1067 | StackQueueDescriptor queueDescriptor = workload->GetData(); |
| 1068 | for (unsigned int i = 0; i < numInputs; ++i) |
| 1069 | { |
Jan Eilers | bb446e5 | 2020-04-02 13:56:54 +0100 | [diff] [blame] | 1070 | auto inputHandle = PolymorphicDowncast<RefTensorHandle*>(queueDescriptor.m_Inputs[i]); |
Matthew Jackson | d516610 | 2019-07-31 14:06:28 +0100 | [diff] [blame] | 1071 | BOOST_TEST((inputHandle->GetTensorInfo() == TensorInfo(inputShape, DataType))); |
| 1072 | } |
Jan Eilers | bb446e5 | 2020-04-02 13:56:54 +0100 | [diff] [blame] | 1073 | auto outputHandle = PolymorphicDowncast<RefTensorHandle*>(queueDescriptor.m_Outputs[0]); |
Matthew Jackson | d516610 | 2019-07-31 14:06:28 +0100 | [diff] [blame] | 1074 | BOOST_TEST((outputHandle->GetTensorInfo() == TensorInfo(outputShape, DataType))); |
Matthew Jackson | 81e601c | 2019-07-11 12:07:09 +0100 | [diff] [blame] | 1075 | } |
| 1076 | |
| 1077 | BOOST_AUTO_TEST_CASE(CreateStackFloat32Workload) |
| 1078 | { |
Matthew Jackson | d516610 | 2019-07-31 14:06:28 +0100 | [diff] [blame] | 1079 | RefCreateStackWorkloadTest<armnn::DataType::Float32>({ 3, 4, 5 }, { 3, 4, 2, 5 }, 2, 2); |
Matthew Jackson | 81e601c | 2019-07-11 12:07:09 +0100 | [diff] [blame] | 1080 | } |
| 1081 | |
| 1082 | BOOST_AUTO_TEST_CASE(CreateStackUint8Workload) |
| 1083 | { |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 1084 | RefCreateStackWorkloadTest<armnn::DataType::QAsymmU8>({ 3, 4, 5 }, { 3, 4, 2, 5 }, 2, 2); |
Matthew Jackson | 81e601c | 2019-07-11 12:07:09 +0100 | [diff] [blame] | 1085 | } |
| 1086 | |
| 1087 | BOOST_AUTO_TEST_CASE(CreateStackUint16Workload) |
| 1088 | { |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 1089 | RefCreateStackWorkloadTest<armnn::DataType::QSymmS16>({ 3, 4, 5 }, { 3, 4, 2, 5 }, 2, 2); |
Matthew Jackson | 81e601c | 2019-07-11 12:07:09 +0100 | [diff] [blame] | 1090 | } |
| 1091 | |
James Conroy | 4f1f899 | 2020-04-29 20:01:10 +0100 | [diff] [blame] | 1092 | template <typename QLstmWorkloadType> |
| 1093 | static void RefCreateQLstmWorkloadTest() |
| 1094 | { |
| 1095 | Graph graph; |
| 1096 | RefWorkloadFactory factory; |
| 1097 | |
| 1098 | auto workload = CreateQLstmWorkloadTest<QLstmWorkloadType>(factory, graph); |
| 1099 | |
| 1100 | armnn::TensorInfo inputInfo({2 , 4}, armnn::DataType::QAsymmS8, 0.0078125f, 0); |
| 1101 | |
| 1102 | armnn::TensorInfo cellStateInfo({2 , 4}, armnn::DataType::QSymmS16, 3.05176e-05f, 0); |
| 1103 | |
| 1104 | armnn::TensorInfo outputInfo({2 , 4}, armnn::DataType::QAsymmS8, 0.007f, 0); |
| 1105 | |
| 1106 | QLstmQueueDescriptor queueDescriptor = workload->GetData(); |
| 1107 | auto inputHandle = boost::polymorphic_downcast<RefTensorHandle*>(queueDescriptor.m_Inputs[0]); |
| 1108 | auto cellStateOutHandle = boost::polymorphic_downcast<RefTensorHandle*>(queueDescriptor.m_Outputs[1]); |
| 1109 | auto outputHandle = boost::polymorphic_downcast<RefTensorHandle*>(queueDescriptor.m_Outputs[2]); |
| 1110 | |
| 1111 | BOOST_TEST((inputHandle->GetTensorInfo() == inputInfo)); |
| 1112 | BOOST_TEST((cellStateOutHandle->GetTensorInfo() == cellStateInfo)); |
| 1113 | BOOST_TEST((outputHandle->GetTensorInfo() == outputInfo)); |
| 1114 | } |
| 1115 | |
| 1116 | BOOST_AUTO_TEST_CASE(CreateQLstmWorkloadTest) |
| 1117 | { |
| 1118 | RefCreateQLstmWorkloadTest<RefQLstmWorkload>(); |
| 1119 | } |
| 1120 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1121 | BOOST_AUTO_TEST_SUITE_END() |