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 | |
Aron Virginas-Tar | c9cc804 | 2018-11-01 16:15:57 +0000 | [diff] [blame] | 8 | #include <backendsCommon/MemCopyWorkload.hpp> |
Aron Virginas-Tar | 3b278e9 | 2018-10-12 13:00:55 +0100 | [diff] [blame] | 9 | |
Aron Virginas-Tar | c9cc804 | 2018-11-01 16:15:57 +0000 | [diff] [blame] | 10 | #include <aclCommon/test/CreateWorkloadClNeon.hpp> |
Aron Virginas-Tar | 3b278e9 | 2018-10-12 13:00:55 +0100 | [diff] [blame] | 11 | |
Aron Virginas-Tar | c9cc804 | 2018-11-01 16:15:57 +0000 | [diff] [blame] | 12 | #include <neon/NeonWorkloadFactory.hpp> |
| 13 | #include <neon/NeonTensorHandle.hpp> |
| 14 | #include <neon/workloads/NeonWorkloadUtils.hpp> |
| 15 | #include <neon/workloads/NeonWorkloads.hpp> |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 16 | |
| 17 | BOOST_AUTO_TEST_SUITE(CreateWorkloadNeon) |
| 18 | |
| 19 | namespace |
| 20 | { |
| 21 | |
| 22 | bool TestNeonTensorHandleInfo(armnn::INeonTensorHandle* handle, const armnn::TensorInfo& expectedInfo) |
| 23 | { |
| 24 | using namespace armnn::armcomputetensorutils; |
| 25 | |
| 26 | const arm_compute::ITensorInfo* handleInfo = handle->GetTensor().info(); |
| 27 | const arm_compute::TensorInfo expectedAclInfo = BuildArmComputeTensorInfo(expectedInfo); |
| 28 | |
| 29 | if (handleInfo->data_type() != expectedAclInfo.data_type()) |
| 30 | { |
| 31 | return false; |
| 32 | } |
| 33 | |
| 34 | if (handleInfo->num_dimensions() != expectedAclInfo.num_dimensions()) |
| 35 | { |
| 36 | return false; |
| 37 | } |
| 38 | |
| 39 | if (handleInfo->quantization_info() != expectedAclInfo.quantization_info()) |
| 40 | { |
| 41 | return false; |
| 42 | } |
| 43 | |
| 44 | for (std::size_t d = 0; d < expectedAclInfo.num_dimensions(); ++d) |
| 45 | { |
| 46 | if (handleInfo->dimension(d) != expectedAclInfo.dimension(d)) |
| 47 | { |
| 48 | return false; |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | return true; |
| 53 | } |
| 54 | |
| 55 | } // namespace |
| 56 | |
Nattapat Chaimanowong | d4b7059 | 2018-10-12 11:21:49 +0100 | [diff] [blame] | 57 | template <typename armnn::DataType DataType> |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 58 | static void NeonCreateActivationWorkloadTest() |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 59 | { |
| 60 | Graph graph; |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 61 | NeonWorkloadFactory factory = |
| 62 | NeonWorkloadFactoryHelper::GetFactory(NeonWorkloadFactoryHelper::GetMemoryManager()); |
| 63 | |
Nattapat Chaimanowong | d4b7059 | 2018-10-12 11:21:49 +0100 | [diff] [blame] | 64 | auto workload = CreateActivationWorkloadTest<NeonActivationWorkload, DataType>(factory, graph); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 65 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 66 | // Checks that inputs/outputs are as we expect them (see definition of CreateActivationWorkloadTest). |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 67 | ActivationQueueDescriptor queueDescriptor = workload->GetData(); |
| 68 | auto inputHandle = boost::polymorphic_downcast<INeonTensorHandle*>(queueDescriptor.m_Inputs[0]); |
| 69 | auto outputHandle = boost::polymorphic_downcast<INeonTensorHandle*>(queueDescriptor.m_Outputs[0]); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 70 | BOOST_TEST(TestNeonTensorHandleInfo(inputHandle, TensorInfo({1, 1}, DataType))); |
| 71 | BOOST_TEST(TestNeonTensorHandleInfo(outputHandle, TensorInfo({1, 1}, DataType))); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 72 | } |
| 73 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 74 | #ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC |
| 75 | BOOST_AUTO_TEST_CASE(CreateActivationFloat16Workload) |
| 76 | { |
Nattapat Chaimanowong | d4b7059 | 2018-10-12 11:21:49 +0100 | [diff] [blame] | 77 | NeonCreateActivationWorkloadTest<DataType::Float16>(); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 78 | } |
| 79 | #endif |
| 80 | |
arovir01 | 9e53a35 | 2018-08-31 15:26:35 +0100 | [diff] [blame] | 81 | BOOST_AUTO_TEST_CASE(CreateActivationFloatWorkload) |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 82 | { |
Nattapat Chaimanowong | d4b7059 | 2018-10-12 11:21:49 +0100 | [diff] [blame] | 83 | NeonCreateActivationWorkloadTest<DataType::Float32>(); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 84 | } |
| 85 | |
David Beck | bc39245 | 2018-09-10 14:47:28 +0100 | [diff] [blame] | 86 | template <typename WorkloadType, |
| 87 | typename DescriptorType, |
| 88 | typename LayerType, |
| 89 | armnn::DataType DataType> |
Éanna Ó Catháin | d57415d | 2018-11-28 16:24:38 +0000 | [diff] [blame] | 90 | static void NeonCreateElementwiseWorkloadTest() |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 91 | { |
David Beck | bc39245 | 2018-09-10 14:47:28 +0100 | [diff] [blame] | 92 | Graph graph; |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 93 | NeonWorkloadFactory factory = |
| 94 | NeonWorkloadFactoryHelper::GetFactory(NeonWorkloadFactoryHelper::GetMemoryManager()); |
| 95 | |
Éanna Ó Catháin | d57415d | 2018-11-28 16:24:38 +0000 | [diff] [blame] | 96 | auto workload = CreateElementwiseWorkloadTest<WorkloadType, DescriptorType, LayerType, DataType>(factory, graph); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 97 | |
David Beck | bc39245 | 2018-09-10 14:47:28 +0100 | [diff] [blame] | 98 | DescriptorType queueDescriptor = workload->GetData(); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 99 | auto inputHandle1 = boost::polymorphic_downcast<INeonTensorHandle*>(queueDescriptor.m_Inputs[0]); |
| 100 | auto inputHandle2 = boost::polymorphic_downcast<INeonTensorHandle*>(queueDescriptor.m_Inputs[1]); |
| 101 | auto outputHandle = boost::polymorphic_downcast<INeonTensorHandle*>(queueDescriptor.m_Outputs[0]); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 102 | BOOST_TEST(TestNeonTensorHandleInfo(inputHandle1, TensorInfo({2, 3}, DataType))); |
| 103 | BOOST_TEST(TestNeonTensorHandleInfo(inputHandle2, TensorInfo({2, 3}, DataType))); |
| 104 | BOOST_TEST(TestNeonTensorHandleInfo(outputHandle, TensorInfo({2, 3}, DataType))); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 105 | } |
| 106 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 107 | #ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC |
| 108 | BOOST_AUTO_TEST_CASE(CreateAdditionFloat16Workload) |
| 109 | { |
Matthew Bentham | 955258d | 2018-12-10 10:48:52 +0000 | [diff] [blame] | 110 | NeonCreateElementwiseWorkloadTest<NeonAdditionWorkload, |
David Beck | bc39245 | 2018-09-10 14:47:28 +0100 | [diff] [blame] | 111 | AdditionQueueDescriptor, |
| 112 | AdditionLayer, |
| 113 | DataType::Float16>(); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 114 | } |
| 115 | #endif |
| 116 | |
arovir01 | 9e53a35 | 2018-08-31 15:26:35 +0100 | [diff] [blame] | 117 | BOOST_AUTO_TEST_CASE(CreateAdditionFloatWorkload) |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 118 | { |
Matthew Bentham | 955258d | 2018-12-10 10:48:52 +0000 | [diff] [blame] | 119 | NeonCreateElementwiseWorkloadTest<NeonAdditionWorkload, |
David Beck | bc39245 | 2018-09-10 14:47:28 +0100 | [diff] [blame] | 120 | AdditionQueueDescriptor, |
| 121 | AdditionLayer, |
| 122 | DataType::Float32>(); |
| 123 | } |
| 124 | |
| 125 | #ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC |
| 126 | BOOST_AUTO_TEST_CASE(CreateSubtractionFloat16Workload) |
| 127 | { |
Éanna Ó Catháin | d57415d | 2018-11-28 16:24:38 +0000 | [diff] [blame] | 128 | NeonCreateElementwiseWorkloadTest<NeonSubtractionFloatWorkload, |
David Beck | bc39245 | 2018-09-10 14:47:28 +0100 | [diff] [blame] | 129 | SubtractionQueueDescriptor, |
| 130 | SubtractionLayer, |
| 131 | DataType::Float16>(); |
| 132 | } |
| 133 | #endif |
| 134 | |
| 135 | BOOST_AUTO_TEST_CASE(CreateSubtractionFloatWorkload) |
| 136 | { |
Éanna Ó Catháin | d57415d | 2018-11-28 16:24:38 +0000 | [diff] [blame] | 137 | NeonCreateElementwiseWorkloadTest<NeonSubtractionFloatWorkload, |
David Beck | bc39245 | 2018-09-10 14:47:28 +0100 | [diff] [blame] | 138 | SubtractionQueueDescriptor, |
| 139 | SubtractionLayer, |
| 140 | DataType::Float32>(); |
| 141 | } |
| 142 | |
| 143 | #ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC |
| 144 | BOOST_AUTO_TEST_CASE(CreateMultiplicationFloat16Workload) |
| 145 | { |
Éanna Ó Catháin | d57415d | 2018-11-28 16:24:38 +0000 | [diff] [blame] | 146 | NeonCreateElementwiseWorkloadTest<NeonMultiplicationFloatWorkload, |
David Beck | bc39245 | 2018-09-10 14:47:28 +0100 | [diff] [blame] | 147 | MultiplicationQueueDescriptor, |
| 148 | MultiplicationLayer, |
| 149 | DataType::Float16>(); |
| 150 | } |
| 151 | #endif |
| 152 | |
| 153 | BOOST_AUTO_TEST_CASE(CreateMultiplicationFloatWorkload) |
| 154 | { |
Éanna Ó Catháin | d57415d | 2018-11-28 16:24:38 +0000 | [diff] [blame] | 155 | NeonCreateElementwiseWorkloadTest<NeonMultiplicationFloatWorkload, |
David Beck | bc39245 | 2018-09-10 14:47:28 +0100 | [diff] [blame] | 156 | MultiplicationQueueDescriptor, |
| 157 | MultiplicationLayer, |
| 158 | DataType::Float32>(); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 159 | } |
| 160 | |
| 161 | template <typename BatchNormalizationWorkloadType, typename armnn::DataType DataType> |
Nikhil Raj | d134093 | 2018-10-18 14:27:50 +0100 | [diff] [blame] | 162 | static void NeonCreateBatchNormalizationWorkloadTest(DataLayout dataLayout) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 163 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 164 | Graph graph; |
| 165 | NeonWorkloadFactory factory = |
| 166 | NeonWorkloadFactoryHelper::GetFactory(NeonWorkloadFactoryHelper::GetMemoryManager()); |
| 167 | |
Nikhil Raj | d134093 | 2018-10-18 14:27:50 +0100 | [diff] [blame] | 168 | auto workload = CreateBatchNormalizationWorkloadTest<BatchNormalizationWorkloadType, DataType> |
| 169 | (factory, graph, dataLayout); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 170 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 171 | // 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] | 172 | BatchNormalizationQueueDescriptor queueDescriptor = workload->GetData(); |
| 173 | auto inputHandle = boost::polymorphic_downcast<INeonTensorHandle*>(queueDescriptor.m_Inputs[0]); |
| 174 | auto outputHandle = boost::polymorphic_downcast<INeonTensorHandle*>(queueDescriptor.m_Outputs[0]); |
Nikhil Raj | d134093 | 2018-10-18 14:27:50 +0100 | [diff] [blame] | 175 | |
| 176 | TensorShape inputShape = (dataLayout == DataLayout::NCHW) ? TensorShape{2, 3, 4, 4} : TensorShape{2, 4, 4, 3}; |
| 177 | TensorShape outputShape = (dataLayout == DataLayout::NCHW) ? TensorShape{2, 3, 4, 4} : TensorShape{2, 4, 4, 3}; |
| 178 | |
| 179 | BOOST_TEST(TestNeonTensorHandleInfo(inputHandle, TensorInfo(inputShape, DataType))); |
| 180 | BOOST_TEST(TestNeonTensorHandleInfo(outputHandle, TensorInfo(outputShape, DataType))); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 181 | } |
| 182 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 183 | #ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC |
Nikhil Raj | d134093 | 2018-10-18 14:27:50 +0100 | [diff] [blame] | 184 | BOOST_AUTO_TEST_CASE(CreateBatchNormalizationFloat16NchwWorkload) |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 185 | { |
Matthew Bentham | c48ac8c | 2018-12-12 16:15:59 +0000 | [diff] [blame] | 186 | NeonCreateBatchNormalizationWorkloadTest<NeonBatchNormalizationWorkload, DataType::Float16>(DataLayout::NCHW); |
Nikhil Raj | d134093 | 2018-10-18 14:27:50 +0100 | [diff] [blame] | 187 | } |
| 188 | |
| 189 | BOOST_AUTO_TEST_CASE(CreateBatchNormalizationFloat16NhwcWorkload) |
| 190 | { |
Matthew Bentham | c48ac8c | 2018-12-12 16:15:59 +0000 | [diff] [blame] | 191 | NeonCreateBatchNormalizationWorkloadTest<NeonBatchNormalizationWorkload, DataType::Float16>(DataLayout::NHWC); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 192 | } |
| 193 | #endif |
| 194 | |
Nikhil Raj | d134093 | 2018-10-18 14:27:50 +0100 | [diff] [blame] | 195 | BOOST_AUTO_TEST_CASE(CreateBatchNormalizationFloatNchwWorkload) |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 196 | { |
Matthew Bentham | c48ac8c | 2018-12-12 16:15:59 +0000 | [diff] [blame] | 197 | NeonCreateBatchNormalizationWorkloadTest<NeonBatchNormalizationWorkload, DataType::Float32>(DataLayout::NCHW); |
Nikhil Raj | d134093 | 2018-10-18 14:27:50 +0100 | [diff] [blame] | 198 | } |
| 199 | |
| 200 | BOOST_AUTO_TEST_CASE(CreateBatchNormalizationFloatNhwcWorkload) |
| 201 | { |
Matthew Bentham | c48ac8c | 2018-12-12 16:15:59 +0000 | [diff] [blame] | 202 | NeonCreateBatchNormalizationWorkloadTest<NeonBatchNormalizationWorkload, DataType::Float32>(DataLayout::NHWC); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 203 | } |
| 204 | |
Nattapat Chaimanowong | 974b65f | 2018-10-15 15:07:34 +0100 | [diff] [blame] | 205 | template <typename armnn::DataType DataType> |
Francis Murtagh | 0d9d419 | 2018-10-09 16:22:33 +0100 | [diff] [blame] | 206 | static void NeonCreateConvolution2dWorkloadTest(DataLayout dataLayout = DataLayout::NCHW) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 207 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 208 | Graph graph; |
| 209 | NeonWorkloadFactory factory = |
| 210 | NeonWorkloadFactoryHelper::GetFactory(NeonWorkloadFactoryHelper::GetMemoryManager()); |
| 211 | |
| 212 | auto workload = CreateConvolution2dWorkloadTest<NeonConvolution2dWorkload, DataType>(factory, graph, dataLayout); |
Francis Murtagh | 0d9d419 | 2018-10-09 16:22:33 +0100 | [diff] [blame] | 213 | |
| 214 | TensorShape inputShape = (dataLayout == DataLayout::NCHW) ? TensorShape{2, 3, 8, 16} : TensorShape{2, 8, 16, 3}; |
| 215 | 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] | 216 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 217 | // 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] | 218 | Convolution2dQueueDescriptor queueDescriptor = workload->GetData(); |
| 219 | auto inputHandle = boost::polymorphic_downcast<INeonTensorHandle*>(queueDescriptor.m_Inputs[0]); |
| 220 | auto outputHandle = boost::polymorphic_downcast<INeonTensorHandle*>(queueDescriptor.m_Outputs[0]); |
Francis Murtagh | 0d9d419 | 2018-10-09 16:22:33 +0100 | [diff] [blame] | 221 | BOOST_TEST(TestNeonTensorHandleInfo(inputHandle, TensorInfo(inputShape, DataType))); |
| 222 | BOOST_TEST(TestNeonTensorHandleInfo(outputHandle, TensorInfo(outputShape, DataType))); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 223 | } |
| 224 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 225 | #ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC |
Francis Murtagh | 0d9d419 | 2018-10-09 16:22:33 +0100 | [diff] [blame] | 226 | BOOST_AUTO_TEST_CASE(CreateConvolution2dFloat16NchwWorkload) |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 227 | { |
Nattapat Chaimanowong | 974b65f | 2018-10-15 15:07:34 +0100 | [diff] [blame] | 228 | NeonCreateConvolution2dWorkloadTest<DataType::Float16>(); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 229 | } |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 230 | |
Francis Murtagh | 0d9d419 | 2018-10-09 16:22:33 +0100 | [diff] [blame] | 231 | BOOST_AUTO_TEST_CASE(CreateConvolution2dFloat16NhwcWorkload) |
| 232 | { |
Nattapat Chaimanowong | 974b65f | 2018-10-15 15:07:34 +0100 | [diff] [blame] | 233 | NeonCreateConvolution2dWorkloadTest<DataType::Float16>(DataLayout::NHWC); |
Francis Murtagh | 0d9d419 | 2018-10-09 16:22:33 +0100 | [diff] [blame] | 234 | } |
| 235 | |
| 236 | #endif |
| 237 | BOOST_AUTO_TEST_CASE(CreateConvolution2dFloatNchwWorkload) |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 238 | { |
Nattapat Chaimanowong | 974b65f | 2018-10-15 15:07:34 +0100 | [diff] [blame] | 239 | NeonCreateConvolution2dWorkloadTest<DataType::Float32>(); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 240 | } |
| 241 | |
Francis Murtagh | 0d9d419 | 2018-10-09 16:22:33 +0100 | [diff] [blame] | 242 | BOOST_AUTO_TEST_CASE(CreateConvolution2dFloatNhwcWorkload) |
| 243 | { |
Nattapat Chaimanowong | 974b65f | 2018-10-15 15:07:34 +0100 | [diff] [blame] | 244 | NeonCreateConvolution2dWorkloadTest<DataType::Float32>(DataLayout::NHWC); |
Francis Murtagh | 0d9d419 | 2018-10-09 16:22:33 +0100 | [diff] [blame] | 245 | } |
| 246 | |
Nattapat Chaimanowong | 7714088 | 2018-10-17 11:12:19 +0100 | [diff] [blame] | 247 | template <typename armnn::DataType DataType> |
Nikhil Raj | cec6b65 | 2018-10-12 13:51:57 +0100 | [diff] [blame] | 248 | static void NeonCreateDepthWiseConvolutionWorkloadTest(DataLayout dataLayout) |
| 249 | { |
| 250 | Graph graph; |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 251 | NeonWorkloadFactory factory = |
| 252 | NeonWorkloadFactoryHelper::GetFactory(NeonWorkloadFactoryHelper::GetMemoryManager()); |
Nikhil Raj | cec6b65 | 2018-10-12 13:51:57 +0100 | [diff] [blame] | 253 | |
Nattapat Chaimanowong | 7714088 | 2018-10-17 11:12:19 +0100 | [diff] [blame] | 254 | auto workload = CreateDepthwiseConvolution2dWorkloadTest<NeonDepthwiseConvolutionWorkload, |
Nikhil Raj | cec6b65 | 2018-10-12 13:51:57 +0100 | [diff] [blame] | 255 | DataType>(factory, graph, dataLayout); |
| 256 | |
| 257 | // Checks that inputs/outputs are as we expect them (see definition of CreateNormalizationWorkloadTest). |
| 258 | DepthwiseConvolution2dQueueDescriptor queueDescriptor = workload->GetData(); |
| 259 | auto inputHandle = boost::polymorphic_downcast<INeonTensorHandle*>(queueDescriptor.m_Inputs[0]); |
| 260 | auto outputHandle = boost::polymorphic_downcast<INeonTensorHandle*>(queueDescriptor.m_Outputs[0]); |
| 261 | |
| 262 | std::initializer_list<unsigned int> inputShape = (dataLayout == DataLayout::NCHW) |
| 263 | ? std::initializer_list<unsigned int>({ 2, 2, 5, 5 }) |
| 264 | : std::initializer_list<unsigned int>({ 2, 5, 5, 2 }); |
| 265 | std::initializer_list<unsigned int> outputShape = (dataLayout == DataLayout::NCHW) |
| 266 | ? std::initializer_list<unsigned int>({ 2, 2, 5, 5 }) |
| 267 | : std::initializer_list<unsigned int>({ 2, 5, 5, 2 }); |
| 268 | |
| 269 | BOOST_TEST(TestNeonTensorHandleInfo(inputHandle, TensorInfo(inputShape, DataType))); |
| 270 | BOOST_TEST(TestNeonTensorHandleInfo(outputHandle, TensorInfo(outputShape, DataType))); |
| 271 | } |
| 272 | |
| 273 | BOOST_AUTO_TEST_CASE(CreateDepthWiseConvolution2dFloat32NhwcWorkload) |
| 274 | { |
Nattapat Chaimanowong | 7714088 | 2018-10-17 11:12:19 +0100 | [diff] [blame] | 275 | NeonCreateDepthWiseConvolutionWorkloadTest<DataType::Float32>(DataLayout::NHWC); |
Nikhil Raj | cec6b65 | 2018-10-12 13:51:57 +0100 | [diff] [blame] | 276 | } |
| 277 | |
| 278 | #ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC |
| 279 | BOOST_AUTO_TEST_CASE(CreateDepthWiseConvolution2dFloat16NhwcWorkload) |
| 280 | { |
Nattapat Chaimanowong | 7714088 | 2018-10-17 11:12:19 +0100 | [diff] [blame] | 281 | NeonCreateDepthWiseConvolutionWorkloadTest<DataType::Float16>(DataLayout::NHWC); |
Nikhil Raj | cec6b65 | 2018-10-12 13:51:57 +0100 | [diff] [blame] | 282 | } |
| 283 | #endif |
| 284 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 285 | template <typename FullyConnectedWorkloadType, typename armnn::DataType DataType> |
| 286 | static void NeonCreateFullyConnectedWorkloadTest() |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 287 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 288 | Graph graph; |
| 289 | NeonWorkloadFactory factory = |
| 290 | NeonWorkloadFactoryHelper::GetFactory(NeonWorkloadFactoryHelper::GetMemoryManager()); |
| 291 | |
| 292 | auto workload = CreateFullyConnectedWorkloadTest<FullyConnectedWorkloadType, DataType>(factory, graph); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 293 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 294 | // 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] | 295 | FullyConnectedQueueDescriptor queueDescriptor = workload->GetData(); |
| 296 | auto inputHandle = boost::polymorphic_downcast<INeonTensorHandle*>(queueDescriptor.m_Inputs[0]); |
| 297 | auto outputHandle = boost::polymorphic_downcast<INeonTensorHandle*>(queueDescriptor.m_Outputs[0]); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 298 | BOOST_TEST(TestNeonTensorHandleInfo(inputHandle, TensorInfo({3, 1, 4, 5}, DataType))); |
| 299 | BOOST_TEST(TestNeonTensorHandleInfo(outputHandle, TensorInfo({3, 7}, DataType))); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 300 | } |
| 301 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 302 | #ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC |
| 303 | BOOST_AUTO_TEST_CASE(CreateFullyConnectedFloat16Workload) |
| 304 | { |
kevmay01 | e448be3 | 2018-09-26 10:21:55 +0100 | [diff] [blame] | 305 | NeonCreateFullyConnectedWorkloadTest<NeonFullyConnectedWorkload, DataType::Float16>(); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 306 | } |
| 307 | #endif |
| 308 | |
arovir01 | 9e53a35 | 2018-08-31 15:26:35 +0100 | [diff] [blame] | 309 | BOOST_AUTO_TEST_CASE(CreateFullyConnectedFloatWorkload) |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 310 | { |
kevmay01 | e448be3 | 2018-09-26 10:21:55 +0100 | [diff] [blame] | 311 | NeonCreateFullyConnectedWorkloadTest<NeonFullyConnectedWorkload, DataType::Float32>(); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 312 | } |
| 313 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 314 | template <typename NormalizationWorkloadType, typename armnn::DataType DataType> |
narpra01 | 55a97bc | 2018-10-02 14:35:53 +0100 | [diff] [blame] | 315 | static void NeonCreateNormalizationWorkloadTest(DataLayout dataLayout) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 316 | { |
narpra01 | 55a97bc | 2018-10-02 14:35:53 +0100 | [diff] [blame] | 317 | Graph graph; |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 318 | NeonWorkloadFactory factory = |
| 319 | NeonWorkloadFactoryHelper::GetFactory(NeonWorkloadFactoryHelper::GetMemoryManager()); |
| 320 | |
narpra01 | 55a97bc | 2018-10-02 14:35:53 +0100 | [diff] [blame] | 321 | auto workload = CreateNormalizationWorkloadTest<NormalizationWorkloadType, DataType>(factory, graph, dataLayout); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 322 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 323 | // 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] | 324 | NormalizationQueueDescriptor queueDescriptor = workload->GetData(); |
| 325 | auto inputHandle = boost::polymorphic_downcast<INeonTensorHandle*>(queueDescriptor.m_Inputs[0]); |
| 326 | auto outputHandle = boost::polymorphic_downcast<INeonTensorHandle*>(queueDescriptor.m_Outputs[0]); |
Matteo Martincigh | a160b24 | 2018-10-18 10:33:23 +0100 | [diff] [blame] | 327 | |
| 328 | TensorShape inputShape = (dataLayout == DataLayout::NCHW) ? TensorShape{3, 5, 5, 1} : TensorShape{3, 1, 5, 5}; |
| 329 | TensorShape outputShape = (dataLayout == DataLayout::NCHW) ? TensorShape{3, 5, 5, 1} : TensorShape{3, 1, 5, 5}; |
| 330 | |
| 331 | BOOST_TEST(TestNeonTensorHandleInfo(inputHandle, TensorInfo(inputShape, DataType))); |
| 332 | BOOST_TEST(TestNeonTensorHandleInfo(outputHandle, TensorInfo(outputShape, DataType))); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 333 | } |
| 334 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 335 | #ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC |
narpra01 | 55a97bc | 2018-10-02 14:35:53 +0100 | [diff] [blame] | 336 | BOOST_AUTO_TEST_CASE(CreateNormalizationFloat16NchwWorkload) |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 337 | { |
narpra01 | 55a97bc | 2018-10-02 14:35:53 +0100 | [diff] [blame] | 338 | NeonCreateNormalizationWorkloadTest<NeonNormalizationFloatWorkload, DataType::Float16>(DataLayout::NCHW); |
| 339 | } |
| 340 | |
| 341 | BOOST_AUTO_TEST_CASE(CreateNormalizationFloat16NhwcWorkload) |
| 342 | { |
| 343 | NeonCreateNormalizationWorkloadTest<NeonNormalizationFloatWorkload, DataType::Float16>(DataLayout::NHWC); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 344 | } |
| 345 | #endif |
| 346 | |
narpra01 | 55a97bc | 2018-10-02 14:35:53 +0100 | [diff] [blame] | 347 | BOOST_AUTO_TEST_CASE(CreateNormalizationFloatNchwWorkload) |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 348 | { |
narpra01 | 55a97bc | 2018-10-02 14:35:53 +0100 | [diff] [blame] | 349 | NeonCreateNormalizationWorkloadTest<NeonNormalizationFloatWorkload, DataType::Float32>(DataLayout::NCHW); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 350 | } |
| 351 | |
narpra01 | 55a97bc | 2018-10-02 14:35:53 +0100 | [diff] [blame] | 352 | BOOST_AUTO_TEST_CASE(CreateNormalizationFloatNhwcWorkload) |
| 353 | { |
| 354 | NeonCreateNormalizationWorkloadTest<NeonNormalizationFloatWorkload, DataType::Float32>(DataLayout::NHWC); |
| 355 | } |
| 356 | |
| 357 | |
Nattapat Chaimanowong | 5d2e700 | 2018-10-12 16:03:56 +0100 | [diff] [blame] | 358 | template <typename armnn::DataType DataType> |
Nina Drozd | b48e686 | 2018-10-09 12:09:56 +0100 | [diff] [blame] | 359 | static void NeonCreatePooling2dWorkloadTest(DataLayout dataLayout = DataLayout::NCHW) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 360 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 361 | Graph graph; |
| 362 | NeonWorkloadFactory factory = |
| 363 | NeonWorkloadFactoryHelper::GetFactory(NeonWorkloadFactoryHelper::GetMemoryManager()); |
| 364 | |
| 365 | auto workload = CreatePooling2dWorkloadTest<NeonPooling2dWorkload, DataType>(factory, graph, dataLayout); |
Nina Drozd | b48e686 | 2018-10-09 12:09:56 +0100 | [diff] [blame] | 366 | |
| 367 | TensorShape inputShape = (dataLayout == DataLayout::NCHW) ? TensorShape{3, 2, 5, 5} : TensorShape{3, 5, 5, 2}; |
| 368 | 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] | 369 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 370 | // 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] | 371 | Pooling2dQueueDescriptor queueDescriptor = workload->GetData(); |
| 372 | auto inputHandle = boost::polymorphic_downcast<INeonTensorHandle*>(queueDescriptor.m_Inputs[0]); |
| 373 | auto outputHandle = boost::polymorphic_downcast<INeonTensorHandle*>(queueDescriptor.m_Outputs[0]); |
Nina Drozd | b48e686 | 2018-10-09 12:09:56 +0100 | [diff] [blame] | 374 | BOOST_TEST(TestNeonTensorHandleInfo(inputHandle, TensorInfo(inputShape, DataType))); |
| 375 | BOOST_TEST(TestNeonTensorHandleInfo(outputHandle, TensorInfo(outputShape, DataType))); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 376 | } |
| 377 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 378 | #ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC |
| 379 | BOOST_AUTO_TEST_CASE(CreatePooling2dFloat16Workload) |
| 380 | { |
Nattapat Chaimanowong | 5d2e700 | 2018-10-12 16:03:56 +0100 | [diff] [blame] | 381 | NeonCreatePooling2dWorkloadTest<DataType::Float16>(); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 382 | } |
| 383 | #endif |
| 384 | |
Nina Drozd | b48e686 | 2018-10-09 12:09:56 +0100 | [diff] [blame] | 385 | BOOST_AUTO_TEST_CASE(CreatePooling2dFloatNchwWorkload) |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 386 | { |
Nattapat Chaimanowong | 5d2e700 | 2018-10-12 16:03:56 +0100 | [diff] [blame] | 387 | NeonCreatePooling2dWorkloadTest<DataType::Float32>(DataLayout::NCHW); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 388 | } |
| 389 | |
Nina Drozd | b48e686 | 2018-10-09 12:09:56 +0100 | [diff] [blame] | 390 | BOOST_AUTO_TEST_CASE(CreatePooling2dFloatNhwcWorkload) |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 391 | { |
Nattapat Chaimanowong | 5d2e700 | 2018-10-12 16:03:56 +0100 | [diff] [blame] | 392 | NeonCreatePooling2dWorkloadTest<DataType::Float32>(DataLayout::NHWC); |
Nina Drozd | b48e686 | 2018-10-09 12:09:56 +0100 | [diff] [blame] | 393 | } |
| 394 | |
| 395 | BOOST_AUTO_TEST_CASE(CreatePooling2dUint8NchwWorkload) |
| 396 | { |
Nattapat Chaimanowong | 5d2e700 | 2018-10-12 16:03:56 +0100 | [diff] [blame] | 397 | NeonCreatePooling2dWorkloadTest<DataType::QuantisedAsymm8>(DataLayout::NCHW); |
Nina Drozd | b48e686 | 2018-10-09 12:09:56 +0100 | [diff] [blame] | 398 | } |
| 399 | |
| 400 | BOOST_AUTO_TEST_CASE(CreatePooling2dUint8NhwcWorkload) |
| 401 | { |
Nattapat Chaimanowong | 5d2e700 | 2018-10-12 16:03:56 +0100 | [diff] [blame] | 402 | NeonCreatePooling2dWorkloadTest<DataType::QuantisedAsymm8>(DataLayout::NHWC); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 403 | } |
| 404 | |
Nattapat Chaimanowong | cce11fc | 2018-10-12 16:30:56 +0100 | [diff] [blame] | 405 | template <typename armnn::DataType DataType> |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 406 | static void NeonCreateReshapeWorkloadTest() |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 407 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 408 | Graph graph; |
| 409 | NeonWorkloadFactory factory = |
| 410 | NeonWorkloadFactoryHelper::GetFactory(NeonWorkloadFactoryHelper::GetMemoryManager()); |
| 411 | |
| 412 | auto workload = CreateReshapeWorkloadTest<NeonReshapeWorkload, DataType>(factory, graph); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 413 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 414 | // 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] | 415 | ReshapeQueueDescriptor queueDescriptor = workload->GetData(); |
| 416 | auto inputHandle = boost::polymorphic_downcast<INeonTensorHandle*>(queueDescriptor.m_Inputs[0]); |
| 417 | auto outputHandle = boost::polymorphic_downcast<INeonTensorHandle*>(queueDescriptor.m_Outputs[0]); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 418 | BOOST_TEST(TestNeonTensorHandleInfo(inputHandle, TensorInfo({4, 1}, DataType))); |
| 419 | BOOST_TEST(TestNeonTensorHandleInfo(outputHandle, TensorInfo({1, 4}, DataType))); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 420 | } |
| 421 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 422 | #ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC |
| 423 | BOOST_AUTO_TEST_CASE(CreateReshapeFloat16Workload) |
| 424 | { |
Nattapat Chaimanowong | cce11fc | 2018-10-12 16:30:56 +0100 | [diff] [blame] | 425 | NeonCreateReshapeWorkloadTest<DataType::Float16>(); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 426 | } |
| 427 | #endif |
| 428 | |
arovir01 | 9e53a35 | 2018-08-31 15:26:35 +0100 | [diff] [blame] | 429 | BOOST_AUTO_TEST_CASE(CreateReshapeFloatWorkload) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 430 | { |
Nattapat Chaimanowong | cce11fc | 2018-10-12 16:30:56 +0100 | [diff] [blame] | 431 | NeonCreateReshapeWorkloadTest<DataType::Float32>(); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 432 | } |
| 433 | |
| 434 | BOOST_AUTO_TEST_CASE(CreateReshapeUint8Workload) |
| 435 | { |
Nattapat Chaimanowong | cce11fc | 2018-10-12 16:30:56 +0100 | [diff] [blame] | 436 | NeonCreateReshapeWorkloadTest<DataType::QuantisedAsymm8>(); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 437 | } |
| 438 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 439 | template <typename SoftmaxWorkloadType, typename armnn::DataType DataType> |
| 440 | static void NeonCreateSoftmaxWorkloadTest() |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 441 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 442 | Graph graph; |
| 443 | NeonWorkloadFactory factory = |
| 444 | NeonWorkloadFactoryHelper::GetFactory(NeonWorkloadFactoryHelper::GetMemoryManager()); |
| 445 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 446 | auto workload = CreateSoftmaxWorkloadTest<SoftmaxWorkloadType, DataType>(factory, graph); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 447 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 448 | // 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] | 449 | SoftmaxQueueDescriptor queueDescriptor = workload->GetData(); |
| 450 | auto inputHandle = boost::polymorphic_downcast<INeonTensorHandle*>(queueDescriptor.m_Inputs[0]); |
| 451 | auto outputHandle = boost::polymorphic_downcast<INeonTensorHandle*>(queueDescriptor.m_Outputs[0]); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 452 | BOOST_TEST(TestNeonTensorHandleInfo(inputHandle, TensorInfo({4, 1}, DataType))); |
| 453 | BOOST_TEST(TestNeonTensorHandleInfo(outputHandle, TensorInfo({4, 1}, DataType))); |
| 454 | } |
| 455 | |
| 456 | #ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC |
| 457 | BOOST_AUTO_TEST_CASE(CreateSoftmaxFloat16Workload) |
| 458 | { |
arovir01 | 9e53a35 | 2018-08-31 15:26:35 +0100 | [diff] [blame] | 459 | NeonCreateSoftmaxWorkloadTest<NeonSoftmaxFloatWorkload, DataType::Float16>(); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 460 | } |
| 461 | #endif |
| 462 | |
arovir01 | 9e53a35 | 2018-08-31 15:26:35 +0100 | [diff] [blame] | 463 | BOOST_AUTO_TEST_CASE(CreateSoftmaxFloatWorkload) |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 464 | { |
arovir01 | 9e53a35 | 2018-08-31 15:26:35 +0100 | [diff] [blame] | 465 | NeonCreateSoftmaxWorkloadTest<NeonSoftmaxFloatWorkload, DataType::Float32>(); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 466 | } |
| 467 | |
| 468 | BOOST_AUTO_TEST_CASE(CreateSplitterWorkload) |
| 469 | { |
| 470 | Graph graph; |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 471 | NeonWorkloadFactory factory = |
| 472 | NeonWorkloadFactoryHelper::GetFactory(NeonWorkloadFactoryHelper::GetMemoryManager()); |
| 473 | |
Nattapat Chaimanowong | 14766d7 | 2018-10-12 15:09:53 +0100 | [diff] [blame] | 474 | auto workload = CreateSplitterWorkloadTest<NeonSplitterWorkload, DataType::Float32>(factory, graph); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 475 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 476 | // Checks that outputs are as we expect them (see definition of CreateSplitterWorkloadTest). |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 477 | SplitterQueueDescriptor queueDescriptor = workload->GetData(); |
| 478 | auto inputHandle = boost::polymorphic_downcast<INeonTensorHandle*>(queueDescriptor.m_Inputs[0]); |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 479 | BOOST_TEST(TestNeonTensorHandleInfo(inputHandle, TensorInfo({5, 7, 7}, DataType::Float32))); |
| 480 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 481 | auto outputHandle0 = boost::polymorphic_downcast<INeonTensorHandle*>(queueDescriptor.m_Outputs[0]); |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 482 | BOOST_TEST(TestNeonTensorHandleInfo(outputHandle0, TensorInfo({1, 7, 7}, DataType::Float32))); |
| 483 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 484 | auto outputHandle1 = boost::polymorphic_downcast<INeonTensorHandle*>(queueDescriptor.m_Outputs[1]); |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 485 | BOOST_TEST(TestNeonTensorHandleInfo(outputHandle1, TensorInfo({2, 7, 7}, DataType::Float32))); |
| 486 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 487 | auto outputHandle2 = boost::polymorphic_downcast<INeonTensorHandle*>(queueDescriptor.m_Outputs[2]); |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 488 | BOOST_TEST(TestNeonTensorHandleInfo(outputHandle2, TensorInfo({2, 7, 7}, DataType::Float32))); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 489 | } |
| 490 | |
| 491 | BOOST_AUTO_TEST_CASE(CreateSplitterMerger) |
| 492 | { |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 493 | // Tests that it is possible to decide which output of the splitter layer |
| 494 | // should be lined to which input of the merger layer. |
| 495 | // We tested that is is possible to specify 0th output |
| 496 | // of the splitter to be the 1st input to the merger, and the 1st output of the splitter to be 0th input |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 497 | // of the merger. |
| 498 | |
| 499 | Graph graph; |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 500 | NeonWorkloadFactory factory = |
| 501 | NeonWorkloadFactoryHelper::GetFactory(NeonWorkloadFactoryHelper::GetMemoryManager()); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 502 | |
| 503 | auto workloads = |
Nattapat Chaimanowong | 14766d7 | 2018-10-12 15:09:53 +0100 | [diff] [blame] | 504 | CreateSplitterMergerWorkloadTest<NeonSplitterWorkload, NeonMergerWorkload, |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 505 | DataType::Float32>(factory, graph); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 506 | |
| 507 | auto wlSplitter = std::move(workloads.first); |
| 508 | auto wlMerger = std::move(workloads.second); |
| 509 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 510 | //Checks that the index of inputs/outputs matches what we declared on InputDescriptor construction. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 511 | armnn::INeonTensorHandle* sOut0 = dynamic_cast<armnn::INeonTensorHandle*>(wlSplitter->GetData().m_Outputs[0]); |
| 512 | armnn::INeonTensorHandle* sOut1 = dynamic_cast<armnn::INeonTensorHandle*>(wlSplitter->GetData().m_Outputs[1]); |
| 513 | armnn::INeonTensorHandle* mIn0 = dynamic_cast<armnn::INeonTensorHandle*>(wlMerger->GetData().m_Inputs[0]); |
| 514 | armnn::INeonTensorHandle* mIn1 = dynamic_cast<armnn::INeonTensorHandle*>(wlMerger->GetData().m_Inputs[1]); |
| 515 | |
| 516 | BOOST_TEST(sOut0); |
| 517 | BOOST_TEST(sOut1); |
| 518 | BOOST_TEST(mIn0); |
| 519 | BOOST_TEST(mIn1); |
| 520 | |
| 521 | bool validDataPointers = (sOut0 == mIn1) && (sOut1 == mIn0); |
| 522 | |
| 523 | BOOST_TEST(validDataPointers); |
| 524 | } |
| 525 | |
| 526 | BOOST_AUTO_TEST_CASE(CreateSingleOutputMultipleInputs) |
| 527 | { |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 528 | // Tests that it is possible to assign multiple (two) different layers to each of the outputs of a splitter layer. |
| 529 | // 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] | 530 | |
| 531 | Graph graph; |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 532 | NeonWorkloadFactory factory = |
| 533 | NeonWorkloadFactoryHelper::GetFactory(NeonWorkloadFactoryHelper::GetMemoryManager()); |
| 534 | |
Nattapat Chaimanowong | 14766d7 | 2018-10-12 15:09:53 +0100 | [diff] [blame] | 535 | std::unique_ptr<NeonSplitterWorkload> wlSplitter; |
Nattapat Chaimanowong | d4b7059 | 2018-10-12 11:21:49 +0100 | [diff] [blame] | 536 | std::unique_ptr<NeonActivationWorkload> wlActiv0_0; |
| 537 | std::unique_ptr<NeonActivationWorkload> wlActiv0_1; |
| 538 | std::unique_ptr<NeonActivationWorkload> wlActiv1_0; |
| 539 | std::unique_ptr<NeonActivationWorkload> wlActiv1_1; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 540 | |
Nattapat Chaimanowong | 14766d7 | 2018-10-12 15:09:53 +0100 | [diff] [blame] | 541 | CreateSplitterMultipleInputsOneOutputWorkloadTest<NeonSplitterWorkload, |
Nattapat Chaimanowong | d4b7059 | 2018-10-12 11:21:49 +0100 | [diff] [blame] | 542 | NeonActivationWorkload, DataType::Float32>(factory, graph, wlSplitter, wlActiv0_0, wlActiv0_1, |
| 543 | wlActiv1_0, wlActiv1_1); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 544 | |
| 545 | armnn::INeonTensorHandle* sOut0 = dynamic_cast<armnn::INeonTensorHandle*>(wlSplitter->GetData().m_Outputs[0]); |
| 546 | armnn::INeonTensorHandle* sOut1 = dynamic_cast<armnn::INeonTensorHandle*>(wlSplitter->GetData().m_Outputs[1]); |
| 547 | armnn::INeonTensorHandle* activ0_0Im = dynamic_cast<armnn::INeonTensorHandle*>(wlActiv0_0->GetData().m_Inputs[0]); |
| 548 | armnn::INeonTensorHandle* activ0_1Im = dynamic_cast<armnn::INeonTensorHandle*>(wlActiv0_1->GetData().m_Inputs[0]); |
| 549 | armnn::INeonTensorHandle* activ1_0Im = dynamic_cast<armnn::INeonTensorHandle*>(wlActiv1_0->GetData().m_Inputs[0]); |
| 550 | armnn::INeonTensorHandle* activ1_1Im = dynamic_cast<armnn::INeonTensorHandle*>(wlActiv1_1->GetData().m_Inputs[0]); |
| 551 | |
| 552 | |
| 553 | BOOST_TEST(sOut0); |
| 554 | BOOST_TEST(sOut1); |
| 555 | BOOST_TEST(activ0_0Im); |
| 556 | BOOST_TEST(activ0_1Im); |
| 557 | BOOST_TEST(activ1_0Im); |
| 558 | BOOST_TEST(activ1_1Im); |
| 559 | |
| 560 | bool validDataPointers = (sOut0 == activ0_0Im) && (sOut0 == activ0_1Im) && |
| 561 | (sOut1 == activ1_0Im) && (sOut1 == activ1_1Im); |
| 562 | |
| 563 | BOOST_TEST(validDataPointers); |
| 564 | } |
| 565 | |
| 566 | BOOST_AUTO_TEST_CASE(CreateMemCopyWorkloadsNeon) |
| 567 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 568 | NeonWorkloadFactory factory = |
| 569 | NeonWorkloadFactoryHelper::GetFactory(NeonWorkloadFactoryHelper::GetMemoryManager()); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 570 | CreateMemCopyWorkloads<INeonTensorHandle>(factory); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 571 | } |
| 572 | |
Matteo Martincigh | bcd3c85 | 2018-09-28 14:14:12 +0100 | [diff] [blame] | 573 | template <typename L2NormalizationWorkloadType, typename armnn::DataType DataType> |
| 574 | static void NeonCreateL2NormalizationWorkloadTest(DataLayout dataLayout) |
| 575 | { |
Matteo Martincigh | 2400b6d | 2018-10-09 18:19:20 +0100 | [diff] [blame] | 576 | Graph graph; |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 577 | NeonWorkloadFactory factory = |
| 578 | NeonWorkloadFactoryHelper::GetFactory(NeonWorkloadFactoryHelper::GetMemoryManager()); |
| 579 | |
Matteo Martincigh | 2400b6d | 2018-10-09 18:19:20 +0100 | [diff] [blame] | 580 | auto workload = |
| 581 | CreateL2NormalizationWorkloadTest<L2NormalizationWorkloadType, DataType>(factory, graph, dataLayout); |
Matteo Martincigh | bcd3c85 | 2018-09-28 14:14:12 +0100 | [diff] [blame] | 582 | |
| 583 | // Checks that inputs/outputs are as we expect them (see definition of CreateNormalizationWorkloadTest). |
| 584 | L2NormalizationQueueDescriptor queueDescriptor = workload->GetData(); |
| 585 | auto inputHandle = boost::polymorphic_downcast<INeonTensorHandle*>(queueDescriptor.m_Inputs[0]); |
| 586 | auto outputHandle = boost::polymorphic_downcast<INeonTensorHandle*>(queueDescriptor.m_Outputs[0]); |
Matteo Martincigh | 2400b6d | 2018-10-09 18:19:20 +0100 | [diff] [blame] | 587 | |
| 588 | TensorShape inputShape = (dataLayout == DataLayout::NCHW) ? |
| 589 | TensorShape{ 5, 20, 50, 67 } : TensorShape{ 5, 50, 67, 20 }; |
| 590 | TensorShape outputShape = (dataLayout == DataLayout::NCHW) ? |
| 591 | TensorShape{ 5, 20, 50, 67 } : TensorShape{ 5, 50, 67, 20 }; |
| 592 | |
| 593 | BOOST_TEST(TestNeonTensorHandleInfo(inputHandle, TensorInfo(inputShape, DataType))); |
| 594 | BOOST_TEST(TestNeonTensorHandleInfo(outputHandle, TensorInfo(outputShape, DataType))); |
Matteo Martincigh | bcd3c85 | 2018-09-28 14:14:12 +0100 | [diff] [blame] | 595 | } |
| 596 | |
| 597 | #ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC |
| 598 | BOOST_AUTO_TEST_CASE(CreateL2NormalizationFloat16NchwWorkload) |
| 599 | { |
| 600 | NeonCreateL2NormalizationWorkloadTest<NeonL2NormalizationFloatWorkload, DataType::Float16>(DataLayout::NCHW); |
| 601 | } |
| 602 | |
| 603 | BOOST_AUTO_TEST_CASE(CreateL2NormalizationFloat16NhwcWorkload) |
| 604 | { |
| 605 | NeonCreateL2NormalizationWorkloadTest<NeonL2NormalizationFloatWorkload, DataType::Float16>(DataLayout::NHWC); |
| 606 | } |
| 607 | #endif |
| 608 | |
| 609 | BOOST_AUTO_TEST_CASE(CreateL2NormalizationNchwWorkload) |
| 610 | { |
| 611 | NeonCreateL2NormalizationWorkloadTest<NeonL2NormalizationFloatWorkload, DataType::Float32>(DataLayout::NCHW); |
| 612 | } |
| 613 | |
| 614 | BOOST_AUTO_TEST_CASE(CreateL2NormalizationNhwcWorkload) |
| 615 | { |
| 616 | NeonCreateL2NormalizationWorkloadTest<NeonL2NormalizationFloatWorkload, DataType::Float32>(DataLayout::NHWC); |
| 617 | } |
| 618 | |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 619 | template <typename MergerWorkloadType, armnn::DataType DataType> |
| 620 | static void NeonCreateMergerWorkloadTest(std::initializer_list<unsigned int> outputShape, |
| 621 | unsigned int concatAxis) |
| 622 | { |
| 623 | Graph graph; |
| 624 | NeonWorkloadFactory factory = |
| 625 | NeonWorkloadFactoryHelper::GetFactory(NeonWorkloadFactoryHelper::GetMemoryManager()); |
| 626 | |
| 627 | auto workload = CreateMergerWorkloadTest<MergerWorkloadType, DataType>(factory, graph, outputShape, concatAxis); |
| 628 | |
| 629 | MergerQueueDescriptor queueDescriptor = workload->GetData(); |
| 630 | auto inputHandle0 = boost::polymorphic_downcast<INeonTensorHandle*>(queueDescriptor.m_Inputs[0]); |
| 631 | auto inputHandle1 = boost::polymorphic_downcast<INeonTensorHandle*>(queueDescriptor.m_Inputs[1]); |
| 632 | auto outputHandle = boost::polymorphic_downcast<INeonTensorHandle*>(queueDescriptor.m_Outputs[0]); |
| 633 | |
| 634 | BOOST_TEST(TestNeonTensorHandleInfo(inputHandle0, TensorInfo({ 2, 3, 2, 5 }, DataType))); |
| 635 | BOOST_TEST(TestNeonTensorHandleInfo(inputHandle1, TensorInfo({ 2, 3, 2, 5 }, DataType))); |
| 636 | BOOST_TEST(TestNeonTensorHandleInfo(outputHandle, TensorInfo(outputShape, DataType))); |
| 637 | } |
| 638 | |
| 639 | BOOST_AUTO_TEST_CASE(CreateMergerDim0Float32Workload) |
| 640 | { |
| 641 | NeonCreateMergerWorkloadTest<NeonMergerWorkload, armnn::DataType::Float32>({ 4, 3, 2, 5 }, 0); |
| 642 | } |
| 643 | |
| 644 | BOOST_AUTO_TEST_CASE(CreateMergerDim1Float32Workload) |
| 645 | { |
| 646 | NeonCreateMergerWorkloadTest<NeonMergerWorkload, armnn::DataType::Float32>({ 2, 6, 2, 5 }, 1); |
| 647 | } |
| 648 | |
| 649 | BOOST_AUTO_TEST_CASE(CreateMergerDim3Float32Workload) |
| 650 | { |
| 651 | NeonCreateMergerWorkloadTest<NeonMergerWorkload, armnn::DataType::Float32>({ 2, 3, 2, 10 }, 3); |
| 652 | } |
| 653 | |
narpra01 | 63b0882 | 2018-11-20 11:29:12 +0000 | [diff] [blame] | 654 | BOOST_AUTO_TEST_CASE(CreateMergerDim0Uint8Workload) |
| 655 | { |
| 656 | NeonCreateMergerWorkloadTest<NeonMergerWorkload, armnn::DataType::QuantisedAsymm8>({ 4, 3, 2, 5 }, 0); |
| 657 | } |
| 658 | |
| 659 | BOOST_AUTO_TEST_CASE(CreateMergerDim1Uint8Workload) |
| 660 | { |
| 661 | NeonCreateMergerWorkloadTest<NeonMergerWorkload, armnn::DataType::QuantisedAsymm8>({ 2, 6, 2, 5 }, 1); |
| 662 | } |
| 663 | |
| 664 | BOOST_AUTO_TEST_CASE(CreateMergerDim3Uint8Workload) |
| 665 | { |
| 666 | NeonCreateMergerWorkloadTest<NeonMergerWorkload, armnn::DataType::QuantisedAsymm8>({ 2, 3, 2, 10 }, 3); |
| 667 | } |
| 668 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 669 | BOOST_AUTO_TEST_SUITE_END() |