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