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 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 6 | #include "ClContextControlFixture.hpp" |
Aron Virginas-Tar | 5605519 | 2018-11-12 18:10:43 +0000 | [diff] [blame] | 7 | #include "ClWorkloadFactoryHelper.hpp" |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8 | |
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 <cl/ClTensorHandle.hpp> |
| 14 | #include <cl/ClWorkloadFactory.hpp> |
| 15 | #include <cl/workloads/ClWorkloads.hpp> |
| 16 | #include <cl/workloads/ClWorkloadUtils.hpp> |
arovir01 | 43095f3 | 2018-10-09 18:04:24 +0100 | [diff] [blame] | 17 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 18 | boost::test_tools::predicate_result CompareIClTensorHandleShape(IClTensorHandle* tensorHandle, |
| 19 | std::initializer_list<unsigned int> expectedDimensions) |
| 20 | { |
| 21 | return CompareTensorHandleShape<IClTensorHandle>(tensorHandle, expectedDimensions); |
| 22 | } |
| 23 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 24 | BOOST_FIXTURE_TEST_SUITE(CreateWorkloadCl, ClContextControlFixture) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 25 | |
Nattapat Chaimanowong | e06757e | 2018-10-11 15:39:18 +0100 | [diff] [blame] | 26 | template <armnn::DataType DataType> |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 27 | static void ClCreateActivationWorkloadTest() |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 28 | { |
| 29 | Graph graph; |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 30 | ClWorkloadFactory factory = |
| 31 | ClWorkloadFactoryHelper::GetFactory(ClWorkloadFactoryHelper::GetMemoryManager()); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 32 | |
Nattapat Chaimanowong | e06757e | 2018-10-11 15:39:18 +0100 | [diff] [blame] | 33 | auto workload = CreateActivationWorkloadTest<ClActivationWorkload, DataType>(factory, graph); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 34 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 35 | // Checks that inputs/outputs are as we expect them (see definition of CreateActivationWorkloadTest). |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 36 | ActivationQueueDescriptor queueDescriptor = workload->GetData(); |
| 37 | auto inputHandle = boost::polymorphic_downcast<IClTensorHandle*>(queueDescriptor.m_Inputs[0]); |
| 38 | auto outputHandle = boost::polymorphic_downcast<IClTensorHandle*>(queueDescriptor.m_Outputs[0]); |
| 39 | |
Matthew Bentham | 8910528 | 2018-11-20 14:33:33 +0000 | [diff] [blame] | 40 | BOOST_TEST(CompareIClTensorHandleShape(inputHandle, {1, 1})); |
| 41 | BOOST_TEST(CompareIClTensorHandleShape(outputHandle, {1, 1})); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 42 | } |
| 43 | |
arovir01 | 9e53a35 | 2018-08-31 15:26:35 +0100 | [diff] [blame] | 44 | BOOST_AUTO_TEST_CASE(CreateActivationFloatWorkload) |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 45 | { |
Nattapat Chaimanowong | e06757e | 2018-10-11 15:39:18 +0100 | [diff] [blame] | 46 | ClCreateActivationWorkloadTest<armnn::DataType::Float32>(); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 47 | } |
| 48 | |
| 49 | BOOST_AUTO_TEST_CASE(CreateActivationFloat16Workload) |
| 50 | { |
Nattapat Chaimanowong | e06757e | 2018-10-11 15:39:18 +0100 | [diff] [blame] | 51 | ClCreateActivationWorkloadTest<armnn::DataType::Float16>(); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 52 | } |
| 53 | |
David Beck | 4a8692c | 2018-09-07 16:19:24 +0100 | [diff] [blame] | 54 | template <typename WorkloadType, |
| 55 | typename DescriptorType, |
| 56 | typename LayerType, |
| 57 | armnn::DataType DataType> |
Éanna Ó Catháin | d57415d | 2018-11-28 16:24:38 +0000 | [diff] [blame] | 58 | static void ClCreateElementwiseWorkloadTest() |
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 | ClWorkloadFactory factory = |
| 62 | ClWorkloadFactoryHelper::GetFactory(ClWorkloadFactoryHelper::GetMemoryManager()); |
| 63 | |
Éanna Ó Catháin | d57415d | 2018-11-28 16:24:38 +0000 | [diff] [blame] | 64 | auto workload = CreateElementwiseWorkloadTest<WorkloadType, DescriptorType, LayerType, DataType>(factory, graph); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 65 | |
Éanna Ó Catháin | d57415d | 2018-11-28 16:24:38 +0000 | [diff] [blame] | 66 | // Checks that inputs/outputs are as we expect them (see definition of CreateElementwiseWorkloadTest). |
David Beck | 4a8692c | 2018-09-07 16:19:24 +0100 | [diff] [blame] | 67 | DescriptorType queueDescriptor = workload->GetData(); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 68 | auto inputHandle1 = boost::polymorphic_downcast<IClTensorHandle*>(queueDescriptor.m_Inputs[0]); |
| 69 | auto inputHandle2 = boost::polymorphic_downcast<IClTensorHandle*>(queueDescriptor.m_Inputs[1]); |
| 70 | auto outputHandle = boost::polymorphic_downcast<IClTensorHandle*>(queueDescriptor.m_Outputs[0]); |
| 71 | BOOST_TEST(CompareIClTensorHandleShape(inputHandle1, {2, 3})); |
| 72 | BOOST_TEST(CompareIClTensorHandleShape(inputHandle2, {2, 3})); |
| 73 | BOOST_TEST(CompareIClTensorHandleShape(outputHandle, {2, 3})); |
| 74 | } |
| 75 | |
arovir01 | 9e53a35 | 2018-08-31 15:26:35 +0100 | [diff] [blame] | 76 | BOOST_AUTO_TEST_CASE(CreateAdditionFloatWorkload) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 77 | { |
Éanna Ó Catháin | d57415d | 2018-11-28 16:24:38 +0000 | [diff] [blame] | 78 | ClCreateElementwiseWorkloadTest<ClAdditionWorkload, |
David Beck | 4a8692c | 2018-09-07 16:19:24 +0100 | [diff] [blame] | 79 | AdditionQueueDescriptor, |
| 80 | AdditionLayer, |
| 81 | armnn::DataType::Float32>(); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 82 | } |
| 83 | |
| 84 | BOOST_AUTO_TEST_CASE(CreateAdditionFloat16Workload) |
| 85 | { |
Éanna Ó Catháin | d57415d | 2018-11-28 16:24:38 +0000 | [diff] [blame] | 86 | ClCreateElementwiseWorkloadTest<ClAdditionWorkload, |
David Beck | 4a8692c | 2018-09-07 16:19:24 +0100 | [diff] [blame] | 87 | AdditionQueueDescriptor, |
| 88 | AdditionLayer, |
| 89 | armnn::DataType::Float16>(); |
| 90 | } |
| 91 | |
| 92 | BOOST_AUTO_TEST_CASE(CreateSubtractionFloatWorkload) |
| 93 | { |
Éanna Ó Catháin | d57415d | 2018-11-28 16:24:38 +0000 | [diff] [blame] | 94 | ClCreateElementwiseWorkloadTest<ClSubtractionWorkload, |
David Beck | 4a8692c | 2018-09-07 16:19:24 +0100 | [diff] [blame] | 95 | SubtractionQueueDescriptor, |
| 96 | SubtractionLayer, |
| 97 | armnn::DataType::Float32>(); |
| 98 | } |
| 99 | |
| 100 | BOOST_AUTO_TEST_CASE(CreateSubtractionFloat16Workload) |
| 101 | { |
Éanna Ó Catháin | d57415d | 2018-11-28 16:24:38 +0000 | [diff] [blame] | 102 | ClCreateElementwiseWorkloadTest<ClSubtractionWorkload, |
David Beck | 4a8692c | 2018-09-07 16:19:24 +0100 | [diff] [blame] | 103 | SubtractionQueueDescriptor, |
| 104 | SubtractionLayer, |
| 105 | armnn::DataType::Float16>(); |
| 106 | } |
| 107 | |
| 108 | BOOST_AUTO_TEST_CASE(CreateMultiplicationFloatWorkloadTest) |
| 109 | { |
Éanna Ó Catháin | d57415d | 2018-11-28 16:24:38 +0000 | [diff] [blame] | 110 | ClCreateElementwiseWorkloadTest<ClMultiplicationWorkload, |
David Beck | 4a8692c | 2018-09-07 16:19:24 +0100 | [diff] [blame] | 111 | MultiplicationQueueDescriptor, |
| 112 | MultiplicationLayer, |
| 113 | armnn::DataType::Float32>(); |
| 114 | } |
| 115 | |
| 116 | BOOST_AUTO_TEST_CASE(CreateMultiplicationFloat16WorkloadTest) |
| 117 | { |
Éanna Ó Catháin | d57415d | 2018-11-28 16:24:38 +0000 | [diff] [blame] | 118 | ClCreateElementwiseWorkloadTest<ClMultiplicationWorkload, |
David Beck | 4a8692c | 2018-09-07 16:19:24 +0100 | [diff] [blame] | 119 | MultiplicationQueueDescriptor, |
| 120 | MultiplicationLayer, |
| 121 | armnn::DataType::Float16>(); |
| 122 | } |
| 123 | |
Matthew Bentham | e2ec330 | 2018-10-01 11:32:48 +0100 | [diff] [blame] | 124 | BOOST_AUTO_TEST_CASE(CreateMultiplicationUint8WorkloadTest) |
| 125 | { |
Éanna Ó Catháin | d57415d | 2018-11-28 16:24:38 +0000 | [diff] [blame] | 126 | ClCreateElementwiseWorkloadTest<ClMultiplicationWorkload, |
Matthew Bentham | e2ec330 | 2018-10-01 11:32:48 +0100 | [diff] [blame] | 127 | MultiplicationQueueDescriptor, |
| 128 | MultiplicationLayer, |
| 129 | armnn::DataType::QuantisedAsymm8>(); |
| 130 | } |
| 131 | |
David Beck | 4a8692c | 2018-09-07 16:19:24 +0100 | [diff] [blame] | 132 | BOOST_AUTO_TEST_CASE(CreateDivisionFloatWorkloadTest) |
| 133 | { |
Éanna Ó Catháin | d57415d | 2018-11-28 16:24:38 +0000 | [diff] [blame] | 134 | ClCreateElementwiseWorkloadTest<ClDivisionFloatWorkload, |
David Beck | 4a8692c | 2018-09-07 16:19:24 +0100 | [diff] [blame] | 135 | DivisionQueueDescriptor, |
| 136 | DivisionLayer, |
| 137 | armnn::DataType::Float32>(); |
| 138 | } |
| 139 | |
| 140 | BOOST_AUTO_TEST_CASE(CreateDivisionFloat16WorkloadTest) |
| 141 | { |
Éanna Ó Catháin | d57415d | 2018-11-28 16:24:38 +0000 | [diff] [blame] | 142 | ClCreateElementwiseWorkloadTest<ClDivisionFloatWorkload, |
David Beck | 4a8692c | 2018-09-07 16:19:24 +0100 | [diff] [blame] | 143 | DivisionQueueDescriptor, |
| 144 | DivisionLayer, |
| 145 | armnn::DataType::Float16>(); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 146 | } |
| 147 | |
| 148 | template <typename BatchNormalizationWorkloadType, armnn::DataType DataType> |
Nikhil Raj | d134093 | 2018-10-18 14:27:50 +0100 | [diff] [blame] | 149 | static void ClCreateBatchNormalizationWorkloadTest(DataLayout dataLayout) |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 150 | { |
| 151 | Graph graph; |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 152 | ClWorkloadFactory factory = |
| 153 | ClWorkloadFactoryHelper::GetFactory(ClWorkloadFactoryHelper::GetMemoryManager()); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 154 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 155 | auto workload = CreateBatchNormalizationWorkloadTest<BatchNormalizationWorkloadType, DataType> |
Nikhil Raj | d134093 | 2018-10-18 14:27:50 +0100 | [diff] [blame] | 156 | (factory, graph, dataLayout); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 157 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 158 | // Checks that inputs/outputs are as we expect them (see definition of CreateBatchNormalizationWorkloadTest). |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 159 | BatchNormalizationQueueDescriptor queueDescriptor = workload->GetData(); |
| 160 | auto inputHandle = boost::polymorphic_downcast<IClTensorHandle*>(queueDescriptor.m_Inputs[0]); |
| 161 | auto outputHandle = boost::polymorphic_downcast<IClTensorHandle*>(queueDescriptor.m_Outputs[0]); |
| 162 | |
Nikhil Raj | d134093 | 2018-10-18 14:27:50 +0100 | [diff] [blame] | 163 | switch (dataLayout) |
| 164 | { |
| 165 | case DataLayout::NHWC: |
| 166 | BOOST_TEST(CompareIClTensorHandleShape(inputHandle, { 2, 4, 4, 3 })); |
| 167 | BOOST_TEST(CompareIClTensorHandleShape(outputHandle, { 2, 4, 4, 3 })); |
| 168 | break; |
| 169 | default: // NCHW |
| 170 | BOOST_TEST(CompareIClTensorHandleShape(inputHandle, { 2, 3, 4, 4 })); |
| 171 | BOOST_TEST(CompareIClTensorHandleShape(outputHandle, { 2, 3, 4, 4 })); |
| 172 | } |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 173 | } |
| 174 | |
Nikhil Raj | d134093 | 2018-10-18 14:27:50 +0100 | [diff] [blame] | 175 | BOOST_AUTO_TEST_CASE(CreateBatchNormalizationFloatNchwWorkload) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 176 | { |
Nikhil Raj | d134093 | 2018-10-18 14:27:50 +0100 | [diff] [blame] | 177 | ClCreateBatchNormalizationWorkloadTest<ClBatchNormalizationFloatWorkload, |
| 178 | armnn::DataType::Float32>(DataLayout::NCHW); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 179 | } |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 180 | |
Nikhil Raj | d134093 | 2018-10-18 14:27:50 +0100 | [diff] [blame] | 181 | BOOST_AUTO_TEST_CASE(CreateBatchNormalizationFloat16NchwWorkload) |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 182 | { |
Nikhil Raj | d134093 | 2018-10-18 14:27:50 +0100 | [diff] [blame] | 183 | ClCreateBatchNormalizationWorkloadTest<ClBatchNormalizationFloatWorkload, |
| 184 | armnn::DataType::Float16>(DataLayout::NCHW); |
| 185 | } |
| 186 | |
| 187 | BOOST_AUTO_TEST_CASE(CreateBatchNormalizationFloatNhwcWorkload) |
| 188 | { |
| 189 | ClCreateBatchNormalizationWorkloadTest<ClBatchNormalizationFloatWorkload, |
| 190 | armnn::DataType::Float32>(DataLayout::NHWC); |
| 191 | } |
| 192 | |
| 193 | BOOST_AUTO_TEST_CASE(CreateBatchNormalizationNhwcFloat16NhwcWorkload) |
| 194 | { |
| 195 | ClCreateBatchNormalizationWorkloadTest<ClBatchNormalizationFloatWorkload, |
| 196 | armnn::DataType::Float16>(DataLayout::NHWC); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 197 | } |
| 198 | |
| 199 | BOOST_AUTO_TEST_CASE(CreateConvertFp16ToFp32Workload) |
| 200 | { |
| 201 | Graph graph; |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 202 | ClWorkloadFactory factory = |
| 203 | ClWorkloadFactoryHelper::GetFactory(ClWorkloadFactoryHelper::GetMemoryManager()); |
| 204 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 205 | auto workload = CreateConvertFp16ToFp32WorkloadTest<ClConvertFp16ToFp32Workload>(factory, graph); |
| 206 | |
| 207 | ConvertFp16ToFp32QueueDescriptor queueDescriptor = workload->GetData(); |
| 208 | auto inputHandle = boost::polymorphic_downcast<IClTensorHandle*>(queueDescriptor.m_Inputs[0]); |
| 209 | auto outputHandle = boost::polymorphic_downcast<IClTensorHandle*>(queueDescriptor.m_Outputs[0]); |
| 210 | |
Matthew Bentham | 8910528 | 2018-11-20 14:33:33 +0000 | [diff] [blame] | 211 | BOOST_TEST(CompareIClTensorHandleShape(inputHandle, {1, 3, 2, 3})); |
| 212 | BOOST_TEST(CompareIClTensorHandleShape(outputHandle, {1, 3, 2, 3})); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 213 | BOOST_TEST((inputHandle->GetTensor().info()->data_type() == arm_compute::DataType::F16)); |
| 214 | BOOST_TEST((outputHandle->GetTensor().info()->data_type() == arm_compute::DataType::F32)); |
| 215 | } |
| 216 | |
| 217 | BOOST_AUTO_TEST_CASE(CreateConvertFp32ToFp16Workload) |
| 218 | { |
| 219 | Graph graph; |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 220 | ClWorkloadFactory factory = |
| 221 | ClWorkloadFactoryHelper::GetFactory(ClWorkloadFactoryHelper::GetMemoryManager()); |
| 222 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 223 | auto workload = CreateConvertFp32ToFp16WorkloadTest<ClConvertFp32ToFp16Workload>(factory, graph); |
| 224 | |
| 225 | ConvertFp32ToFp16QueueDescriptor queueDescriptor = workload->GetData(); |
| 226 | auto inputHandle = boost::polymorphic_downcast<IClTensorHandle*>(queueDescriptor.m_Inputs[0]); |
| 227 | auto outputHandle = boost::polymorphic_downcast<IClTensorHandle*>(queueDescriptor.m_Outputs[0]); |
| 228 | |
Matthew Bentham | 8910528 | 2018-11-20 14:33:33 +0000 | [diff] [blame] | 229 | BOOST_TEST(CompareIClTensorHandleShape(inputHandle, {1, 3, 2, 3})); |
| 230 | BOOST_TEST(CompareIClTensorHandleShape(outputHandle, {1, 3, 2, 3})); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 231 | BOOST_TEST((inputHandle->GetTensor().info()->data_type() == arm_compute::DataType::F32)); |
| 232 | BOOST_TEST((outputHandle->GetTensor().info()->data_type() == arm_compute::DataType::F16)); |
| 233 | } |
| 234 | |
Francis Murtagh | 0d9d419 | 2018-10-09 16:22:33 +0100 | [diff] [blame] | 235 | template <typename Convolution2dWorkloadType, typename armnn::DataType DataType> |
| 236 | static void ClConvolution2dWorkloadTest(DataLayout dataLayout) |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 237 | { |
| 238 | Graph graph; |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 239 | ClWorkloadFactory factory = |
| 240 | ClWorkloadFactoryHelper::GetFactory(ClWorkloadFactoryHelper::GetMemoryManager()); |
| 241 | |
Francis Murtagh | 0d9d419 | 2018-10-09 16:22:33 +0100 | [diff] [blame] | 242 | auto workload = CreateConvolution2dWorkloadTest<ClConvolution2dWorkload, DataType>(factory, |
| 243 | graph, |
| 244 | dataLayout); |
| 245 | |
| 246 | std::initializer_list<unsigned int> inputShape = (dataLayout == DataLayout::NCHW) ? |
| 247 | std::initializer_list<unsigned int>({2, 3, 8, 16}) : std::initializer_list<unsigned int>({2, 8, 16, 3}); |
| 248 | std::initializer_list<unsigned int> outputShape = (dataLayout == DataLayout::NCHW) ? |
| 249 | std::initializer_list<unsigned int>({2, 2, 2, 10}) : std::initializer_list<unsigned int>({2, 2, 10, 2}); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 250 | |
| 251 | // 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] | 252 | Convolution2dQueueDescriptor queueDescriptor = workload->GetData(); |
| 253 | auto inputHandle = boost::polymorphic_downcast<IClTensorHandle*>(queueDescriptor.m_Inputs[0]); |
| 254 | auto outputHandle = boost::polymorphic_downcast<IClTensorHandle*>(queueDescriptor.m_Outputs[0]); |
Francis Murtagh | 0d9d419 | 2018-10-09 16:22:33 +0100 | [diff] [blame] | 255 | BOOST_TEST(CompareIClTensorHandleShape(inputHandle, inputShape)); |
| 256 | BOOST_TEST(CompareIClTensorHandleShape(outputHandle, outputShape)); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 257 | } |
| 258 | |
Francis Murtagh | 0d9d419 | 2018-10-09 16:22:33 +0100 | [diff] [blame] | 259 | BOOST_AUTO_TEST_CASE(CreateConvolution2dFloatNchwWorkload) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 260 | { |
Francis Murtagh | 0d9d419 | 2018-10-09 16:22:33 +0100 | [diff] [blame] | 261 | ClConvolution2dWorkloadTest<ClConvolution2dWorkload, armnn::DataType::Float32>(DataLayout::NCHW); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 262 | } |
| 263 | |
Francis Murtagh | 0d9d419 | 2018-10-09 16:22:33 +0100 | [diff] [blame] | 264 | BOOST_AUTO_TEST_CASE(CreateConvolution2dFloatNhwcWorkload) |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 265 | { |
Francis Murtagh | 0d9d419 | 2018-10-09 16:22:33 +0100 | [diff] [blame] | 266 | ClConvolution2dWorkloadTest<ClConvolution2dWorkload, armnn::DataType::Float32>(DataLayout::NHWC); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 267 | } |
| 268 | |
Francis Murtagh | 0d9d419 | 2018-10-09 16:22:33 +0100 | [diff] [blame] | 269 | BOOST_AUTO_TEST_CASE(CreateConvolution2dFloat16NchwWorkload) |
| 270 | { |
| 271 | ClConvolution2dWorkloadTest<ClConvolution2dWorkload, armnn::DataType::Float16>(DataLayout::NCHW); |
| 272 | } |
| 273 | |
| 274 | BOOST_AUTO_TEST_CASE(CreateConvolution2dFloat16NhwcWorkload) |
| 275 | { |
| 276 | ClConvolution2dWorkloadTest<ClConvolution2dWorkload, armnn::DataType::Float16>(DataLayout::NHWC); |
| 277 | } |
| 278 | |
Nikhil Raj | cec6b65 | 2018-10-12 13:51:57 +0100 | [diff] [blame] | 279 | template <typename DepthwiseConvolutionWorkloadType, typename armnn::DataType DataType> |
| 280 | static void ClDepthwiseConvolutionWorkloadTest(DataLayout dataLayout) |
| 281 | { |
| 282 | Graph graph; |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 283 | ClWorkloadFactory factory = |
| 284 | ClWorkloadFactoryHelper::GetFactory(ClWorkloadFactoryHelper::GetMemoryManager()); |
Nikhil Raj | cec6b65 | 2018-10-12 13:51:57 +0100 | [diff] [blame] | 285 | |
| 286 | auto workload = CreateDepthwiseConvolution2dWorkloadTest<DepthwiseConvolutionWorkloadType, DataType> |
| 287 | (factory, graph, dataLayout); |
| 288 | |
| 289 | // Checks that inputs/outputs are as we expect them (see definition of CreateDepthwiseConvolution2dWorkloadTest). |
| 290 | DepthwiseConvolution2dQueueDescriptor queueDescriptor = workload->GetData(); |
| 291 | auto inputHandle = boost::polymorphic_downcast<IClTensorHandle*>(queueDescriptor.m_Inputs[0]); |
| 292 | auto outputHandle = boost::polymorphic_downcast<IClTensorHandle*>(queueDescriptor.m_Outputs[0]); |
| 293 | |
| 294 | std::initializer_list<unsigned int> inputShape = (dataLayout == DataLayout::NCHW) |
| 295 | ? std::initializer_list<unsigned int>({ 2, 2, 5, 5 }) |
| 296 | : std::initializer_list<unsigned int>({ 2, 5, 5, 2 }); |
| 297 | std::initializer_list<unsigned int> outputShape = (dataLayout == DataLayout::NCHW) |
| 298 | ? std::initializer_list<unsigned int>({ 2, 2, 5, 5 }) |
| 299 | : std::initializer_list<unsigned int>({ 2, 5, 5, 2 }); |
| 300 | |
| 301 | BOOST_TEST(CompareIClTensorHandleShape(inputHandle, inputShape)); |
| 302 | BOOST_TEST(CompareIClTensorHandleShape(outputHandle, outputShape)); |
| 303 | } |
| 304 | |
| 305 | BOOST_AUTO_TEST_CASE(CreateDepthwiseConvolutionFloat32NhwcWorkload) |
| 306 | { |
| 307 | ClDepthwiseConvolutionWorkloadTest<ClDepthwiseConvolutionWorkload, DataType::Float32>(DataLayout::NHWC); |
| 308 | } |
| 309 | |
Francis Murtagh | 0d9d419 | 2018-10-09 16:22:33 +0100 | [diff] [blame] | 310 | template <typename Convolution2dWorkloadType, typename armnn::DataType DataType> |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 311 | static void ClDirectConvolution2dWorkloadTest() |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 312 | { |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 313 | Graph graph; |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 314 | ClWorkloadFactory factory = |
| 315 | ClWorkloadFactoryHelper::GetFactory(ClWorkloadFactoryHelper::GetMemoryManager()); |
| 316 | |
Matthew Bentham | d806792 | 2018-10-03 17:18:04 +0100 | [diff] [blame] | 317 | auto workload = CreateDirectConvolution2dWorkloadTest<ClConvolution2dWorkload, DataType>(factory, graph); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 318 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 319 | // Checks that outputs and inputs are as we expect them (see definition of CreateDirectConvolution2dWorkloadTest). |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 320 | Convolution2dQueueDescriptor queueDescriptor = workload->GetData(); |
| 321 | auto inputHandle = boost::polymorphic_downcast<IClTensorHandle*>(queueDescriptor.m_Inputs[0]); |
| 322 | auto outputHandle = boost::polymorphic_downcast<IClTensorHandle*>(queueDescriptor.m_Outputs[0]); |
| 323 | BOOST_TEST(CompareIClTensorHandleShape(inputHandle, {2, 3, 6, 6})); |
| 324 | BOOST_TEST(CompareIClTensorHandleShape(outputHandle, {2, 2, 6, 6})); |
| 325 | } |
| 326 | |
arovir01 | 9e53a35 | 2018-08-31 15:26:35 +0100 | [diff] [blame] | 327 | BOOST_AUTO_TEST_CASE(CreateDirectConvolution2dFloatWorkload) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 328 | { |
Francis Murtagh | 0d9d419 | 2018-10-09 16:22:33 +0100 | [diff] [blame] | 329 | ClDirectConvolution2dWorkloadTest<ClConvolution2dWorkload, armnn::DataType::Float32>(); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 330 | } |
| 331 | |
| 332 | BOOST_AUTO_TEST_CASE(CreateDirectConvolution2dFloat16Workload) |
| 333 | { |
Francis Murtagh | 0d9d419 | 2018-10-09 16:22:33 +0100 | [diff] [blame] | 334 | ClDirectConvolution2dWorkloadTest<ClConvolution2dWorkload, armnn::DataType::Float16>(); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 335 | } |
| 336 | |
| 337 | BOOST_AUTO_TEST_CASE(CreateDirectConvolution2dUint8Workload) |
| 338 | { |
Francis Murtagh | 0d9d419 | 2018-10-09 16:22:33 +0100 | [diff] [blame] | 339 | ClDirectConvolution2dWorkloadTest<ClConvolution2dWorkload, armnn::DataType::QuantisedAsymm8>(); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 340 | } |
| 341 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 342 | template <typename FullyConnectedWorkloadType, typename armnn::DataType DataType> |
| 343 | static void ClCreateFullyConnectedWorkloadTest() |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 344 | { |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 345 | Graph graph; |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 346 | ClWorkloadFactory factory = |
| 347 | ClWorkloadFactoryHelper::GetFactory(ClWorkloadFactoryHelper::GetMemoryManager()); |
| 348 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 349 | auto workload = |
| 350 | CreateFullyConnectedWorkloadTest<FullyConnectedWorkloadType, DataType>(factory, graph); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 351 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 352 | // 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] | 353 | FullyConnectedQueueDescriptor queueDescriptor = workload->GetData(); |
| 354 | auto inputHandle = boost::polymorphic_downcast<IClTensorHandle*>(queueDescriptor.m_Inputs[0]); |
| 355 | auto outputHandle = boost::polymorphic_downcast<IClTensorHandle*>(queueDescriptor.m_Outputs[0]); |
| 356 | BOOST_TEST(CompareIClTensorHandleShape(inputHandle, {3, 1, 4, 5})); |
| 357 | BOOST_TEST(CompareIClTensorHandleShape(outputHandle, {3, 7})); |
| 358 | } |
| 359 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 360 | |
arovir01 | 9e53a35 | 2018-08-31 15:26:35 +0100 | [diff] [blame] | 361 | BOOST_AUTO_TEST_CASE(CreateFullyConnectedFloatWorkloadTest) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 362 | { |
Matthew Bentham | ab8cdc1 | 2018-09-17 11:17:41 +0100 | [diff] [blame] | 363 | ClCreateFullyConnectedWorkloadTest<ClFullyConnectedWorkload, armnn::DataType::Float32>(); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 364 | } |
| 365 | |
| 366 | BOOST_AUTO_TEST_CASE(CreateFullyConnectedFloat16WorkloadTest) |
| 367 | { |
Matthew Bentham | ab8cdc1 | 2018-09-17 11:17:41 +0100 | [diff] [blame] | 368 | ClCreateFullyConnectedWorkloadTest<ClFullyConnectedWorkload, armnn::DataType::Float16>(); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 369 | } |
| 370 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 371 | template <typename NormalizationWorkloadType, typename armnn::DataType DataType> |
narpra01 | 55a97bc | 2018-10-02 14:35:53 +0100 | [diff] [blame] | 372 | static void ClNormalizationWorkloadTest(DataLayout dataLayout) |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 373 | { |
| 374 | Graph graph; |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 375 | ClWorkloadFactory factory = |
| 376 | ClWorkloadFactoryHelper::GetFactory(ClWorkloadFactoryHelper::GetMemoryManager()); |
| 377 | |
Matteo Martincigh | a160b24 | 2018-10-18 10:33:23 +0100 | [diff] [blame] | 378 | auto workload = CreateNormalizationWorkloadTest<NormalizationWorkloadType, DataType>(factory, graph, dataLayout); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 379 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 380 | // Checks that inputs/outputs are as we expect them (see definition of CreateNormalizationWorkloadTest). |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 381 | NormalizationQueueDescriptor queueDescriptor = workload->GetData(); |
| 382 | auto inputHandle = boost::polymorphic_downcast<IClTensorHandle*>(queueDescriptor.m_Inputs[0]); |
| 383 | auto outputHandle = boost::polymorphic_downcast<IClTensorHandle*>(queueDescriptor.m_Outputs[0]); |
| 384 | |
Matteo Martincigh | a160b24 | 2018-10-18 10:33:23 +0100 | [diff] [blame] | 385 | std::initializer_list<unsigned int> inputShape = (dataLayout == DataLayout::NCHW) ? |
| 386 | std::initializer_list<unsigned int>({3, 5, 5, 1}) : std::initializer_list<unsigned int>({3, 1, 5, 5}); |
| 387 | std::initializer_list<unsigned int> outputShape = (dataLayout == DataLayout::NCHW) ? |
| 388 | std::initializer_list<unsigned int>({3, 5, 5, 1}) : std::initializer_list<unsigned int>({3, 1, 5, 5}); |
| 389 | |
| 390 | BOOST_TEST(CompareIClTensorHandleShape(inputHandle, inputShape)); |
| 391 | BOOST_TEST(CompareIClTensorHandleShape(outputHandle, outputShape)); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 392 | } |
| 393 | |
narpra01 | 55a97bc | 2018-10-02 14:35:53 +0100 | [diff] [blame] | 394 | BOOST_AUTO_TEST_CASE(CreateNormalizationFloat32NchwWorkload) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 395 | { |
narpra01 | 55a97bc | 2018-10-02 14:35:53 +0100 | [diff] [blame] | 396 | ClNormalizationWorkloadTest<ClNormalizationFloatWorkload, armnn::DataType::Float32>(DataLayout::NCHW); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 397 | } |
| 398 | |
narpra01 | 55a97bc | 2018-10-02 14:35:53 +0100 | [diff] [blame] | 399 | BOOST_AUTO_TEST_CASE(CreateNormalizationFloat16NchwWorkload) |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 400 | { |
narpra01 | 55a97bc | 2018-10-02 14:35:53 +0100 | [diff] [blame] | 401 | ClNormalizationWorkloadTest<ClNormalizationFloatWorkload, armnn::DataType::Float16>(DataLayout::NCHW); |
| 402 | } |
| 403 | |
| 404 | BOOST_AUTO_TEST_CASE(CreateNormalizationFloat32NhwcWorkload) |
| 405 | { |
| 406 | ClNormalizationWorkloadTest<ClNormalizationFloatWorkload, armnn::DataType::Float32>(DataLayout::NHWC); |
| 407 | } |
| 408 | |
| 409 | BOOST_AUTO_TEST_CASE(CreateNormalizationFloat16NhwcWorkload) |
| 410 | { |
| 411 | ClNormalizationWorkloadTest<ClNormalizationFloatWorkload, armnn::DataType::Float16>(DataLayout::NHWC); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 412 | } |
| 413 | |
Nattapat Chaimanowong | ac9e096 | 2018-10-10 17:18:35 +0100 | [diff] [blame] | 414 | template <typename armnn::DataType DataType> |
Nina Drozd | b48e686 | 2018-10-09 12:09:56 +0100 | [diff] [blame] | 415 | static void ClPooling2dWorkloadTest(DataLayout dataLayout) |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 416 | { |
| 417 | Graph graph; |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 418 | ClWorkloadFactory factory = |
| 419 | ClWorkloadFactoryHelper::GetFactory(ClWorkloadFactoryHelper::GetMemoryManager()); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 420 | |
Nattapat Chaimanowong | ac9e096 | 2018-10-10 17:18:35 +0100 | [diff] [blame] | 421 | auto workload = CreatePooling2dWorkloadTest<ClPooling2dWorkload, DataType>(factory, graph, dataLayout); |
Nina Drozd | b48e686 | 2018-10-09 12:09:56 +0100 | [diff] [blame] | 422 | |
| 423 | std::initializer_list<unsigned int> inputShape = (dataLayout == DataLayout::NCHW) ? |
| 424 | std::initializer_list<unsigned int>({3, 2, 5, 5}) : std::initializer_list<unsigned int>({3, 5, 5, 2}); |
| 425 | std::initializer_list<unsigned int> outputShape = (dataLayout == DataLayout::NCHW) ? |
| 426 | std::initializer_list<unsigned int>({3, 2, 2, 4}) : std::initializer_list<unsigned int>({3, 2, 4, 2}); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 427 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 428 | // Check that inputs/outputs are as we expect them (see definition of CreatePooling2dWorkloadTest). |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 429 | Pooling2dQueueDescriptor queueDescriptor = workload->GetData(); |
| 430 | auto inputHandle = boost::polymorphic_downcast<IClTensorHandle*>(queueDescriptor.m_Inputs[0]); |
| 431 | auto outputHandle = boost::polymorphic_downcast<IClTensorHandle*>(queueDescriptor.m_Outputs[0]); |
| 432 | |
Nina Drozd | b48e686 | 2018-10-09 12:09:56 +0100 | [diff] [blame] | 433 | BOOST_TEST(CompareIClTensorHandleShape(inputHandle, inputShape)); |
| 434 | BOOST_TEST(CompareIClTensorHandleShape(outputHandle, outputShape)); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 435 | } |
| 436 | |
Nina Drozd | b48e686 | 2018-10-09 12:09:56 +0100 | [diff] [blame] | 437 | BOOST_AUTO_TEST_CASE(CreatePooling2dFloatNchwWorkload) |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 438 | { |
Nattapat Chaimanowong | ac9e096 | 2018-10-10 17:18:35 +0100 | [diff] [blame] | 439 | ClPooling2dWorkloadTest<armnn::DataType::Float32>(DataLayout::NCHW); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 440 | } |
| 441 | |
Nina Drozd | b48e686 | 2018-10-09 12:09:56 +0100 | [diff] [blame] | 442 | BOOST_AUTO_TEST_CASE(CreatePooling2dFloatNhwcWorkload) |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 443 | { |
Nattapat Chaimanowong | ac9e096 | 2018-10-10 17:18:35 +0100 | [diff] [blame] | 444 | ClPooling2dWorkloadTest<armnn::DataType::Float32>(DataLayout::NHWC); |
Nina Drozd | b48e686 | 2018-10-09 12:09:56 +0100 | [diff] [blame] | 445 | } |
| 446 | |
| 447 | BOOST_AUTO_TEST_CASE(CreatePooling2dFloat16NchwWorkload) |
| 448 | { |
Nattapat Chaimanowong | ac9e096 | 2018-10-10 17:18:35 +0100 | [diff] [blame] | 449 | ClPooling2dWorkloadTest<armnn::DataType::Float16>(DataLayout::NCHW); |
Nina Drozd | b48e686 | 2018-10-09 12:09:56 +0100 | [diff] [blame] | 450 | } |
| 451 | |
| 452 | BOOST_AUTO_TEST_CASE(CreatePooling2dFloat16NhwcWorkload) |
| 453 | { |
Nattapat Chaimanowong | ac9e096 | 2018-10-10 17:18:35 +0100 | [diff] [blame] | 454 | ClPooling2dWorkloadTest<armnn::DataType::Float16>(DataLayout::NHWC); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 455 | } |
| 456 | |
Nattapat Chaimanowong | a76698c | 2018-10-11 10:29:15 +0100 | [diff] [blame] | 457 | template <typename armnn::DataType DataType> |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 458 | static void ClCreateReshapeWorkloadTest() |
| 459 | { |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 460 | Graph graph; |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 461 | ClWorkloadFactory factory = |
| 462 | ClWorkloadFactoryHelper::GetFactory(ClWorkloadFactoryHelper::GetMemoryManager()); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 463 | |
Nattapat Chaimanowong | a76698c | 2018-10-11 10:29:15 +0100 | [diff] [blame] | 464 | auto workload = CreateReshapeWorkloadTest<ClReshapeWorkload, DataType>(factory, graph); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 465 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 466 | // 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] | 467 | ReshapeQueueDescriptor queueDescriptor = workload->GetData(); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 468 | auto inputHandle = boost::polymorphic_downcast<IClTensorHandle*>(queueDescriptor.m_Inputs[0]); |
| 469 | auto outputHandle = boost::polymorphic_downcast<IClTensorHandle*>(queueDescriptor.m_Outputs[0]); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 470 | |
| 471 | BOOST_TEST(CompareIClTensorHandleShape(inputHandle, {4, 1})); |
Matthew Bentham | 8910528 | 2018-11-20 14:33:33 +0000 | [diff] [blame] | 472 | BOOST_TEST(CompareIClTensorHandleShape(outputHandle, {1, 4})); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 473 | } |
| 474 | |
arovir01 | 9e53a35 | 2018-08-31 15:26:35 +0100 | [diff] [blame] | 475 | BOOST_AUTO_TEST_CASE(CreateReshapeFloatWorkload) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 476 | { |
Nattapat Chaimanowong | a76698c | 2018-10-11 10:29:15 +0100 | [diff] [blame] | 477 | ClCreateReshapeWorkloadTest<armnn::DataType::Float32>(); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 478 | } |
| 479 | |
| 480 | BOOST_AUTO_TEST_CASE(CreateReshapeFloat16Workload) |
| 481 | { |
Nattapat Chaimanowong | a76698c | 2018-10-11 10:29:15 +0100 | [diff] [blame] | 482 | ClCreateReshapeWorkloadTest<armnn::DataType::Float16>(); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 483 | } |
| 484 | |
| 485 | BOOST_AUTO_TEST_CASE(CreateReshapeUint8Workload) |
| 486 | { |
Nattapat Chaimanowong | a76698c | 2018-10-11 10:29:15 +0100 | [diff] [blame] | 487 | ClCreateReshapeWorkloadTest<armnn::DataType::QuantisedAsymm8>(); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 488 | } |
| 489 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 490 | template <typename SoftmaxWorkloadType, typename armnn::DataType DataType> |
| 491 | static void ClSoftmaxWorkloadTest() |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 492 | { |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 493 | Graph graph; |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 494 | ClWorkloadFactory factory = |
| 495 | ClWorkloadFactoryHelper::GetFactory(ClWorkloadFactoryHelper::GetMemoryManager()); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 496 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 497 | auto workload = CreateSoftmaxWorkloadTest<SoftmaxWorkloadType, DataType>(factory, graph); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 498 | |
arovir01 | 9e53a35 | 2018-08-31 15:26:35 +0100 | [diff] [blame] | 499 | // Checks that inputs/outputs are as we expect them (see definition of ClSoftmaxFloatWorkload). |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 500 | SoftmaxQueueDescriptor queueDescriptor = workload->GetData(); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 501 | auto inputHandle = boost::polymorphic_downcast<IClTensorHandle*>(queueDescriptor.m_Inputs[0]); |
| 502 | auto outputHandle = boost::polymorphic_downcast<IClTensorHandle*>(queueDescriptor.m_Outputs[0]); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 503 | |
| 504 | BOOST_TEST(CompareIClTensorHandleShape(inputHandle, {4, 1})); |
| 505 | BOOST_TEST(CompareIClTensorHandleShape(outputHandle, {4, 1})); |
| 506 | } |
| 507 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 508 | |
arovir01 | 9e53a35 | 2018-08-31 15:26:35 +0100 | [diff] [blame] | 509 | BOOST_AUTO_TEST_CASE(CreateSoftmaxFloatWorkloadTest) |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 510 | { |
arovir01 | 9e53a35 | 2018-08-31 15:26:35 +0100 | [diff] [blame] | 511 | ClSoftmaxWorkloadTest<ClSoftmaxFloatWorkload, armnn::DataType::Float32>(); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 512 | } |
| 513 | |
| 514 | BOOST_AUTO_TEST_CASE(CreateSoftmaxFloat16WorkloadTest) |
| 515 | { |
arovir01 | 9e53a35 | 2018-08-31 15:26:35 +0100 | [diff] [blame] | 516 | ClSoftmaxWorkloadTest<ClSoftmaxFloatWorkload, armnn::DataType::Float16>(); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 517 | } |
| 518 | |
Matthew Bentham | 29cadb3 | 2018-10-01 17:22:32 +0100 | [diff] [blame] | 519 | template <typename armnn::DataType DataType> |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 520 | static void ClSplitterWorkloadTest() |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 521 | { |
| 522 | Graph graph; |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 523 | ClWorkloadFactory factory = |
| 524 | ClWorkloadFactoryHelper::GetFactory(ClWorkloadFactoryHelper::GetMemoryManager()); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 525 | |
Matthew Bentham | 29cadb3 | 2018-10-01 17:22:32 +0100 | [diff] [blame] | 526 | auto workload = CreateSplitterWorkloadTest<ClSplitterWorkload, DataType>(factory, graph); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 527 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 528 | // Checks that outputs are as we expect them (see definition of CreateSplitterWorkloadTest). |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 529 | SplitterQueueDescriptor queueDescriptor = workload->GetData(); |
| 530 | auto inputHandle = boost::polymorphic_downcast<IClTensorHandle*>(queueDescriptor.m_Inputs[0]); |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 531 | BOOST_TEST(CompareIClTensorHandleShape(inputHandle, {5, 7, 7})); |
| 532 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 533 | auto outputHandle1 = boost::polymorphic_downcast<IClTensorHandle*>(queueDescriptor.m_Outputs[1]); |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 534 | BOOST_TEST(CompareIClTensorHandleShape(outputHandle1, {2, 7, 7})); |
| 535 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 536 | auto outputHandle2 = boost::polymorphic_downcast<IClTensorHandle*>(queueDescriptor.m_Outputs[2]); |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 537 | BOOST_TEST(CompareIClTensorHandleShape(outputHandle2, {2, 7, 7})); |
| 538 | |
| 539 | auto outputHandle0 = boost::polymorphic_downcast<IClTensorHandle*>(queueDescriptor.m_Outputs[0]); |
Matthew Bentham | 8910528 | 2018-11-20 14:33:33 +0000 | [diff] [blame] | 540 | BOOST_TEST(CompareIClTensorHandleShape(outputHandle0, {1, 7, 7})); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 541 | } |
| 542 | |
arovir01 | 9e53a35 | 2018-08-31 15:26:35 +0100 | [diff] [blame] | 543 | BOOST_AUTO_TEST_CASE(CreateSplitterFloatWorkload) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 544 | { |
Matthew Bentham | 29cadb3 | 2018-10-01 17:22:32 +0100 | [diff] [blame] | 545 | ClSplitterWorkloadTest<armnn::DataType::Float32>(); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 546 | } |
| 547 | |
| 548 | BOOST_AUTO_TEST_CASE(CreateSplitterFloat16Workload) |
| 549 | { |
Matthew Bentham | 29cadb3 | 2018-10-01 17:22:32 +0100 | [diff] [blame] | 550 | ClSplitterWorkloadTest<armnn::DataType::Float16>(); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 551 | } |
| 552 | |
Nattapat Chaimanowong | 02f8bc1 | 2018-10-11 16:16:17 +0100 | [diff] [blame] | 553 | template <typename armnn::DataType DataType> |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 554 | static void ClSplitterMergerTest() |
| 555 | { |
| 556 | // Tests that it is possible to decide which output of the splitter layer |
| 557 | // should be lined to which input of the merger layer. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 558 | // We test that is is possible to specify 0th output |
| 559 | // of the splitter to be the 1st input to the merger and the 1st output of the splitter to be 0th input |
| 560 | // of the merger. |
| 561 | |
| 562 | Graph graph; |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 563 | ClWorkloadFactory factory = |
| 564 | ClWorkloadFactoryHelper::GetFactory(ClWorkloadFactoryHelper::GetMemoryManager()); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 565 | |
| 566 | auto workloads = |
Nattapat Chaimanowong | 02f8bc1 | 2018-10-11 16:16:17 +0100 | [diff] [blame] | 567 | CreateSplitterMergerWorkloadTest<ClSplitterWorkload, ClMergerWorkload, DataType> |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 568 | (factory, graph); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 569 | |
| 570 | auto wlSplitter = std::move(workloads.first); |
| 571 | auto wlMerger = std::move(workloads.second); |
| 572 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 573 | //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] | 574 | armnn::ClSubTensorHandle* sOut0 = dynamic_cast<armnn::ClSubTensorHandle*>(wlSplitter->GetData().m_Outputs[0]); |
| 575 | armnn::ClSubTensorHandle* sOut1 = dynamic_cast<armnn::ClSubTensorHandle*>(wlSplitter->GetData().m_Outputs[1]); |
| 576 | armnn::ClSubTensorHandle* mIn0 = dynamic_cast<armnn::ClSubTensorHandle*>(wlMerger->GetData().m_Inputs[0]); |
| 577 | armnn::ClSubTensorHandle* mIn1 = dynamic_cast<armnn::ClSubTensorHandle*>(wlMerger->GetData().m_Inputs[1]); |
| 578 | |
| 579 | BOOST_TEST(sOut0); |
| 580 | BOOST_TEST(sOut1); |
| 581 | BOOST_TEST(mIn0); |
| 582 | BOOST_TEST(mIn1); |
| 583 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 584 | //Fliped order of inputs/outputs. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 585 | bool validDataPointers = (sOut0 == mIn1) && (sOut1 == mIn0); |
| 586 | BOOST_TEST(validDataPointers); |
| 587 | |
| 588 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 589 | //Also make sure that the inputs are subtensors of one tensor and outputs are sub tensors of another tensor. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 590 | bool validSubTensorParents = (mIn0->GetTensor().parent() == mIn1->GetTensor().parent()) |
| 591 | && (sOut0->GetTensor().parent() == sOut1->GetTensor().parent()); |
| 592 | |
| 593 | BOOST_TEST(validSubTensorParents); |
| 594 | } |
| 595 | |
arovir01 | 9e53a35 | 2018-08-31 15:26:35 +0100 | [diff] [blame] | 596 | BOOST_AUTO_TEST_CASE(CreateSplitterMergerFloatWorkload) |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 597 | { |
Nattapat Chaimanowong | 02f8bc1 | 2018-10-11 16:16:17 +0100 | [diff] [blame] | 598 | ClSplitterMergerTest<armnn::DataType::Float32>(); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 599 | } |
| 600 | |
| 601 | BOOST_AUTO_TEST_CASE(CreateSplitterMergerFloat16Workload) |
| 602 | { |
Nattapat Chaimanowong | 02f8bc1 | 2018-10-11 16:16:17 +0100 | [diff] [blame] | 603 | ClSplitterMergerTest<armnn::DataType::Float16>(); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 604 | } |
| 605 | |
| 606 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 607 | BOOST_AUTO_TEST_CASE(CreateSingleOutputMultipleInputs) |
| 608 | { |
| 609 | // Test that it is possible to assign multiple (two) different layers to each of the outputs of a splitter layer. |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 610 | // We create 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] | 611 | |
| 612 | Graph graph; |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 613 | ClWorkloadFactory factory = |
| 614 | ClWorkloadFactoryHelper::GetFactory(ClWorkloadFactoryHelper::GetMemoryManager()); |
| 615 | |
Matthew Bentham | 29cadb3 | 2018-10-01 17:22:32 +0100 | [diff] [blame] | 616 | std::unique_ptr<ClSplitterWorkload> wlSplitter; |
Nattapat Chaimanowong | e06757e | 2018-10-11 15:39:18 +0100 | [diff] [blame] | 617 | std::unique_ptr<ClActivationWorkload> wlActiv0_0; |
| 618 | std::unique_ptr<ClActivationWorkload> wlActiv0_1; |
| 619 | std::unique_ptr<ClActivationWorkload> wlActiv1_0; |
| 620 | std::unique_ptr<ClActivationWorkload> wlActiv1_1; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 621 | |
Matthew Bentham | 29cadb3 | 2018-10-01 17:22:32 +0100 | [diff] [blame] | 622 | CreateSplitterMultipleInputsOneOutputWorkloadTest<ClSplitterWorkload, |
Nattapat Chaimanowong | e06757e | 2018-10-11 15:39:18 +0100 | [diff] [blame] | 623 | ClActivationWorkload, armnn::DataType::Float32>(factory, graph, wlSplitter, wlActiv0_0, wlActiv0_1, |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 624 | wlActiv1_0, wlActiv1_1); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 625 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 626 | //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] | 627 | armnn::ClSubTensorHandle* sOut0 = dynamic_cast<armnn::ClSubTensorHandle*>(wlSplitter->GetData().m_Outputs[0]); |
| 628 | armnn::ClSubTensorHandle* sOut1 = dynamic_cast<armnn::ClSubTensorHandle*>(wlSplitter->GetData().m_Outputs[1]); |
| 629 | armnn::ClSubTensorHandle* activ0_0Im = dynamic_cast<armnn::ClSubTensorHandle*>(wlActiv0_0->GetData().m_Inputs[0]); |
| 630 | armnn::ClSubTensorHandle* activ0_1Im = dynamic_cast<armnn::ClSubTensorHandle*>(wlActiv0_1->GetData().m_Inputs[0]); |
| 631 | armnn::ClSubTensorHandle* activ1_0Im = dynamic_cast<armnn::ClSubTensorHandle*>(wlActiv1_0->GetData().m_Inputs[0]); |
| 632 | armnn::ClSubTensorHandle* activ1_1Im = dynamic_cast<armnn::ClSubTensorHandle*>(wlActiv1_1->GetData().m_Inputs[0]); |
| 633 | |
| 634 | |
| 635 | BOOST_TEST(sOut0); |
| 636 | BOOST_TEST(sOut1); |
| 637 | BOOST_TEST(activ0_0Im); |
| 638 | BOOST_TEST(activ0_1Im); |
| 639 | BOOST_TEST(activ1_0Im); |
| 640 | BOOST_TEST(activ1_1Im); |
| 641 | |
| 642 | bool validDataPointers = (sOut0 == activ0_0Im) && (sOut0 == activ0_1Im) && |
| 643 | (sOut1 == activ1_0Im) && (sOut1 == activ1_1Im); |
| 644 | |
| 645 | BOOST_TEST(validDataPointers); |
| 646 | } |
| 647 | |
| 648 | BOOST_AUTO_TEST_CASE(CreateMemCopyWorkloadsCl) |
| 649 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 650 | ClWorkloadFactory factory = |
| 651 | ClWorkloadFactoryHelper::GetFactory(ClWorkloadFactoryHelper::GetMemoryManager()); |
| 652 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 653 | CreateMemCopyWorkloads<IClTensorHandle>(factory); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 654 | } |
| 655 | |
Matteo Martincigh | bcd3c85 | 2018-09-28 14:14:12 +0100 | [diff] [blame] | 656 | template <typename L2NormalizationWorkloadType, typename armnn::DataType DataType> |
| 657 | static void ClL2NormalizationWorkloadTest(DataLayout dataLayout) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 658 | { |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 659 | Graph graph; |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 660 | ClWorkloadFactory factory = |
| 661 | ClWorkloadFactoryHelper::GetFactory(ClWorkloadFactoryHelper::GetMemoryManager()); |
| 662 | |
Matteo Martincigh | 2400b6d | 2018-10-09 18:19:20 +0100 | [diff] [blame] | 663 | auto workload = |
| 664 | CreateL2NormalizationWorkloadTest<L2NormalizationWorkloadType, DataType>(factory, graph, dataLayout); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 665 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 666 | // Checks that inputs/outputs are as we expect them (see definition of CreateNormalizationWorkloadTest). |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 667 | L2NormalizationQueueDescriptor queueDescriptor = workload->GetData(); |
| 668 | auto inputHandle = boost::polymorphic_downcast<IClTensorHandle*>(queueDescriptor.m_Inputs[0]); |
| 669 | auto outputHandle = boost::polymorphic_downcast<IClTensorHandle*>(queueDescriptor.m_Outputs[0]); |
| 670 | |
Matteo Martincigh | 2400b6d | 2018-10-09 18:19:20 +0100 | [diff] [blame] | 671 | std::initializer_list<unsigned int> inputShape = (dataLayout == DataLayout::NCHW) |
| 672 | ? std::initializer_list<unsigned int>({ 5, 20, 50, 67 }) |
| 673 | : std::initializer_list<unsigned int>({ 5, 50, 67, 20 }); |
| 674 | std::initializer_list<unsigned int> outputShape = (dataLayout == DataLayout::NCHW) |
| 675 | ? std::initializer_list<unsigned int>({ 5, 20, 50, 67 }) |
| 676 | : std::initializer_list<unsigned int>({ 5, 50, 67, 20 }); |
| 677 | |
| 678 | BOOST_TEST(CompareIClTensorHandleShape(inputHandle, inputShape)); |
| 679 | BOOST_TEST(CompareIClTensorHandleShape(outputHandle, outputShape)); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 680 | } |
| 681 | |
Matteo Martincigh | bcd3c85 | 2018-09-28 14:14:12 +0100 | [diff] [blame] | 682 | BOOST_AUTO_TEST_CASE(CreateL2NormalizationFloatNchwWorkload) |
| 683 | { |
| 684 | ClL2NormalizationWorkloadTest<ClL2NormalizationFloatWorkload, armnn::DataType::Float32>(DataLayout::NCHW); |
| 685 | } |
| 686 | |
| 687 | BOOST_AUTO_TEST_CASE(CreateL2NormalizationFloatNhwcWorkload) |
| 688 | { |
| 689 | ClL2NormalizationWorkloadTest<ClL2NormalizationFloatWorkload, armnn::DataType::Float32>(DataLayout::NHWC); |
| 690 | } |
| 691 | |
| 692 | BOOST_AUTO_TEST_CASE(CreateL2NormalizationFloat16NchwWorkload) |
| 693 | { |
| 694 | ClL2NormalizationWorkloadTest<ClL2NormalizationFloatWorkload, armnn::DataType::Float16>(DataLayout::NCHW); |
| 695 | } |
| 696 | |
| 697 | BOOST_AUTO_TEST_CASE(CreateL2NormalizationFloat16NhwcWorkload) |
| 698 | { |
| 699 | ClL2NormalizationWorkloadTest<ClL2NormalizationFloatWorkload, armnn::DataType::Float16>(DataLayout::NHWC); |
| 700 | } |
| 701 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 702 | template <typename LstmWorkloadType> |
| 703 | static void ClCreateLstmWorkloadTest() |
| 704 | { |
| 705 | Graph graph; |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 706 | ClWorkloadFactory factory = |
| 707 | ClWorkloadFactoryHelper::GetFactory(ClWorkloadFactoryHelper::GetMemoryManager()); |
| 708 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 709 | auto workload = CreateLstmWorkloadTest<LstmWorkloadType>(factory, graph); |
| 710 | |
| 711 | LstmQueueDescriptor queueDescriptor = workload->GetData(); |
| 712 | auto inputHandle = boost::polymorphic_downcast<IClTensorHandle*>(queueDescriptor.m_Inputs[0]); |
| 713 | auto outputHandle = boost::polymorphic_downcast<IClTensorHandle*>(queueDescriptor.m_Outputs[1]); |
| 714 | BOOST_TEST(CompareIClTensorHandleShape(inputHandle, { 2, 2 })); |
| 715 | BOOST_TEST(CompareIClTensorHandleShape(outputHandle, { 2, 4 })); |
| 716 | } |
| 717 | |
arovir01 | 9e53a35 | 2018-08-31 15:26:35 +0100 | [diff] [blame] | 718 | BOOST_AUTO_TEST_CASE(CreateLSTMWorkloadFloatWorkload) |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 719 | { |
arovir01 | 9e53a35 | 2018-08-31 15:26:35 +0100 | [diff] [blame] | 720 | ClCreateLstmWorkloadTest<ClLstmFloatWorkload>(); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 721 | } |
| 722 | |
James Conroy | 074f371 | 2018-10-03 09:32:03 +0100 | [diff] [blame] | 723 | template <typename ResizeBilinearWorkloadType, typename armnn::DataType DataType> |
| 724 | static void ClResizeBilinearWorkloadTest(DataLayout dataLayout) |
| 725 | { |
| 726 | Graph graph; |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 727 | ClWorkloadFactory factory = |
| 728 | ClWorkloadFactoryHelper::GetFactory(ClWorkloadFactoryHelper::GetMemoryManager()); |
James Conroy | 074f371 | 2018-10-03 09:32:03 +0100 | [diff] [blame] | 729 | |
| 730 | auto workload = CreateResizeBilinearWorkloadTest<ResizeBilinearWorkloadType, DataType>(factory, graph, dataLayout); |
| 731 | |
| 732 | // Checks that inputs/outputs are as we expect them (see definition of CreateResizeBilinearWorkloadTest). |
| 733 | ResizeBilinearQueueDescriptor queueDescriptor = workload->GetData(); |
| 734 | auto inputHandle = boost::polymorphic_downcast<IClTensorHandle*>(queueDescriptor.m_Inputs[0]); |
| 735 | auto outputHandle = boost::polymorphic_downcast<IClTensorHandle*>(queueDescriptor.m_Outputs[0]); |
| 736 | |
| 737 | switch (dataLayout) |
| 738 | { |
| 739 | case DataLayout::NHWC: |
| 740 | BOOST_TEST(CompareIClTensorHandleShape(inputHandle, { 2, 4, 4, 3 })); |
| 741 | BOOST_TEST(CompareIClTensorHandleShape(outputHandle, { 2, 2, 2, 3 })); |
| 742 | break; |
James Conroy | 6948227 | 2018-10-19 10:41:35 +0100 | [diff] [blame] | 743 | case DataLayout::NCHW: |
| 744 | default: |
James Conroy | 074f371 | 2018-10-03 09:32:03 +0100 | [diff] [blame] | 745 | BOOST_TEST(CompareIClTensorHandleShape(inputHandle, { 2, 3, 4, 4 })); |
| 746 | BOOST_TEST(CompareIClTensorHandleShape(outputHandle, { 2, 3, 2, 2 })); |
| 747 | } |
| 748 | } |
| 749 | |
| 750 | BOOST_AUTO_TEST_CASE(CreateResizeBilinearFloat32NchwWorkload) |
| 751 | { |
| 752 | ClResizeBilinearWorkloadTest<ClResizeBilinearFloatWorkload, armnn::DataType::Float32>(DataLayout::NCHW); |
| 753 | } |
| 754 | |
| 755 | BOOST_AUTO_TEST_CASE(CreateResizeBilinearFloat16NchwWorkload) |
| 756 | { |
| 757 | ClResizeBilinearWorkloadTest<ClResizeBilinearFloatWorkload, armnn::DataType::Float16>(DataLayout::NCHW); |
| 758 | } |
| 759 | |
| 760 | BOOST_AUTO_TEST_CASE(CreateResizeBilinearFloat32NhwcWorkload) |
| 761 | { |
| 762 | ClResizeBilinearWorkloadTest<ClResizeBilinearFloatWorkload, armnn::DataType::Float32>(DataLayout::NHWC); |
| 763 | } |
| 764 | |
| 765 | BOOST_AUTO_TEST_CASE(CreateResizeBilinearFloat16NhwcWorkload) |
| 766 | { |
| 767 | ClResizeBilinearWorkloadTest<ClResizeBilinearFloatWorkload, armnn::DataType::Float16>(DataLayout::NHWC); |
| 768 | } |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 769 | |
Matteo Martincigh | 28dcab6 | 2018-10-19 16:40:03 +0100 | [diff] [blame] | 770 | template <typename MeanWorkloadType, typename armnn::DataType DataType> |
| 771 | static void ClMeanWorkloadTest() |
| 772 | { |
| 773 | Graph graph; |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 774 | ClWorkloadFactory factory = |
| 775 | ClWorkloadFactoryHelper::GetFactory(ClWorkloadFactoryHelper::GetMemoryManager()); |
| 776 | |
Matteo Martincigh | 28dcab6 | 2018-10-19 16:40:03 +0100 | [diff] [blame] | 777 | auto workload = CreateMeanWorkloadTest<MeanWorkloadType, DataType>(factory, graph); |
| 778 | |
| 779 | // Checks that inputs/outputs are as we expect them (see definition of CreateMeanWorkloadTest). |
| 780 | MeanQueueDescriptor queueDescriptor = workload->GetData(); |
| 781 | auto inputHandle = boost::polymorphic_downcast<IClTensorHandle*>(queueDescriptor.m_Inputs[0]); |
| 782 | auto outputHandle = boost::polymorphic_downcast<IClTensorHandle*>(queueDescriptor.m_Outputs[0]); |
| 783 | |
| 784 | // The first dimension (batch size) in both input and output is singular thus it has been reduced by ACL. |
Matthew Bentham | 8910528 | 2018-11-20 14:33:33 +0000 | [diff] [blame] | 785 | BOOST_TEST(CompareIClTensorHandleShape(inputHandle, { 1, 3, 7, 4 })); |
| 786 | BOOST_TEST(CompareIClTensorHandleShape(outputHandle, { 1, 4 })); |
Matteo Martincigh | 28dcab6 | 2018-10-19 16:40:03 +0100 | [diff] [blame] | 787 | } |
| 788 | |
| 789 | BOOST_AUTO_TEST_CASE(CreateMeanFloat32Workload) |
| 790 | { |
| 791 | ClMeanWorkloadTest<ClMeanWorkload, armnn::DataType::Float32>(); |
| 792 | } |
| 793 | |
| 794 | BOOST_AUTO_TEST_CASE(CreateMeanFloat16Workload) |
| 795 | { |
| 796 | ClMeanWorkloadTest<ClMeanWorkload, armnn::DataType::Float16>(); |
| 797 | } |
| 798 | |
| 799 | BOOST_AUTO_TEST_CASE(CreateMeanUint8Workload) |
| 800 | { |
| 801 | ClMeanWorkloadTest<ClMeanWorkload, armnn::DataType::QuantisedAsymm8>(); |
| 802 | } |
| 803 | |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 804 | template <typename MergerWorkloadType, armnn::DataType DataType> |
| 805 | static void ClCreateMergerWorkloadTest(std::initializer_list<unsigned int> outputShape, |
| 806 | unsigned int concatAxis) |
| 807 | { |
| 808 | Graph graph; |
| 809 | ClWorkloadFactory factory = |
| 810 | ClWorkloadFactoryHelper::GetFactory(ClWorkloadFactoryHelper::GetMemoryManager()); |
| 811 | |
| 812 | auto workload = CreateMergerWorkloadTest<MergerWorkloadType, DataType>(factory, graph, outputShape, concatAxis); |
| 813 | |
| 814 | MergerQueueDescriptor queueDescriptor = workload->GetData(); |
| 815 | auto inputHandle0 = boost::polymorphic_downcast<IClTensorHandle*>(queueDescriptor.m_Inputs[0]); |
| 816 | auto inputHandle1 = boost::polymorphic_downcast<IClTensorHandle*>(queueDescriptor.m_Inputs[1]); |
| 817 | auto outputHandle = boost::polymorphic_downcast<IClTensorHandle*>(queueDescriptor.m_Outputs[0]); |
| 818 | |
| 819 | BOOST_TEST(CompareIClTensorHandleShape(inputHandle0, { 2, 3, 2, 5 })); |
| 820 | BOOST_TEST(CompareIClTensorHandleShape(inputHandle1, { 2, 3, 2, 5 })); |
| 821 | BOOST_TEST(CompareIClTensorHandleShape(outputHandle, outputShape)); |
| 822 | } |
| 823 | |
| 824 | BOOST_AUTO_TEST_CASE(CreateMergerDim0Float32Workload) |
| 825 | { |
| 826 | ClCreateMergerWorkloadTest<ClMergerWorkload, armnn::DataType::Float32>({ 4, 3, 2, 5 }, 0); |
| 827 | } |
| 828 | |
| 829 | BOOST_AUTO_TEST_CASE(CreateMergerDim1Float32Workload) |
| 830 | { |
| 831 | ClCreateMergerWorkloadTest<ClMergerWorkload, armnn::DataType::Float32>({ 2, 6, 2, 5 }, 1); |
| 832 | } |
| 833 | |
| 834 | BOOST_AUTO_TEST_CASE(CreateMergerDim3Float32Workload) |
| 835 | { |
| 836 | ClCreateMergerWorkloadTest<ClMergerWorkload, armnn::DataType::Float32>({ 2, 3, 2, 10 }, 3); |
| 837 | } |
| 838 | |
narpra01 | 63b0882 | 2018-11-20 11:29:12 +0000 | [diff] [blame] | 839 | BOOST_AUTO_TEST_CASE(CreateMergerDim0Uint8Workload) |
| 840 | { |
| 841 | ClCreateMergerWorkloadTest<ClMergerWorkload, armnn::DataType::QuantisedAsymm8>({ 4, 3, 2, 5 }, 0); |
| 842 | } |
| 843 | |
| 844 | BOOST_AUTO_TEST_CASE(CreateMergerDim1Uint8Workload) |
| 845 | { |
| 846 | ClCreateMergerWorkloadTest<ClMergerWorkload, armnn::DataType::QuantisedAsymm8>({ 2, 6, 2, 5 }, 1); |
| 847 | } |
| 848 | |
| 849 | BOOST_AUTO_TEST_CASE(CreateMergerDim3Uint8Workload) |
| 850 | { |
| 851 | ClCreateMergerWorkloadTest<ClMergerWorkload, armnn::DataType::QuantisedAsymm8>({ 2, 3, 2, 10 }, 3); |
| 852 | } |
| 853 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 854 | BOOST_AUTO_TEST_SUITE_END() |