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 | 5605519 | 2018-11-12 18:10:43 +0000 | [diff] [blame] | 6 | #include "NeonWorkloadFactoryHelper.hpp" |
| 7 | |
Francis Murtagh | 4fc3c48 | 2019-08-02 13:20:54 +0100 | [diff] [blame] | 8 | #include <aclCommon/ArmComputeTensorUtils.hpp> |
Aron Virginas-Tar | c9cc804 | 2018-11-01 16:15:57 +0000 | [diff] [blame] | 9 | #include <backendsCommon/MemCopyWorkload.hpp> |
Aron Virginas-Tar | 3b278e9 | 2018-10-12 13:00:55 +0100 | [diff] [blame] | 10 | |
Aron Virginas-Tar | c9cc804 | 2018-11-01 16:15:57 +0000 | [diff] [blame] | 11 | #include <aclCommon/test/CreateWorkloadClNeon.hpp> |
Aron Virginas-Tar | 3b278e9 | 2018-10-12 13:00:55 +0100 | [diff] [blame] | 12 | |
Aron Virginas-Tar | c9cc804 | 2018-11-01 16:15:57 +0000 | [diff] [blame] | 13 | #include <neon/NeonWorkloadFactory.hpp> |
| 14 | #include <neon/NeonTensorHandle.hpp> |
| 15 | #include <neon/workloads/NeonWorkloadUtils.hpp> |
| 16 | #include <neon/workloads/NeonWorkloads.hpp> |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 17 | |
| 18 | BOOST_AUTO_TEST_SUITE(CreateWorkloadNeon) |
| 19 | |
| 20 | namespace |
| 21 | { |
| 22 | |
Ellen Norris-Thompson | 37e6868 | 2019-07-15 14:23:30 +0100 | [diff] [blame] | 23 | boost::test_tools::predicate_result CompareIAclTensorHandleShape(IAclTensorHandle* tensorHandle, |
| 24 | std::initializer_list<unsigned int> expectedDimensions) |
| 25 | { |
| 26 | return CompareTensorHandleShape<IAclTensorHandle>(tensorHandle, expectedDimensions); |
| 27 | } |
| 28 | |
Derek Lamberti | c81855f | 2019-06-13 17:34:19 +0100 | [diff] [blame] | 29 | bool TestNeonTensorHandleInfo(armnn::IAclTensorHandle* handle, const armnn::TensorInfo& expectedInfo) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 30 | { |
| 31 | using namespace armnn::armcomputetensorutils; |
| 32 | |
| 33 | const arm_compute::ITensorInfo* handleInfo = handle->GetTensor().info(); |
| 34 | const arm_compute::TensorInfo expectedAclInfo = BuildArmComputeTensorInfo(expectedInfo); |
| 35 | |
| 36 | if (handleInfo->data_type() != expectedAclInfo.data_type()) |
| 37 | { |
| 38 | return false; |
| 39 | } |
| 40 | |
| 41 | if (handleInfo->num_dimensions() != expectedAclInfo.num_dimensions()) |
| 42 | { |
| 43 | return false; |
| 44 | } |
| 45 | |
| 46 | if (handleInfo->quantization_info() != expectedAclInfo.quantization_info()) |
| 47 | { |
| 48 | return false; |
| 49 | } |
| 50 | |
| 51 | for (std::size_t d = 0; d < expectedAclInfo.num_dimensions(); ++d) |
| 52 | { |
| 53 | if (handleInfo->dimension(d) != expectedAclInfo.dimension(d)) |
| 54 | { |
| 55 | return false; |
| 56 | } |
| 57 | } |
| 58 | |
| 59 | return true; |
| 60 | } |
| 61 | |
| 62 | } // namespace |
| 63 | |
Nattapat Chaimanowong | d4b7059 | 2018-10-12 11:21:49 +0100 | [diff] [blame] | 64 | template <typename armnn::DataType DataType> |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 65 | static void NeonCreateActivationWorkloadTest() |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 66 | { |
| 67 | Graph graph; |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 68 | NeonWorkloadFactory factory = |
| 69 | NeonWorkloadFactoryHelper::GetFactory(NeonWorkloadFactoryHelper::GetMemoryManager()); |
| 70 | |
Nattapat Chaimanowong | d4b7059 | 2018-10-12 11:21:49 +0100 | [diff] [blame] | 71 | auto workload = CreateActivationWorkloadTest<NeonActivationWorkload, DataType>(factory, graph); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 72 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 73 | // Checks that inputs/outputs are as we expect them (see definition of CreateActivationWorkloadTest). |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 74 | ActivationQueueDescriptor queueDescriptor = workload->GetData(); |
Derek Lamberti | c81855f | 2019-06-13 17:34:19 +0100 | [diff] [blame] | 75 | auto inputHandle = boost::polymorphic_downcast<IAclTensorHandle*>(queueDescriptor.m_Inputs[0]); |
| 76 | auto outputHandle = boost::polymorphic_downcast<IAclTensorHandle*>(queueDescriptor.m_Outputs[0]); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 77 | BOOST_TEST(TestNeonTensorHandleInfo(inputHandle, TensorInfo({1, 1}, DataType))); |
| 78 | BOOST_TEST(TestNeonTensorHandleInfo(outputHandle, TensorInfo({1, 1}, DataType))); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 79 | } |
| 80 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 81 | #ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC |
| 82 | BOOST_AUTO_TEST_CASE(CreateActivationFloat16Workload) |
| 83 | { |
Nattapat Chaimanowong | d4b7059 | 2018-10-12 11:21:49 +0100 | [diff] [blame] | 84 | NeonCreateActivationWorkloadTest<DataType::Float16>(); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 85 | } |
| 86 | #endif |
| 87 | |
arovir01 | 9e53a35 | 2018-08-31 15:26:35 +0100 | [diff] [blame] | 88 | BOOST_AUTO_TEST_CASE(CreateActivationFloatWorkload) |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 89 | { |
Nattapat Chaimanowong | d4b7059 | 2018-10-12 11:21:49 +0100 | [diff] [blame] | 90 | NeonCreateActivationWorkloadTest<DataType::Float32>(); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 91 | } |
| 92 | |
David Beck | bc39245 | 2018-09-10 14:47:28 +0100 | [diff] [blame] | 93 | template <typename WorkloadType, |
| 94 | typename DescriptorType, |
| 95 | typename LayerType, |
| 96 | armnn::DataType DataType> |
Éanna Ó Catháin | d57415d | 2018-11-28 16:24:38 +0000 | [diff] [blame] | 97 | static void NeonCreateElementwiseWorkloadTest() |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 98 | { |
David Beck | bc39245 | 2018-09-10 14:47:28 +0100 | [diff] [blame] | 99 | Graph graph; |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 100 | NeonWorkloadFactory factory = |
| 101 | NeonWorkloadFactoryHelper::GetFactory(NeonWorkloadFactoryHelper::GetMemoryManager()); |
| 102 | |
Éanna Ó Catháin | d57415d | 2018-11-28 16:24:38 +0000 | [diff] [blame] | 103 | auto workload = CreateElementwiseWorkloadTest<WorkloadType, DescriptorType, LayerType, DataType>(factory, graph); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 104 | |
David Beck | bc39245 | 2018-09-10 14:47:28 +0100 | [diff] [blame] | 105 | DescriptorType queueDescriptor = workload->GetData(); |
Derek Lamberti | c81855f | 2019-06-13 17:34:19 +0100 | [diff] [blame] | 106 | auto inputHandle1 = boost::polymorphic_downcast<IAclTensorHandle*>(queueDescriptor.m_Inputs[0]); |
| 107 | auto inputHandle2 = boost::polymorphic_downcast<IAclTensorHandle*>(queueDescriptor.m_Inputs[1]); |
| 108 | auto outputHandle = boost::polymorphic_downcast<IAclTensorHandle*>(queueDescriptor.m_Outputs[0]); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 109 | BOOST_TEST(TestNeonTensorHandleInfo(inputHandle1, TensorInfo({2, 3}, DataType))); |
| 110 | BOOST_TEST(TestNeonTensorHandleInfo(inputHandle2, TensorInfo({2, 3}, DataType))); |
| 111 | BOOST_TEST(TestNeonTensorHandleInfo(outputHandle, TensorInfo({2, 3}, DataType))); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 112 | } |
| 113 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 114 | #ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC |
| 115 | BOOST_AUTO_TEST_CASE(CreateAdditionFloat16Workload) |
| 116 | { |
Matthew Bentham | 955258d | 2018-12-10 10:48:52 +0000 | [diff] [blame] | 117 | NeonCreateElementwiseWorkloadTest<NeonAdditionWorkload, |
David Beck | bc39245 | 2018-09-10 14:47:28 +0100 | [diff] [blame] | 118 | AdditionQueueDescriptor, |
| 119 | AdditionLayer, |
| 120 | DataType::Float16>(); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 121 | } |
| 122 | #endif |
| 123 | |
arovir01 | 9e53a35 | 2018-08-31 15:26:35 +0100 | [diff] [blame] | 124 | BOOST_AUTO_TEST_CASE(CreateAdditionFloatWorkload) |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 125 | { |
Matthew Bentham | 955258d | 2018-12-10 10:48:52 +0000 | [diff] [blame] | 126 | NeonCreateElementwiseWorkloadTest<NeonAdditionWorkload, |
David Beck | bc39245 | 2018-09-10 14:47:28 +0100 | [diff] [blame] | 127 | AdditionQueueDescriptor, |
| 128 | AdditionLayer, |
| 129 | DataType::Float32>(); |
| 130 | } |
| 131 | |
| 132 | #ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC |
| 133 | BOOST_AUTO_TEST_CASE(CreateSubtractionFloat16Workload) |
| 134 | { |
Conor Kennedy | b99480b | 2019-03-08 08:24:41 +0000 | [diff] [blame] | 135 | NeonCreateElementwiseWorkloadTest<NeonSubtractionWorkload, |
David Beck | bc39245 | 2018-09-10 14:47:28 +0100 | [diff] [blame] | 136 | SubtractionQueueDescriptor, |
| 137 | SubtractionLayer, |
| 138 | DataType::Float16>(); |
| 139 | } |
| 140 | #endif |
| 141 | |
| 142 | BOOST_AUTO_TEST_CASE(CreateSubtractionFloatWorkload) |
| 143 | { |
Conor Kennedy | b99480b | 2019-03-08 08:24:41 +0000 | [diff] [blame] | 144 | NeonCreateElementwiseWorkloadTest<NeonSubtractionWorkload, |
David Beck | bc39245 | 2018-09-10 14:47:28 +0100 | [diff] [blame] | 145 | SubtractionQueueDescriptor, |
| 146 | SubtractionLayer, |
| 147 | DataType::Float32>(); |
| 148 | } |
| 149 | |
Conor Kennedy | b99480b | 2019-03-08 08:24:41 +0000 | [diff] [blame] | 150 | BOOST_AUTO_TEST_CASE(CreateSubtractionUint8Workload) |
| 151 | { |
| 152 | NeonCreateElementwiseWorkloadTest<NeonSubtractionWorkload, |
| 153 | SubtractionQueueDescriptor, |
| 154 | SubtractionLayer, |
| 155 | DataType::QuantisedAsymm8>(); |
| 156 | } |
| 157 | |
David Beck | bc39245 | 2018-09-10 14:47:28 +0100 | [diff] [blame] | 158 | #ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC |
| 159 | BOOST_AUTO_TEST_CASE(CreateMultiplicationFloat16Workload) |
| 160 | { |
Conor Kennedy | b99480b | 2019-03-08 08:24:41 +0000 | [diff] [blame] | 161 | NeonCreateElementwiseWorkloadTest<NeonMultiplicationWorkload, |
David Beck | bc39245 | 2018-09-10 14:47:28 +0100 | [diff] [blame] | 162 | MultiplicationQueueDescriptor, |
| 163 | MultiplicationLayer, |
| 164 | DataType::Float16>(); |
| 165 | } |
| 166 | #endif |
| 167 | |
| 168 | BOOST_AUTO_TEST_CASE(CreateMultiplicationFloatWorkload) |
| 169 | { |
Conor Kennedy | b99480b | 2019-03-08 08:24:41 +0000 | [diff] [blame] | 170 | NeonCreateElementwiseWorkloadTest<NeonMultiplicationWorkload, |
David Beck | bc39245 | 2018-09-10 14:47:28 +0100 | [diff] [blame] | 171 | MultiplicationQueueDescriptor, |
| 172 | MultiplicationLayer, |
| 173 | DataType::Float32>(); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 174 | } |
| 175 | |
Conor Kennedy | b99480b | 2019-03-08 08:24:41 +0000 | [diff] [blame] | 176 | BOOST_AUTO_TEST_CASE(CreateMultiplicationUint8Workload) |
| 177 | { |
| 178 | NeonCreateElementwiseWorkloadTest<NeonMultiplicationWorkload, |
| 179 | MultiplicationQueueDescriptor, |
| 180 | MultiplicationLayer, |
| 181 | DataType::QuantisedAsymm8>(); |
| 182 | } |
| 183 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 184 | template <typename BatchNormalizationWorkloadType, typename armnn::DataType DataType> |
Nikhil Raj | d134093 | 2018-10-18 14:27:50 +0100 | [diff] [blame] | 185 | static void NeonCreateBatchNormalizationWorkloadTest(DataLayout dataLayout) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 186 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 187 | Graph graph; |
| 188 | NeonWorkloadFactory factory = |
| 189 | NeonWorkloadFactoryHelper::GetFactory(NeonWorkloadFactoryHelper::GetMemoryManager()); |
| 190 | |
Nikhil Raj | d134093 | 2018-10-18 14:27:50 +0100 | [diff] [blame] | 191 | auto workload = CreateBatchNormalizationWorkloadTest<BatchNormalizationWorkloadType, DataType> |
| 192 | (factory, graph, dataLayout); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 193 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 194 | // Checks that outputs and inputs are as we expect them (see definition of CreateBatchNormalizationWorkloadTest). |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 195 | BatchNormalizationQueueDescriptor queueDescriptor = workload->GetData(); |
Derek Lamberti | c81855f | 2019-06-13 17:34:19 +0100 | [diff] [blame] | 196 | auto inputHandle = boost::polymorphic_downcast<IAclTensorHandle*>(queueDescriptor.m_Inputs[0]); |
| 197 | auto outputHandle = boost::polymorphic_downcast<IAclTensorHandle*>(queueDescriptor.m_Outputs[0]); |
Nikhil Raj | d134093 | 2018-10-18 14:27:50 +0100 | [diff] [blame] | 198 | |
| 199 | TensorShape inputShape = (dataLayout == DataLayout::NCHW) ? TensorShape{2, 3, 4, 4} : TensorShape{2, 4, 4, 3}; |
| 200 | TensorShape outputShape = (dataLayout == DataLayout::NCHW) ? TensorShape{2, 3, 4, 4} : TensorShape{2, 4, 4, 3}; |
| 201 | |
| 202 | BOOST_TEST(TestNeonTensorHandleInfo(inputHandle, TensorInfo(inputShape, DataType))); |
| 203 | BOOST_TEST(TestNeonTensorHandleInfo(outputHandle, TensorInfo(outputShape, DataType))); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 204 | } |
| 205 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 206 | #ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC |
Nikhil Raj | d134093 | 2018-10-18 14:27:50 +0100 | [diff] [blame] | 207 | BOOST_AUTO_TEST_CASE(CreateBatchNormalizationFloat16NchwWorkload) |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 208 | { |
Matthew Bentham | c48ac8c | 2018-12-12 16:15:59 +0000 | [diff] [blame] | 209 | NeonCreateBatchNormalizationWorkloadTest<NeonBatchNormalizationWorkload, DataType::Float16>(DataLayout::NCHW); |
Nikhil Raj | d134093 | 2018-10-18 14:27:50 +0100 | [diff] [blame] | 210 | } |
| 211 | |
| 212 | BOOST_AUTO_TEST_CASE(CreateBatchNormalizationFloat16NhwcWorkload) |
| 213 | { |
Matthew Bentham | c48ac8c | 2018-12-12 16:15:59 +0000 | [diff] [blame] | 214 | NeonCreateBatchNormalizationWorkloadTest<NeonBatchNormalizationWorkload, DataType::Float16>(DataLayout::NHWC); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 215 | } |
| 216 | #endif |
| 217 | |
Nikhil Raj | d134093 | 2018-10-18 14:27:50 +0100 | [diff] [blame] | 218 | BOOST_AUTO_TEST_CASE(CreateBatchNormalizationFloatNchwWorkload) |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 219 | { |
Matthew Bentham | c48ac8c | 2018-12-12 16:15:59 +0000 | [diff] [blame] | 220 | NeonCreateBatchNormalizationWorkloadTest<NeonBatchNormalizationWorkload, DataType::Float32>(DataLayout::NCHW); |
Nikhil Raj | d134093 | 2018-10-18 14:27:50 +0100 | [diff] [blame] | 221 | } |
| 222 | |
| 223 | BOOST_AUTO_TEST_CASE(CreateBatchNormalizationFloatNhwcWorkload) |
| 224 | { |
Matthew Bentham | c48ac8c | 2018-12-12 16:15:59 +0000 | [diff] [blame] | 225 | NeonCreateBatchNormalizationWorkloadTest<NeonBatchNormalizationWorkload, DataType::Float32>(DataLayout::NHWC); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 226 | } |
| 227 | |
Nattapat Chaimanowong | 974b65f | 2018-10-15 15:07:34 +0100 | [diff] [blame] | 228 | template <typename armnn::DataType DataType> |
Francis Murtagh | 0d9d419 | 2018-10-09 16:22:33 +0100 | [diff] [blame] | 229 | static void NeonCreateConvolution2dWorkloadTest(DataLayout dataLayout = DataLayout::NCHW) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 230 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 231 | Graph graph; |
| 232 | NeonWorkloadFactory factory = |
| 233 | NeonWorkloadFactoryHelper::GetFactory(NeonWorkloadFactoryHelper::GetMemoryManager()); |
| 234 | |
| 235 | auto workload = CreateConvolution2dWorkloadTest<NeonConvolution2dWorkload, DataType>(factory, graph, dataLayout); |
Francis Murtagh | 0d9d419 | 2018-10-09 16:22:33 +0100 | [diff] [blame] | 236 | |
| 237 | TensorShape inputShape = (dataLayout == DataLayout::NCHW) ? TensorShape{2, 3, 8, 16} : TensorShape{2, 8, 16, 3}; |
| 238 | TensorShape outputShape = (dataLayout == DataLayout::NCHW) ? TensorShape{2, 2, 2, 10} : TensorShape{2, 2, 10, 2}; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 239 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 240 | // 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] | 241 | Convolution2dQueueDescriptor queueDescriptor = workload->GetData(); |
Derek Lamberti | c81855f | 2019-06-13 17:34:19 +0100 | [diff] [blame] | 242 | auto inputHandle = boost::polymorphic_downcast<IAclTensorHandle*>(queueDescriptor.m_Inputs[0]); |
| 243 | auto outputHandle = boost::polymorphic_downcast<IAclTensorHandle*>(queueDescriptor.m_Outputs[0]); |
Francis Murtagh | 0d9d419 | 2018-10-09 16:22:33 +0100 | [diff] [blame] | 244 | BOOST_TEST(TestNeonTensorHandleInfo(inputHandle, TensorInfo(inputShape, DataType))); |
| 245 | BOOST_TEST(TestNeonTensorHandleInfo(outputHandle, TensorInfo(outputShape, DataType))); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 246 | } |
| 247 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 248 | #ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC |
Francis Murtagh | 0d9d419 | 2018-10-09 16:22:33 +0100 | [diff] [blame] | 249 | BOOST_AUTO_TEST_CASE(CreateConvolution2dFloat16NchwWorkload) |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 250 | { |
Nattapat Chaimanowong | 974b65f | 2018-10-15 15:07:34 +0100 | [diff] [blame] | 251 | NeonCreateConvolution2dWorkloadTest<DataType::Float16>(); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 252 | } |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 253 | |
Francis Murtagh | 0d9d419 | 2018-10-09 16:22:33 +0100 | [diff] [blame] | 254 | BOOST_AUTO_TEST_CASE(CreateConvolution2dFloat16NhwcWorkload) |
| 255 | { |
Nattapat Chaimanowong | 974b65f | 2018-10-15 15:07:34 +0100 | [diff] [blame] | 256 | NeonCreateConvolution2dWorkloadTest<DataType::Float16>(DataLayout::NHWC); |
Francis Murtagh | 0d9d419 | 2018-10-09 16:22:33 +0100 | [diff] [blame] | 257 | } |
| 258 | |
| 259 | #endif |
| 260 | BOOST_AUTO_TEST_CASE(CreateConvolution2dFloatNchwWorkload) |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 261 | { |
Nattapat Chaimanowong | 974b65f | 2018-10-15 15:07:34 +0100 | [diff] [blame] | 262 | NeonCreateConvolution2dWorkloadTest<DataType::Float32>(); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 263 | } |
| 264 | |
Francis Murtagh | 0d9d419 | 2018-10-09 16:22:33 +0100 | [diff] [blame] | 265 | BOOST_AUTO_TEST_CASE(CreateConvolution2dFloatNhwcWorkload) |
| 266 | { |
Nattapat Chaimanowong | 974b65f | 2018-10-15 15:07:34 +0100 | [diff] [blame] | 267 | NeonCreateConvolution2dWorkloadTest<DataType::Float32>(DataLayout::NHWC); |
Francis Murtagh | 0d9d419 | 2018-10-09 16:22:33 +0100 | [diff] [blame] | 268 | } |
| 269 | |
Nattapat Chaimanowong | 7714088 | 2018-10-17 11:12:19 +0100 | [diff] [blame] | 270 | template <typename armnn::DataType DataType> |
Nikhil Raj | cec6b65 | 2018-10-12 13:51:57 +0100 | [diff] [blame] | 271 | static void NeonCreateDepthWiseConvolutionWorkloadTest(DataLayout dataLayout) |
| 272 | { |
| 273 | Graph graph; |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 274 | NeonWorkloadFactory factory = |
| 275 | NeonWorkloadFactoryHelper::GetFactory(NeonWorkloadFactoryHelper::GetMemoryManager()); |
Nikhil Raj | cec6b65 | 2018-10-12 13:51:57 +0100 | [diff] [blame] | 276 | |
Nattapat Chaimanowong | 7714088 | 2018-10-17 11:12:19 +0100 | [diff] [blame] | 277 | auto workload = CreateDepthwiseConvolution2dWorkloadTest<NeonDepthwiseConvolutionWorkload, |
Nikhil Raj | cec6b65 | 2018-10-12 13:51:57 +0100 | [diff] [blame] | 278 | DataType>(factory, graph, dataLayout); |
| 279 | |
| 280 | // Checks that inputs/outputs are as we expect them (see definition of CreateNormalizationWorkloadTest). |
| 281 | DepthwiseConvolution2dQueueDescriptor queueDescriptor = workload->GetData(); |
Derek Lamberti | c81855f | 2019-06-13 17:34:19 +0100 | [diff] [blame] | 282 | auto inputHandle = boost::polymorphic_downcast<IAclTensorHandle*>(queueDescriptor.m_Inputs[0]); |
| 283 | auto outputHandle = boost::polymorphic_downcast<IAclTensorHandle*>(queueDescriptor.m_Outputs[0]); |
Nikhil Raj | cec6b65 | 2018-10-12 13:51:57 +0100 | [diff] [blame] | 284 | |
Mike Kelly | db48288 | 2019-06-14 12:35:24 +0100 | [diff] [blame] | 285 | TensorShape inputShape = (dataLayout == DataLayout::NCHW) ? std::initializer_list<unsigned int>({ 2, 2, 5, 5 }) |
| 286 | : std::initializer_list<unsigned int>({ 2, 5, 5, 2 }); |
| 287 | TensorShape outputShape = (dataLayout == DataLayout::NCHW) ? std::initializer_list<unsigned int>({ 2, 2, 5, 5 }) |
| 288 | : std::initializer_list<unsigned int>({ 2, 5, 5, 2 }); |
Nikhil Raj | cec6b65 | 2018-10-12 13:51:57 +0100 | [diff] [blame] | 289 | |
| 290 | BOOST_TEST(TestNeonTensorHandleInfo(inputHandle, TensorInfo(inputShape, DataType))); |
| 291 | BOOST_TEST(TestNeonTensorHandleInfo(outputHandle, TensorInfo(outputShape, DataType))); |
| 292 | } |
| 293 | |
| 294 | BOOST_AUTO_TEST_CASE(CreateDepthWiseConvolution2dFloat32NhwcWorkload) |
| 295 | { |
Nattapat Chaimanowong | 7714088 | 2018-10-17 11:12:19 +0100 | [diff] [blame] | 296 | NeonCreateDepthWiseConvolutionWorkloadTest<DataType::Float32>(DataLayout::NHWC); |
Nikhil Raj | cec6b65 | 2018-10-12 13:51:57 +0100 | [diff] [blame] | 297 | } |
| 298 | |
| 299 | #ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC |
| 300 | BOOST_AUTO_TEST_CASE(CreateDepthWiseConvolution2dFloat16NhwcWorkload) |
| 301 | { |
Nattapat Chaimanowong | 7714088 | 2018-10-17 11:12:19 +0100 | [diff] [blame] | 302 | NeonCreateDepthWiseConvolutionWorkloadTest<DataType::Float16>(DataLayout::NHWC); |
Nikhil Raj | cec6b65 | 2018-10-12 13:51:57 +0100 | [diff] [blame] | 303 | } |
| 304 | #endif |
| 305 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 306 | template <typename FullyConnectedWorkloadType, typename armnn::DataType DataType> |
| 307 | static void NeonCreateFullyConnectedWorkloadTest() |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 308 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 309 | Graph graph; |
| 310 | NeonWorkloadFactory factory = |
| 311 | NeonWorkloadFactoryHelper::GetFactory(NeonWorkloadFactoryHelper::GetMemoryManager()); |
| 312 | |
| 313 | auto workload = CreateFullyConnectedWorkloadTest<FullyConnectedWorkloadType, DataType>(factory, graph); |
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 CreateFullyConnectedWorkloadTest). |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 316 | FullyConnectedQueueDescriptor queueDescriptor = workload->GetData(); |
Derek Lamberti | c81855f | 2019-06-13 17:34:19 +0100 | [diff] [blame] | 317 | auto inputHandle = boost::polymorphic_downcast<IAclTensorHandle*>(queueDescriptor.m_Inputs[0]); |
| 318 | auto outputHandle = boost::polymorphic_downcast<IAclTensorHandle*>(queueDescriptor.m_Outputs[0]); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 319 | BOOST_TEST(TestNeonTensorHandleInfo(inputHandle, TensorInfo({3, 1, 4, 5}, DataType))); |
| 320 | BOOST_TEST(TestNeonTensorHandleInfo(outputHandle, TensorInfo({3, 7}, DataType))); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 321 | } |
| 322 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 323 | #ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC |
| 324 | BOOST_AUTO_TEST_CASE(CreateFullyConnectedFloat16Workload) |
| 325 | { |
kevmay01 | e448be3 | 2018-09-26 10:21:55 +0100 | [diff] [blame] | 326 | NeonCreateFullyConnectedWorkloadTest<NeonFullyConnectedWorkload, DataType::Float16>(); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 327 | } |
| 328 | #endif |
| 329 | |
arovir01 | 9e53a35 | 2018-08-31 15:26:35 +0100 | [diff] [blame] | 330 | BOOST_AUTO_TEST_CASE(CreateFullyConnectedFloatWorkload) |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 331 | { |
kevmay01 | e448be3 | 2018-09-26 10:21:55 +0100 | [diff] [blame] | 332 | NeonCreateFullyConnectedWorkloadTest<NeonFullyConnectedWorkload, DataType::Float32>(); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 333 | } |
| 334 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 335 | template <typename NormalizationWorkloadType, typename armnn::DataType DataType> |
narpra01 | 55a97bc | 2018-10-02 14:35:53 +0100 | [diff] [blame] | 336 | static void NeonCreateNormalizationWorkloadTest(DataLayout dataLayout) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 337 | { |
narpra01 | 55a97bc | 2018-10-02 14:35:53 +0100 | [diff] [blame] | 338 | Graph graph; |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 339 | NeonWorkloadFactory factory = |
| 340 | NeonWorkloadFactoryHelper::GetFactory(NeonWorkloadFactoryHelper::GetMemoryManager()); |
| 341 | |
narpra01 | 55a97bc | 2018-10-02 14:35:53 +0100 | [diff] [blame] | 342 | auto workload = CreateNormalizationWorkloadTest<NormalizationWorkloadType, DataType>(factory, graph, dataLayout); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 343 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 344 | // Checks that outputs and inputs are as we expect them (see definition of CreateNormalizationWorkloadTest). |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 345 | NormalizationQueueDescriptor queueDescriptor = workload->GetData(); |
Derek Lamberti | c81855f | 2019-06-13 17:34:19 +0100 | [diff] [blame] | 346 | auto inputHandle = boost::polymorphic_downcast<IAclTensorHandle*>(queueDescriptor.m_Inputs[0]); |
| 347 | auto outputHandle = boost::polymorphic_downcast<IAclTensorHandle*>(queueDescriptor.m_Outputs[0]); |
Matteo Martincigh | a160b24 | 2018-10-18 10:33:23 +0100 | [diff] [blame] | 348 | |
| 349 | TensorShape inputShape = (dataLayout == DataLayout::NCHW) ? TensorShape{3, 5, 5, 1} : TensorShape{3, 1, 5, 5}; |
| 350 | TensorShape outputShape = (dataLayout == DataLayout::NCHW) ? TensorShape{3, 5, 5, 1} : TensorShape{3, 1, 5, 5}; |
| 351 | |
| 352 | BOOST_TEST(TestNeonTensorHandleInfo(inputHandle, TensorInfo(inputShape, DataType))); |
| 353 | BOOST_TEST(TestNeonTensorHandleInfo(outputHandle, TensorInfo(outputShape, DataType))); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 354 | } |
| 355 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 356 | #ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC |
narpra01 | 55a97bc | 2018-10-02 14:35:53 +0100 | [diff] [blame] | 357 | BOOST_AUTO_TEST_CASE(CreateNormalizationFloat16NchwWorkload) |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 358 | { |
narpra01 | 55a97bc | 2018-10-02 14:35:53 +0100 | [diff] [blame] | 359 | NeonCreateNormalizationWorkloadTest<NeonNormalizationFloatWorkload, DataType::Float16>(DataLayout::NCHW); |
| 360 | } |
| 361 | |
| 362 | BOOST_AUTO_TEST_CASE(CreateNormalizationFloat16NhwcWorkload) |
| 363 | { |
| 364 | NeonCreateNormalizationWorkloadTest<NeonNormalizationFloatWorkload, DataType::Float16>(DataLayout::NHWC); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 365 | } |
| 366 | #endif |
| 367 | |
narpra01 | 55a97bc | 2018-10-02 14:35:53 +0100 | [diff] [blame] | 368 | BOOST_AUTO_TEST_CASE(CreateNormalizationFloatNchwWorkload) |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 369 | { |
narpra01 | 55a97bc | 2018-10-02 14:35:53 +0100 | [diff] [blame] | 370 | NeonCreateNormalizationWorkloadTest<NeonNormalizationFloatWorkload, DataType::Float32>(DataLayout::NCHW); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 371 | } |
| 372 | |
narpra01 | 55a97bc | 2018-10-02 14:35:53 +0100 | [diff] [blame] | 373 | BOOST_AUTO_TEST_CASE(CreateNormalizationFloatNhwcWorkload) |
| 374 | { |
| 375 | NeonCreateNormalizationWorkloadTest<NeonNormalizationFloatWorkload, DataType::Float32>(DataLayout::NHWC); |
| 376 | } |
| 377 | |
| 378 | |
Nattapat Chaimanowong | 5d2e700 | 2018-10-12 16:03:56 +0100 | [diff] [blame] | 379 | template <typename armnn::DataType DataType> |
Nina Drozd | b48e686 | 2018-10-09 12:09:56 +0100 | [diff] [blame] | 380 | static void NeonCreatePooling2dWorkloadTest(DataLayout dataLayout = DataLayout::NCHW) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 381 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 382 | Graph graph; |
| 383 | NeonWorkloadFactory factory = |
| 384 | NeonWorkloadFactoryHelper::GetFactory(NeonWorkloadFactoryHelper::GetMemoryManager()); |
| 385 | |
| 386 | auto workload = CreatePooling2dWorkloadTest<NeonPooling2dWorkload, DataType>(factory, graph, dataLayout); |
Nina Drozd | b48e686 | 2018-10-09 12:09:56 +0100 | [diff] [blame] | 387 | |
| 388 | TensorShape inputShape = (dataLayout == DataLayout::NCHW) ? TensorShape{3, 2, 5, 5} : TensorShape{3, 5, 5, 2}; |
| 389 | TensorShape outputShape = (dataLayout == DataLayout::NCHW) ? TensorShape{3, 2, 2, 4} : TensorShape{3, 2, 4, 2}; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 390 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 391 | // Checks that outputs and inputs are as we expect them (see definition of CreatePooling2dWorkloadTest). |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 392 | Pooling2dQueueDescriptor queueDescriptor = workload->GetData(); |
Derek Lamberti | c81855f | 2019-06-13 17:34:19 +0100 | [diff] [blame] | 393 | auto inputHandle = boost::polymorphic_downcast<IAclTensorHandle*>(queueDescriptor.m_Inputs[0]); |
| 394 | auto outputHandle = boost::polymorphic_downcast<IAclTensorHandle*>(queueDescriptor.m_Outputs[0]); |
Nina Drozd | b48e686 | 2018-10-09 12:09:56 +0100 | [diff] [blame] | 395 | BOOST_TEST(TestNeonTensorHandleInfo(inputHandle, TensorInfo(inputShape, DataType))); |
| 396 | BOOST_TEST(TestNeonTensorHandleInfo(outputHandle, TensorInfo(outputShape, DataType))); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 397 | } |
| 398 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 399 | #ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC |
| 400 | BOOST_AUTO_TEST_CASE(CreatePooling2dFloat16Workload) |
| 401 | { |
Nattapat Chaimanowong | 5d2e700 | 2018-10-12 16:03:56 +0100 | [diff] [blame] | 402 | NeonCreatePooling2dWorkloadTest<DataType::Float16>(); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 403 | } |
| 404 | #endif |
| 405 | |
Nina Drozd | b48e686 | 2018-10-09 12:09:56 +0100 | [diff] [blame] | 406 | BOOST_AUTO_TEST_CASE(CreatePooling2dFloatNchwWorkload) |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 407 | { |
Nattapat Chaimanowong | 5d2e700 | 2018-10-12 16:03:56 +0100 | [diff] [blame] | 408 | NeonCreatePooling2dWorkloadTest<DataType::Float32>(DataLayout::NCHW); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 409 | } |
| 410 | |
Nina Drozd | b48e686 | 2018-10-09 12:09:56 +0100 | [diff] [blame] | 411 | BOOST_AUTO_TEST_CASE(CreatePooling2dFloatNhwcWorkload) |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 412 | { |
Nattapat Chaimanowong | 5d2e700 | 2018-10-12 16:03:56 +0100 | [diff] [blame] | 413 | NeonCreatePooling2dWorkloadTest<DataType::Float32>(DataLayout::NHWC); |
Nina Drozd | b48e686 | 2018-10-09 12:09:56 +0100 | [diff] [blame] | 414 | } |
| 415 | |
| 416 | BOOST_AUTO_TEST_CASE(CreatePooling2dUint8NchwWorkload) |
| 417 | { |
Nattapat Chaimanowong | 5d2e700 | 2018-10-12 16:03:56 +0100 | [diff] [blame] | 418 | NeonCreatePooling2dWorkloadTest<DataType::QuantisedAsymm8>(DataLayout::NCHW); |
Nina Drozd | b48e686 | 2018-10-09 12:09:56 +0100 | [diff] [blame] | 419 | } |
| 420 | |
| 421 | BOOST_AUTO_TEST_CASE(CreatePooling2dUint8NhwcWorkload) |
| 422 | { |
Nattapat Chaimanowong | 5d2e700 | 2018-10-12 16:03:56 +0100 | [diff] [blame] | 423 | NeonCreatePooling2dWorkloadTest<DataType::QuantisedAsymm8>(DataLayout::NHWC); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 424 | } |
| 425 | |
Nikhil Raj | 9b46148 | 2019-07-03 15:58:31 +0100 | [diff] [blame] | 426 | static void NeonCreatePreluWorkloadTest(const armnn::TensorShape& inputShape, |
| 427 | const armnn::TensorShape& alphaShape, |
| 428 | const armnn::TensorShape& outputShape, |
| 429 | armnn::DataType dataType) |
| 430 | { |
| 431 | Graph graph; |
| 432 | NeonWorkloadFactory factory = |
| 433 | NeonWorkloadFactoryHelper::GetFactory(NeonWorkloadFactoryHelper::GetMemoryManager()); |
| 434 | |
| 435 | auto workload = CreatePreluWorkloadTest<NeonPreluWorkload>(factory, |
| 436 | graph, |
| 437 | inputShape, |
| 438 | alphaShape, |
| 439 | outputShape, |
| 440 | dataType); |
| 441 | |
| 442 | // Checks that outputs and inputs are as we expect them (see definition of CreateReshapeWorkloadTest). |
| 443 | PreluQueueDescriptor queueDescriptor = workload->GetData(); |
| 444 | auto inputHandle = boost::polymorphic_downcast<IAclTensorHandle*>(queueDescriptor.m_Inputs[0]); |
| 445 | auto alphaHandle = boost::polymorphic_downcast<IAclTensorHandle*>(queueDescriptor.m_Inputs[1]); |
| 446 | auto outputHandle = boost::polymorphic_downcast<IAclTensorHandle*>(queueDescriptor.m_Outputs[0]); |
| 447 | BOOST_TEST(TestNeonTensorHandleInfo(inputHandle, TensorInfo(inputShape, dataType))); |
| 448 | BOOST_TEST(TestNeonTensorHandleInfo(alphaHandle, TensorInfo(alphaShape, dataType))); |
| 449 | BOOST_TEST(TestNeonTensorHandleInfo(outputHandle, TensorInfo(outputShape, dataType))); |
| 450 | } |
| 451 | |
| 452 | #ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC |
| 453 | BOOST_AUTO_TEST_CASE(CreatePreluFloat16Workload) |
| 454 | { |
| 455 | NeonCreatePreluWorkloadTest({ 1, 4, 1, 2 }, { 5, 4, 3, 1 }, { 5, 4, 3, 2 }, DataType::Float16); |
| 456 | } |
| 457 | #endif |
| 458 | |
| 459 | BOOST_AUTO_TEST_CASE(CreatePreluFloatWorkload) |
| 460 | { |
| 461 | NeonCreatePreluWorkloadTest({ 1, 4, 1, 2 }, { 5, 4, 3, 1 }, { 5, 4, 3, 2 }, DataType::Float32); |
| 462 | } |
| 463 | |
| 464 | BOOST_AUTO_TEST_CASE(CreatePreluUint8Workload) |
| 465 | { |
| 466 | NeonCreatePreluWorkloadTest({ 1, 4, 1, 2 }, { 5, 4, 3, 1 }, { 5, 4, 3, 2 }, DataType::QuantisedAsymm8); |
| 467 | } |
| 468 | |
Nattapat Chaimanowong | cce11fc | 2018-10-12 16:30:56 +0100 | [diff] [blame] | 469 | template <typename armnn::DataType DataType> |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 470 | static void NeonCreateReshapeWorkloadTest() |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 471 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 472 | Graph graph; |
| 473 | NeonWorkloadFactory factory = |
| 474 | NeonWorkloadFactoryHelper::GetFactory(NeonWorkloadFactoryHelper::GetMemoryManager()); |
| 475 | |
| 476 | auto workload = CreateReshapeWorkloadTest<NeonReshapeWorkload, DataType>(factory, graph); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 477 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 478 | // 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] | 479 | ReshapeQueueDescriptor queueDescriptor = workload->GetData(); |
Derek Lamberti | c81855f | 2019-06-13 17:34:19 +0100 | [diff] [blame] | 480 | auto inputHandle = boost::polymorphic_downcast<IAclTensorHandle*>(queueDescriptor.m_Inputs[0]); |
| 481 | auto outputHandle = boost::polymorphic_downcast<IAclTensorHandle*>(queueDescriptor.m_Outputs[0]); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 482 | BOOST_TEST(TestNeonTensorHandleInfo(inputHandle, TensorInfo({4, 1}, DataType))); |
| 483 | BOOST_TEST(TestNeonTensorHandleInfo(outputHandle, TensorInfo({1, 4}, DataType))); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 484 | } |
| 485 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 486 | #ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC |
| 487 | BOOST_AUTO_TEST_CASE(CreateReshapeFloat16Workload) |
| 488 | { |
Nattapat Chaimanowong | cce11fc | 2018-10-12 16:30:56 +0100 | [diff] [blame] | 489 | NeonCreateReshapeWorkloadTest<DataType::Float16>(); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 490 | } |
| 491 | #endif |
| 492 | |
arovir01 | 9e53a35 | 2018-08-31 15:26:35 +0100 | [diff] [blame] | 493 | BOOST_AUTO_TEST_CASE(CreateReshapeFloatWorkload) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 494 | { |
Nattapat Chaimanowong | cce11fc | 2018-10-12 16:30:56 +0100 | [diff] [blame] | 495 | NeonCreateReshapeWorkloadTest<DataType::Float32>(); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 496 | } |
| 497 | |
| 498 | BOOST_AUTO_TEST_CASE(CreateReshapeUint8Workload) |
| 499 | { |
Nattapat Chaimanowong | cce11fc | 2018-10-12 16:30:56 +0100 | [diff] [blame] | 500 | NeonCreateReshapeWorkloadTest<DataType::QuantisedAsymm8>(); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 501 | } |
| 502 | |
Ellen Norris-Thompson | 37e6868 | 2019-07-15 14:23:30 +0100 | [diff] [blame] | 503 | template <typename ResizeWorkloadType, armnn::DataType DataType> |
| 504 | static void NeonCreateResizeWorkloadTest(DataLayout dataLayout) |
| 505 | { |
| 506 | Graph graph; |
| 507 | NeonWorkloadFactory factory = |
| 508 | NeonWorkloadFactoryHelper::GetFactory(NeonWorkloadFactoryHelper::GetMemoryManager()); |
| 509 | auto workload = CreateResizeBilinearWorkloadTest<ResizeWorkloadType, DataType>(factory, graph, dataLayout); |
| 510 | |
| 511 | auto queueDescriptor = workload->GetData(); |
| 512 | |
| 513 | auto inputHandle = boost::polymorphic_downcast<IAclTensorHandle*>(queueDescriptor.m_Inputs[0]); |
| 514 | auto outputHandle = boost::polymorphic_downcast<IAclTensorHandle*>(queueDescriptor.m_Outputs[0]); |
| 515 | |
| 516 | switch (dataLayout) |
| 517 | { |
| 518 | case DataLayout::NHWC: |
| 519 | BOOST_TEST(CompareIAclTensorHandleShape(inputHandle, { 2, 4, 4, 3 })); |
| 520 | BOOST_TEST(CompareIAclTensorHandleShape(outputHandle, { 2, 2, 2, 3 })); |
| 521 | break; |
| 522 | case DataLayout::NCHW: |
| 523 | default: |
| 524 | BOOST_TEST(CompareIAclTensorHandleShape(inputHandle, { 2, 3, 4, 4 })); |
| 525 | BOOST_TEST(CompareIAclTensorHandleShape(outputHandle, { 2, 3, 2, 2 })); |
| 526 | } |
| 527 | } |
| 528 | |
| 529 | BOOST_AUTO_TEST_CASE(CreateResizeFloat32NchwWorkload) |
| 530 | { |
| 531 | NeonCreateResizeWorkloadTest<NeonResizeWorkload, armnn::DataType::Float32>(DataLayout::NCHW); |
| 532 | } |
| 533 | |
| 534 | BOOST_AUTO_TEST_CASE(CreateResizeUint8NchwWorkload) |
| 535 | { |
| 536 | NeonCreateResizeWorkloadTest<NeonResizeWorkload, armnn::DataType::QuantisedAsymm8>(DataLayout::NCHW); |
| 537 | } |
| 538 | |
| 539 | BOOST_AUTO_TEST_CASE(CreateResizeFloat32NhwcWorkload) |
| 540 | { |
| 541 | NeonCreateResizeWorkloadTest<NeonResizeWorkload, armnn::DataType::Float32>(DataLayout::NHWC); |
| 542 | } |
| 543 | |
| 544 | BOOST_AUTO_TEST_CASE(CreateResizeUint8NhwcWorkload) |
| 545 | { |
| 546 | NeonCreateResizeWorkloadTest<NeonResizeWorkload, armnn::DataType::QuantisedAsymm8>(DataLayout::NHWC); |
| 547 | } |
| 548 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 549 | template <typename SoftmaxWorkloadType, typename armnn::DataType DataType> |
| 550 | static void NeonCreateSoftmaxWorkloadTest() |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 551 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 552 | Graph graph; |
| 553 | NeonWorkloadFactory factory = |
| 554 | NeonWorkloadFactoryHelper::GetFactory(NeonWorkloadFactoryHelper::GetMemoryManager()); |
| 555 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 556 | auto workload = CreateSoftmaxWorkloadTest<SoftmaxWorkloadType, DataType>(factory, graph); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 557 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 558 | // 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] | 559 | SoftmaxQueueDescriptor queueDescriptor = workload->GetData(); |
Derek Lamberti | c81855f | 2019-06-13 17:34:19 +0100 | [diff] [blame] | 560 | auto inputHandle = boost::polymorphic_downcast<IAclTensorHandle*>(queueDescriptor.m_Inputs[0]); |
| 561 | auto outputHandle = boost::polymorphic_downcast<IAclTensorHandle*>(queueDescriptor.m_Outputs[0]); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 562 | BOOST_TEST(TestNeonTensorHandleInfo(inputHandle, TensorInfo({4, 1}, DataType))); |
| 563 | BOOST_TEST(TestNeonTensorHandleInfo(outputHandle, TensorInfo({4, 1}, DataType))); |
| 564 | } |
| 565 | |
| 566 | #ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC |
| 567 | BOOST_AUTO_TEST_CASE(CreateSoftmaxFloat16Workload) |
| 568 | { |
arovir01 | 9e53a35 | 2018-08-31 15:26:35 +0100 | [diff] [blame] | 569 | NeonCreateSoftmaxWorkloadTest<NeonSoftmaxFloatWorkload, DataType::Float16>(); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 570 | } |
| 571 | #endif |
| 572 | |
arovir01 | 9e53a35 | 2018-08-31 15:26:35 +0100 | [diff] [blame] | 573 | BOOST_AUTO_TEST_CASE(CreateSoftmaxFloatWorkload) |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 574 | { |
arovir01 | 9e53a35 | 2018-08-31 15:26:35 +0100 | [diff] [blame] | 575 | NeonCreateSoftmaxWorkloadTest<NeonSoftmaxFloatWorkload, DataType::Float32>(); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 576 | } |
| 577 | |
Ellen Norris-Thompson | 2979457 | 2019-06-26 16:40:36 +0100 | [diff] [blame] | 578 | template <typename SpaceToDepthWorkloadType, typename armnn::DataType DataType> |
| 579 | static void NeonSpaceToDepthWorkloadTest() |
| 580 | { |
| 581 | Graph graph; |
| 582 | NeonWorkloadFactory factory = |
| 583 | NeonWorkloadFactoryHelper::GetFactory(NeonWorkloadFactoryHelper::GetMemoryManager()); |
| 584 | |
| 585 | auto workload = CreateSpaceToDepthWorkloadTest<SpaceToDepthWorkloadType, DataType>(factory, graph); |
| 586 | |
| 587 | SpaceToDepthQueueDescriptor queueDescriptor = workload->GetData(); |
| 588 | auto inputHandle = boost::polymorphic_downcast<IAclTensorHandle*>(queueDescriptor.m_Inputs[0]); |
| 589 | auto outputHandle = boost::polymorphic_downcast<IAclTensorHandle*>(queueDescriptor.m_Outputs[0]); |
| 590 | |
| 591 | BOOST_TEST(TestNeonTensorHandleInfo(inputHandle, TensorInfo({ 1, 2, 2, 1 }, DataType))); |
| 592 | BOOST_TEST(TestNeonTensorHandleInfo(outputHandle, TensorInfo({ 1, 1, 1, 4 }, DataType))); |
| 593 | } |
| 594 | |
| 595 | BOOST_AUTO_TEST_CASE(CreateSpaceToDepthFloat32Workload) |
| 596 | { |
| 597 | NeonSpaceToDepthWorkloadTest<NeonSpaceToDepthWorkload, armnn::DataType::Float32>(); |
| 598 | } |
| 599 | |
| 600 | BOOST_AUTO_TEST_CASE(CreateSpaceToDepthFloat16Workload) |
| 601 | { |
| 602 | NeonSpaceToDepthWorkloadTest<NeonSpaceToDepthWorkload, armnn::DataType::Float16>(); |
| 603 | } |
| 604 | |
| 605 | BOOST_AUTO_TEST_CASE(CreateSpaceToDepthQAsymm8Workload) |
| 606 | { |
| 607 | NeonSpaceToDepthWorkloadTest<NeonSpaceToDepthWorkload, armnn::DataType::QuantisedAsymm8>(); |
| 608 | } |
| 609 | |
| 610 | BOOST_AUTO_TEST_CASE(CreateSpaceToDepthQSymm16Workload) |
| 611 | { |
| 612 | NeonSpaceToDepthWorkloadTest<NeonSpaceToDepthWorkload, armnn::DataType::QuantisedSymm16>(); |
| 613 | } |
| 614 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 615 | BOOST_AUTO_TEST_CASE(CreateSplitterWorkload) |
| 616 | { |
| 617 | Graph graph; |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 618 | NeonWorkloadFactory factory = |
| 619 | NeonWorkloadFactoryHelper::GetFactory(NeonWorkloadFactoryHelper::GetMemoryManager()); |
| 620 | |
Nattapat Chaimanowong | 14766d7 | 2018-10-12 15:09:53 +0100 | [diff] [blame] | 621 | auto workload = CreateSplitterWorkloadTest<NeonSplitterWorkload, DataType::Float32>(factory, graph); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 622 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 623 | // Checks that outputs are as we expect them (see definition of CreateSplitterWorkloadTest). |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 624 | SplitterQueueDescriptor queueDescriptor = workload->GetData(); |
Derek Lamberti | c81855f | 2019-06-13 17:34:19 +0100 | [diff] [blame] | 625 | auto inputHandle = boost::polymorphic_downcast<IAclTensorHandle*>(queueDescriptor.m_Inputs[0]); |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 626 | BOOST_TEST(TestNeonTensorHandleInfo(inputHandle, TensorInfo({5, 7, 7}, DataType::Float32))); |
| 627 | |
Derek Lamberti | c81855f | 2019-06-13 17:34:19 +0100 | [diff] [blame] | 628 | auto outputHandle0 = boost::polymorphic_downcast<IAclTensorHandle*>(queueDescriptor.m_Outputs[0]); |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 629 | BOOST_TEST(TestNeonTensorHandleInfo(outputHandle0, TensorInfo({1, 7, 7}, DataType::Float32))); |
| 630 | |
Derek Lamberti | c81855f | 2019-06-13 17:34:19 +0100 | [diff] [blame] | 631 | auto outputHandle1 = boost::polymorphic_downcast<IAclTensorHandle*>(queueDescriptor.m_Outputs[1]); |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 632 | BOOST_TEST(TestNeonTensorHandleInfo(outputHandle1, TensorInfo({2, 7, 7}, DataType::Float32))); |
| 633 | |
Derek Lamberti | c81855f | 2019-06-13 17:34:19 +0100 | [diff] [blame] | 634 | auto outputHandle2 = boost::polymorphic_downcast<IAclTensorHandle*>(queueDescriptor.m_Outputs[2]); |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 635 | BOOST_TEST(TestNeonTensorHandleInfo(outputHandle2, TensorInfo({2, 7, 7}, DataType::Float32))); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 636 | } |
| 637 | |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 638 | BOOST_AUTO_TEST_CASE(CreateSplitterConcat) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 639 | { |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 640 | // 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] | 641 | // should be lined to which input of the concat layer. |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 642 | // We tested that is is possible to specify 0th output |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 643 | // of the splitter to be the 1st input to the concat, and the 1st output of the splitter to be 0th input |
| 644 | // of the concat. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 645 | |
| 646 | Graph graph; |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 647 | NeonWorkloadFactory factory = |
| 648 | NeonWorkloadFactoryHelper::GetFactory(NeonWorkloadFactoryHelper::GetMemoryManager()); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 649 | |
| 650 | auto workloads = |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 651 | CreateSplitterConcatWorkloadTest<NeonSplitterWorkload, NeonConcatWorkload, |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 652 | DataType::Float32>(factory, graph); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 653 | |
| 654 | auto wlSplitter = std::move(workloads.first); |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 655 | auto wlConcat = std::move(workloads.second); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 656 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 657 | //Checks that the index of inputs/outputs matches what we declared on InputDescriptor construction. |
Derek Lamberti | c81855f | 2019-06-13 17:34:19 +0100 | [diff] [blame] | 658 | armnn::IAclTensorHandle* sOut0 = dynamic_cast<armnn::IAclTensorHandle*>(wlSplitter->GetData().m_Outputs[0]); |
| 659 | armnn::IAclTensorHandle* sOut1 = dynamic_cast<armnn::IAclTensorHandle*>(wlSplitter->GetData().m_Outputs[1]); |
| 660 | armnn::IAclTensorHandle* mIn0 = dynamic_cast<armnn::IAclTensorHandle*>(wlConcat->GetData().m_Inputs[0]); |
| 661 | armnn::IAclTensorHandle* mIn1 = dynamic_cast<armnn::IAclTensorHandle*>(wlConcat->GetData().m_Inputs[1]); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 662 | |
| 663 | BOOST_TEST(sOut0); |
| 664 | BOOST_TEST(sOut1); |
| 665 | BOOST_TEST(mIn0); |
| 666 | BOOST_TEST(mIn1); |
| 667 | |
| 668 | bool validDataPointers = (sOut0 == mIn1) && (sOut1 == mIn0); |
| 669 | |
| 670 | BOOST_TEST(validDataPointers); |
| 671 | } |
| 672 | |
| 673 | BOOST_AUTO_TEST_CASE(CreateSingleOutputMultipleInputs) |
| 674 | { |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 675 | // Tests that it is possible to assign multiple (two) different layers to each of the outputs of a splitter layer. |
| 676 | // 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] | 677 | |
| 678 | Graph graph; |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 679 | NeonWorkloadFactory factory = |
| 680 | NeonWorkloadFactoryHelper::GetFactory(NeonWorkloadFactoryHelper::GetMemoryManager()); |
| 681 | |
Nattapat Chaimanowong | 14766d7 | 2018-10-12 15:09:53 +0100 | [diff] [blame] | 682 | std::unique_ptr<NeonSplitterWorkload> wlSplitter; |
Nattapat Chaimanowong | d4b7059 | 2018-10-12 11:21:49 +0100 | [diff] [blame] | 683 | std::unique_ptr<NeonActivationWorkload> wlActiv0_0; |
| 684 | std::unique_ptr<NeonActivationWorkload> wlActiv0_1; |
| 685 | std::unique_ptr<NeonActivationWorkload> wlActiv1_0; |
| 686 | std::unique_ptr<NeonActivationWorkload> wlActiv1_1; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 687 | |
Nattapat Chaimanowong | 14766d7 | 2018-10-12 15:09:53 +0100 | [diff] [blame] | 688 | CreateSplitterMultipleInputsOneOutputWorkloadTest<NeonSplitterWorkload, |
Nattapat Chaimanowong | d4b7059 | 2018-10-12 11:21:49 +0100 | [diff] [blame] | 689 | NeonActivationWorkload, DataType::Float32>(factory, graph, wlSplitter, wlActiv0_0, wlActiv0_1, |
| 690 | wlActiv1_0, wlActiv1_1); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 691 | |
Derek Lamberti | c81855f | 2019-06-13 17:34:19 +0100 | [diff] [blame] | 692 | armnn::IAclTensorHandle* sOut0 = dynamic_cast<armnn::IAclTensorHandle*>(wlSplitter->GetData().m_Outputs[0]); |
| 693 | armnn::IAclTensorHandle* sOut1 = dynamic_cast<armnn::IAclTensorHandle*>(wlSplitter->GetData().m_Outputs[1]); |
| 694 | armnn::IAclTensorHandle* activ0_0Im = dynamic_cast<armnn::IAclTensorHandle*>(wlActiv0_0->GetData().m_Inputs[0]); |
| 695 | armnn::IAclTensorHandle* activ0_1Im = dynamic_cast<armnn::IAclTensorHandle*>(wlActiv0_1->GetData().m_Inputs[0]); |
| 696 | armnn::IAclTensorHandle* activ1_0Im = dynamic_cast<armnn::IAclTensorHandle*>(wlActiv1_0->GetData().m_Inputs[0]); |
| 697 | armnn::IAclTensorHandle* activ1_1Im = dynamic_cast<armnn::IAclTensorHandle*>(wlActiv1_1->GetData().m_Inputs[0]); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 698 | |
| 699 | |
| 700 | BOOST_TEST(sOut0); |
| 701 | BOOST_TEST(sOut1); |
| 702 | BOOST_TEST(activ0_0Im); |
| 703 | BOOST_TEST(activ0_1Im); |
| 704 | BOOST_TEST(activ1_0Im); |
| 705 | BOOST_TEST(activ1_1Im); |
| 706 | |
| 707 | bool validDataPointers = (sOut0 == activ0_0Im) && (sOut0 == activ0_1Im) && |
| 708 | (sOut1 == activ1_0Im) && (sOut1 == activ1_1Im); |
| 709 | |
| 710 | BOOST_TEST(validDataPointers); |
| 711 | } |
| 712 | |
Matteo Martincigh | db16dd3 | 2019-08-27 16:41:11 +0100 | [diff] [blame] | 713 | #if defined(ARMNNREF_ENABLED) |
Matteo Martincigh | e67edb2 | 2019-08-14 14:05:46 +0100 | [diff] [blame] | 714 | |
| 715 | // This test unit needs the reference backend, it's not available if the reference backend is not built |
| 716 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 717 | BOOST_AUTO_TEST_CASE(CreateMemCopyWorkloadsNeon) |
| 718 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 719 | NeonWorkloadFactory factory = |
| 720 | NeonWorkloadFactoryHelper::GetFactory(NeonWorkloadFactoryHelper::GetMemoryManager()); |
Derek Lamberti | c81855f | 2019-06-13 17:34:19 +0100 | [diff] [blame] | 721 | CreateMemCopyWorkloads<IAclTensorHandle>(factory); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 722 | } |
| 723 | |
Matteo Martincigh | e67edb2 | 2019-08-14 14:05:46 +0100 | [diff] [blame] | 724 | #endif |
| 725 | |
Matteo Martincigh | bcd3c85 | 2018-09-28 14:14:12 +0100 | [diff] [blame] | 726 | template <typename L2NormalizationWorkloadType, typename armnn::DataType DataType> |
| 727 | static void NeonCreateL2NormalizationWorkloadTest(DataLayout dataLayout) |
| 728 | { |
Matteo Martincigh | 2400b6d | 2018-10-09 18:19:20 +0100 | [diff] [blame] | 729 | Graph graph; |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 730 | NeonWorkloadFactory factory = |
| 731 | NeonWorkloadFactoryHelper::GetFactory(NeonWorkloadFactoryHelper::GetMemoryManager()); |
| 732 | |
Matteo Martincigh | 2400b6d | 2018-10-09 18:19:20 +0100 | [diff] [blame] | 733 | auto workload = |
| 734 | CreateL2NormalizationWorkloadTest<L2NormalizationWorkloadType, DataType>(factory, graph, dataLayout); |
Matteo Martincigh | bcd3c85 | 2018-09-28 14:14:12 +0100 | [diff] [blame] | 735 | |
| 736 | // Checks that inputs/outputs are as we expect them (see definition of CreateNormalizationWorkloadTest). |
| 737 | L2NormalizationQueueDescriptor queueDescriptor = workload->GetData(); |
Derek Lamberti | c81855f | 2019-06-13 17:34:19 +0100 | [diff] [blame] | 738 | auto inputHandle = boost::polymorphic_downcast<IAclTensorHandle*>(queueDescriptor.m_Inputs[0]); |
| 739 | auto outputHandle = boost::polymorphic_downcast<IAclTensorHandle*>(queueDescriptor.m_Outputs[0]); |
Matteo Martincigh | 2400b6d | 2018-10-09 18:19:20 +0100 | [diff] [blame] | 740 | |
| 741 | TensorShape inputShape = (dataLayout == DataLayout::NCHW) ? |
| 742 | TensorShape{ 5, 20, 50, 67 } : TensorShape{ 5, 50, 67, 20 }; |
| 743 | TensorShape outputShape = (dataLayout == DataLayout::NCHW) ? |
| 744 | TensorShape{ 5, 20, 50, 67 } : TensorShape{ 5, 50, 67, 20 }; |
| 745 | |
| 746 | BOOST_TEST(TestNeonTensorHandleInfo(inputHandle, TensorInfo(inputShape, DataType))); |
| 747 | BOOST_TEST(TestNeonTensorHandleInfo(outputHandle, TensorInfo(outputShape, DataType))); |
Matteo Martincigh | bcd3c85 | 2018-09-28 14:14:12 +0100 | [diff] [blame] | 748 | } |
| 749 | |
| 750 | #ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC |
| 751 | BOOST_AUTO_TEST_CASE(CreateL2NormalizationFloat16NchwWorkload) |
| 752 | { |
| 753 | NeonCreateL2NormalizationWorkloadTest<NeonL2NormalizationFloatWorkload, DataType::Float16>(DataLayout::NCHW); |
| 754 | } |
| 755 | |
| 756 | BOOST_AUTO_TEST_CASE(CreateL2NormalizationFloat16NhwcWorkload) |
| 757 | { |
| 758 | NeonCreateL2NormalizationWorkloadTest<NeonL2NormalizationFloatWorkload, DataType::Float16>(DataLayout::NHWC); |
| 759 | } |
| 760 | #endif |
| 761 | |
| 762 | BOOST_AUTO_TEST_CASE(CreateL2NormalizationNchwWorkload) |
| 763 | { |
| 764 | NeonCreateL2NormalizationWorkloadTest<NeonL2NormalizationFloatWorkload, DataType::Float32>(DataLayout::NCHW); |
| 765 | } |
| 766 | |
| 767 | BOOST_AUTO_TEST_CASE(CreateL2NormalizationNhwcWorkload) |
| 768 | { |
| 769 | NeonCreateL2NormalizationWorkloadTest<NeonL2NormalizationFloatWorkload, DataType::Float32>(DataLayout::NHWC); |
| 770 | } |
| 771 | |
Jan Eilers | ad5293a | 2019-07-08 09:57:55 +0100 | [diff] [blame] | 772 | template <typename LstmWorkloadType> |
| 773 | static void NeonCreateLstmWorkloadTest() |
| 774 | { |
| 775 | Graph graph; |
| 776 | NeonWorkloadFactory factory = |
| 777 | NeonWorkloadFactoryHelper::GetFactory(NeonWorkloadFactoryHelper::GetMemoryManager()); |
| 778 | |
| 779 | auto workload = CreateLstmWorkloadTest<LstmWorkloadType>(factory, graph); |
| 780 | |
| 781 | LstmQueueDescriptor queueDescriptor = workload->GetData(); |
| 782 | |
| 783 | auto inputHandle = boost::polymorphic_downcast<IAclTensorHandle*>(queueDescriptor.m_Inputs[0]); |
| 784 | auto outputHandle = boost::polymorphic_downcast<IAclTensorHandle*>(queueDescriptor.m_Outputs[1]); |
| 785 | |
| 786 | BOOST_TEST(TestNeonTensorHandleInfo(inputHandle, TensorInfo({ 2, 2 }, DataType::Float32))); |
| 787 | BOOST_TEST(TestNeonTensorHandleInfo(outputHandle, TensorInfo({ 2, 4 }, DataType::Float32))); |
| 788 | } |
| 789 | |
| 790 | BOOST_AUTO_TEST_CASE(CreateLSTMWorkloadFloatWorkload) |
| 791 | { |
| 792 | NeonCreateLstmWorkloadTest<NeonLstmFloatWorkload>(); |
| 793 | } |
| 794 | |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 795 | template <typename ConcatWorkloadType, armnn::DataType DataType> |
| 796 | static void NeonCreateConcatWorkloadTest(std::initializer_list<unsigned int> outputShape, |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 797 | unsigned int concatAxis) |
| 798 | { |
| 799 | Graph graph; |
| 800 | NeonWorkloadFactory factory = |
| 801 | NeonWorkloadFactoryHelper::GetFactory(NeonWorkloadFactoryHelper::GetMemoryManager()); |
| 802 | |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 803 | auto workload = CreateConcatWorkloadTest<ConcatWorkloadType, DataType>(factory, graph, outputShape, concatAxis); |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 804 | |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 805 | ConcatQueueDescriptor queueDescriptor = workload->GetData(); |
Derek Lamberti | c81855f | 2019-06-13 17:34:19 +0100 | [diff] [blame] | 806 | auto inputHandle0 = boost::polymorphic_downcast<IAclTensorHandle*>(queueDescriptor.m_Inputs[0]); |
| 807 | auto inputHandle1 = boost::polymorphic_downcast<IAclTensorHandle*>(queueDescriptor.m_Inputs[1]); |
| 808 | auto outputHandle = boost::polymorphic_downcast<IAclTensorHandle*>(queueDescriptor.m_Outputs[0]); |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 809 | |
| 810 | BOOST_TEST(TestNeonTensorHandleInfo(inputHandle0, TensorInfo({ 2, 3, 2, 5 }, DataType))); |
| 811 | BOOST_TEST(TestNeonTensorHandleInfo(inputHandle1, TensorInfo({ 2, 3, 2, 5 }, DataType))); |
| 812 | BOOST_TEST(TestNeonTensorHandleInfo(outputHandle, TensorInfo(outputShape, DataType))); |
| 813 | } |
| 814 | |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 815 | BOOST_AUTO_TEST_CASE(CreateConcatDim0Float32Workload) |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 816 | { |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 817 | NeonCreateConcatWorkloadTest<NeonConcatWorkload, armnn::DataType::Float32>({ 4, 3, 2, 5 }, 0); |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 818 | } |
| 819 | |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 820 | BOOST_AUTO_TEST_CASE(CreateConcatDim1Float32Workload) |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 821 | { |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 822 | NeonCreateConcatWorkloadTest<NeonConcatWorkload, armnn::DataType::Float32>({ 2, 6, 2, 5 }, 1); |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 823 | } |
| 824 | |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 825 | BOOST_AUTO_TEST_CASE(CreateConcatDim3Float32Workload) |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 826 | { |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 827 | NeonCreateConcatWorkloadTest<NeonConcatWorkload, armnn::DataType::Float32>({ 2, 3, 2, 10 }, 3); |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 828 | } |
| 829 | |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 830 | BOOST_AUTO_TEST_CASE(CreateConcatDim0Uint8Workload) |
narpra01 | 63b0882 | 2018-11-20 11:29:12 +0000 | [diff] [blame] | 831 | { |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 832 | NeonCreateConcatWorkloadTest<NeonConcatWorkload, armnn::DataType::QuantisedAsymm8>({ 4, 3, 2, 5 }, 0); |
narpra01 | 63b0882 | 2018-11-20 11:29:12 +0000 | [diff] [blame] | 833 | } |
| 834 | |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 835 | BOOST_AUTO_TEST_CASE(CreateConcatDim1Uint8Workload) |
narpra01 | 63b0882 | 2018-11-20 11:29:12 +0000 | [diff] [blame] | 836 | { |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 837 | NeonCreateConcatWorkloadTest<NeonConcatWorkload, armnn::DataType::QuantisedAsymm8>({ 2, 6, 2, 5 }, 1); |
narpra01 | 63b0882 | 2018-11-20 11:29:12 +0000 | [diff] [blame] | 838 | } |
| 839 | |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 840 | BOOST_AUTO_TEST_CASE(CreateConcatDim3Uint8Workload) |
narpra01 | 63b0882 | 2018-11-20 11:29:12 +0000 | [diff] [blame] | 841 | { |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 842 | NeonCreateConcatWorkloadTest<NeonConcatWorkload, armnn::DataType::QuantisedAsymm8>({ 2, 3, 2, 10 }, 3); |
narpra01 | 63b0882 | 2018-11-20 11:29:12 +0000 | [diff] [blame] | 843 | } |
| 844 | |
Matthew Jackson | 87f65ea | 2019-08-01 10:01:34 +0100 | [diff] [blame] | 845 | template <armnn::DataType DataType> |
| 846 | static void NeonCreateStackWorkloadTest(const std::initializer_list<unsigned int>& inputShape, |
| 847 | const std::initializer_list<unsigned int>& outputShape, |
| 848 | unsigned int axis, |
| 849 | unsigned int numInputs) |
| 850 | { |
| 851 | armnn::Graph graph; |
| 852 | NeonWorkloadFactory factory = |
| 853 | NeonWorkloadFactoryHelper::GetFactory(NeonWorkloadFactoryHelper::GetMemoryManager()); |
| 854 | |
| 855 | auto workload = CreateStackWorkloadTest<NeonStackWorkload, DataType>(factory, |
| 856 | graph, |
| 857 | TensorShape(inputShape), |
| 858 | TensorShape(outputShape), |
| 859 | axis, |
| 860 | numInputs); |
| 861 | |
| 862 | // Check inputs and output are as expected |
| 863 | StackQueueDescriptor queueDescriptor = workload->GetData(); |
| 864 | for (unsigned int i = 0; i < numInputs; ++i) |
| 865 | { |
| 866 | auto inputHandle = boost::polymorphic_downcast<IAclTensorHandle*>(queueDescriptor.m_Inputs[i]); |
| 867 | BOOST_TEST(TestNeonTensorHandleInfo(inputHandle, TensorInfo(inputShape, DataType))); |
| 868 | } |
| 869 | auto outputHandle = boost::polymorphic_downcast<IAclTensorHandle*>(queueDescriptor.m_Outputs[0]); |
| 870 | BOOST_TEST(TestNeonTensorHandleInfo(outputHandle, TensorInfo(outputShape, DataType))); |
| 871 | } |
| 872 | |
| 873 | BOOST_AUTO_TEST_CASE(CreateStackFloat32Workload) |
| 874 | { |
| 875 | NeonCreateStackWorkloadTest<armnn::DataType::Float32>({ 3, 4, 5 }, { 3, 4, 2, 5 }, 2, 2); |
| 876 | } |
| 877 | |
Matthew Jackson | e69c399 | 2019-09-09 14:31:21 +0100 | [diff] [blame] | 878 | #ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC |
| 879 | BOOST_AUTO_TEST_CASE(CreateStackFloat16Workload) |
| 880 | { |
| 881 | NeonCreateStackWorkloadTest<armnn::DataType::Float16>({ 3, 4, 5 }, { 3, 4, 2, 5 }, 2, 2); |
| 882 | } |
| 883 | #endif |
| 884 | |
Matthew Jackson | 87f65ea | 2019-08-01 10:01:34 +0100 | [diff] [blame] | 885 | BOOST_AUTO_TEST_CASE(CreateStackUint8Workload) |
| 886 | { |
| 887 | NeonCreateStackWorkloadTest<armnn::DataType::QuantisedAsymm8>({ 3, 4, 5 }, { 3, 4, 2, 5 }, 2, 2); |
| 888 | } |
| 889 | |
Francis Murtagh | 4fc3c48 | 2019-08-02 13:20:54 +0100 | [diff] [blame] | 890 | template <typename QuantizedLstmWorkloadType> |
| 891 | static void NeonCreateQuantizedLstmWorkloadTest() |
| 892 | { |
| 893 | using boost::polymorphic_downcast; |
| 894 | |
| 895 | Graph graph; |
| 896 | NeonWorkloadFactory factory = NeonWorkloadFactoryHelper::GetFactory(NeonWorkloadFactoryHelper::GetMemoryManager()); |
| 897 | |
| 898 | auto workload = CreateQuantizedLstmWorkloadTest<QuantizedLstmWorkloadType>(factory, graph); |
| 899 | |
| 900 | QuantizedLstmQueueDescriptor queueDescriptor = workload->GetData(); |
| 901 | |
| 902 | IAclTensorHandle* inputHandle = polymorphic_downcast<IAclTensorHandle*>(queueDescriptor.m_Inputs[0]); |
| 903 | BOOST_TEST((inputHandle->GetShape() == TensorShape({2, 2}))); |
| 904 | BOOST_TEST((inputHandle->GetDataType() == arm_compute::DataType::QASYMM8)); |
| 905 | |
| 906 | IAclTensorHandle* cellStateInHandle = polymorphic_downcast<IAclTensorHandle*>(queueDescriptor.m_Inputs[1]); |
| 907 | BOOST_TEST((cellStateInHandle->GetShape() == TensorShape({2, 4}))); |
| 908 | BOOST_TEST((cellStateInHandle->GetDataType() == arm_compute::DataType::QSYMM16)); |
| 909 | |
| 910 | IAclTensorHandle* outputStateInHandle = polymorphic_downcast<IAclTensorHandle*>(queueDescriptor.m_Inputs[2]); |
| 911 | BOOST_TEST((outputStateInHandle->GetShape() == TensorShape({2, 4}))); |
| 912 | BOOST_TEST((outputStateInHandle->GetDataType() == arm_compute::DataType::QASYMM8)); |
| 913 | |
| 914 | IAclTensorHandle* cellStateOutHandle = polymorphic_downcast<IAclTensorHandle*>(queueDescriptor.m_Outputs[0]); |
| 915 | BOOST_TEST((cellStateOutHandle->GetShape() == TensorShape({2, 4}))); |
| 916 | BOOST_TEST((cellStateOutHandle->GetDataType() == arm_compute::DataType::QSYMM16)); |
| 917 | |
| 918 | IAclTensorHandle* outputStateOutHandle = polymorphic_downcast<IAclTensorHandle*>(queueDescriptor.m_Outputs[1]); |
| 919 | BOOST_TEST((outputStateOutHandle->GetShape() == TensorShape({2, 4}))); |
| 920 | BOOST_TEST((outputStateOutHandle->GetDataType() == arm_compute::DataType::QASYMM8)); |
| 921 | } |
| 922 | |
| 923 | BOOST_AUTO_TEST_CASE(CreateQuantizedLstmWorkload) |
| 924 | { |
| 925 | NeonCreateQuantizedLstmWorkloadTest<NeonQuantizedLstmWorkload>(); |
| 926 | } |
| 927 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 928 | BOOST_AUTO_TEST_SUITE_END() |