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 | |
Jan Eilers | bb446e5 | 2020-04-02 13:56:54 +0100 | [diff] [blame] | 9 | #include <armnn/utility/PolymorphicDowncast.hpp> |
Aron Virginas-Tar | c9cc804 | 2018-11-01 16:15:57 +0000 | [diff] [blame] | 10 | #include <backendsCommon/MemCopyWorkload.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 <aclCommon/test/CreateWorkloadClNeon.hpp> |
Ferran Balaguer | 737d9ff | 2019-08-01 09:58:08 +0100 | [diff] [blame] | 13 | #include <aclCommon/ArmComputeTensorUtils.hpp> |
Aron Virginas-Tar | 3b278e9 | 2018-10-12 13:00:55 +0100 | [diff] [blame] | 14 | |
Aron Virginas-Tar | c9cc804 | 2018-11-01 16:15:57 +0000 | [diff] [blame] | 15 | #include <cl/ClTensorHandle.hpp> |
| 16 | #include <cl/ClWorkloadFactory.hpp> |
| 17 | #include <cl/workloads/ClWorkloads.hpp> |
| 18 | #include <cl/workloads/ClWorkloadUtils.hpp> |
arovir01 | 43095f3 | 2018-10-09 18:04:24 +0100 | [diff] [blame] | 19 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 20 | boost::test_tools::predicate_result CompareIClTensorHandleShape(IClTensorHandle* tensorHandle, |
| 21 | std::initializer_list<unsigned int> expectedDimensions) |
| 22 | { |
| 23 | return CompareTensorHandleShape<IClTensorHandle>(tensorHandle, expectedDimensions); |
| 24 | } |
| 25 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 26 | BOOST_FIXTURE_TEST_SUITE(CreateWorkloadCl, ClContextControlFixture) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 27 | |
Nattapat Chaimanowong | e06757e | 2018-10-11 15:39:18 +0100 | [diff] [blame] | 28 | template <armnn::DataType DataType> |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 29 | static void ClCreateActivationWorkloadTest() |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 30 | { |
| 31 | Graph graph; |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 32 | ClWorkloadFactory factory = |
| 33 | ClWorkloadFactoryHelper::GetFactory(ClWorkloadFactoryHelper::GetMemoryManager()); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 34 | |
Nattapat Chaimanowong | e06757e | 2018-10-11 15:39:18 +0100 | [diff] [blame] | 35 | auto workload = CreateActivationWorkloadTest<ClActivationWorkload, DataType>(factory, graph); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 36 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 37 | // Checks that inputs/outputs are as we expect them (see definition of CreateActivationWorkloadTest). |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 38 | ActivationQueueDescriptor queueDescriptor = workload->GetData(); |
Jan Eilers | bb446e5 | 2020-04-02 13:56:54 +0100 | [diff] [blame] | 39 | auto inputHandle = PolymorphicDowncast<IClTensorHandle*>(queueDescriptor.m_Inputs[0]); |
| 40 | auto outputHandle = PolymorphicDowncast<IClTensorHandle*>(queueDescriptor.m_Outputs[0]); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 41 | |
Matthew Bentham | 8910528 | 2018-11-20 14:33:33 +0000 | [diff] [blame] | 42 | BOOST_TEST(CompareIClTensorHandleShape(inputHandle, {1, 1})); |
| 43 | BOOST_TEST(CompareIClTensorHandleShape(outputHandle, {1, 1})); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 44 | } |
| 45 | |
arovir01 | 9e53a35 | 2018-08-31 15:26:35 +0100 | [diff] [blame] | 46 | BOOST_AUTO_TEST_CASE(CreateActivationFloatWorkload) |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 47 | { |
Nattapat Chaimanowong | e06757e | 2018-10-11 15:39:18 +0100 | [diff] [blame] | 48 | ClCreateActivationWorkloadTest<armnn::DataType::Float32>(); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 49 | } |
| 50 | |
| 51 | BOOST_AUTO_TEST_CASE(CreateActivationFloat16Workload) |
| 52 | { |
Nattapat Chaimanowong | e06757e | 2018-10-11 15:39:18 +0100 | [diff] [blame] | 53 | ClCreateActivationWorkloadTest<armnn::DataType::Float16>(); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 54 | } |
| 55 | |
David Beck | 4a8692c | 2018-09-07 16:19:24 +0100 | [diff] [blame] | 56 | template <typename WorkloadType, |
| 57 | typename DescriptorType, |
| 58 | typename LayerType, |
| 59 | armnn::DataType DataType> |
Éanna Ó Catháin | d57415d | 2018-11-28 16:24:38 +0000 | [diff] [blame] | 60 | static void ClCreateElementwiseWorkloadTest() |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 61 | { |
| 62 | Graph graph; |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 63 | ClWorkloadFactory factory = |
| 64 | ClWorkloadFactoryHelper::GetFactory(ClWorkloadFactoryHelper::GetMemoryManager()); |
| 65 | |
Éanna Ó Catháin | d57415d | 2018-11-28 16:24:38 +0000 | [diff] [blame] | 66 | auto workload = CreateElementwiseWorkloadTest<WorkloadType, DescriptorType, LayerType, DataType>(factory, graph); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 67 | |
Éanna Ó Catháin | d57415d | 2018-11-28 16:24:38 +0000 | [diff] [blame] | 68 | // 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] | 69 | DescriptorType queueDescriptor = workload->GetData(); |
Jan Eilers | bb446e5 | 2020-04-02 13:56:54 +0100 | [diff] [blame] | 70 | auto inputHandle1 = PolymorphicDowncast<IClTensorHandle*>(queueDescriptor.m_Inputs[0]); |
| 71 | auto inputHandle2 = PolymorphicDowncast<IClTensorHandle*>(queueDescriptor.m_Inputs[1]); |
| 72 | auto outputHandle = PolymorphicDowncast<IClTensorHandle*>(queueDescriptor.m_Outputs[0]); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 73 | BOOST_TEST(CompareIClTensorHandleShape(inputHandle1, {2, 3})); |
| 74 | BOOST_TEST(CompareIClTensorHandleShape(inputHandle2, {2, 3})); |
| 75 | BOOST_TEST(CompareIClTensorHandleShape(outputHandle, {2, 3})); |
| 76 | } |
| 77 | |
arovir01 | 9e53a35 | 2018-08-31 15:26:35 +0100 | [diff] [blame] | 78 | BOOST_AUTO_TEST_CASE(CreateAdditionFloatWorkload) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 79 | { |
Éanna Ó Catháin | d57415d | 2018-11-28 16:24:38 +0000 | [diff] [blame] | 80 | ClCreateElementwiseWorkloadTest<ClAdditionWorkload, |
David Beck | 4a8692c | 2018-09-07 16:19:24 +0100 | [diff] [blame] | 81 | AdditionQueueDescriptor, |
| 82 | AdditionLayer, |
| 83 | armnn::DataType::Float32>(); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 84 | } |
| 85 | |
| 86 | BOOST_AUTO_TEST_CASE(CreateAdditionFloat16Workload) |
| 87 | { |
Éanna Ó Catháin | d57415d | 2018-11-28 16:24:38 +0000 | [diff] [blame] | 88 | ClCreateElementwiseWorkloadTest<ClAdditionWorkload, |
David Beck | 4a8692c | 2018-09-07 16:19:24 +0100 | [diff] [blame] | 89 | AdditionQueueDescriptor, |
| 90 | AdditionLayer, |
| 91 | armnn::DataType::Float16>(); |
| 92 | } |
| 93 | |
| 94 | BOOST_AUTO_TEST_CASE(CreateSubtractionFloatWorkload) |
| 95 | { |
Éanna Ó Catháin | d57415d | 2018-11-28 16:24:38 +0000 | [diff] [blame] | 96 | ClCreateElementwiseWorkloadTest<ClSubtractionWorkload, |
David Beck | 4a8692c | 2018-09-07 16:19:24 +0100 | [diff] [blame] | 97 | SubtractionQueueDescriptor, |
| 98 | SubtractionLayer, |
| 99 | armnn::DataType::Float32>(); |
| 100 | } |
| 101 | |
| 102 | BOOST_AUTO_TEST_CASE(CreateSubtractionFloat16Workload) |
| 103 | { |
Éanna Ó Catháin | d57415d | 2018-11-28 16:24:38 +0000 | [diff] [blame] | 104 | ClCreateElementwiseWorkloadTest<ClSubtractionWorkload, |
David Beck | 4a8692c | 2018-09-07 16:19:24 +0100 | [diff] [blame] | 105 | SubtractionQueueDescriptor, |
| 106 | SubtractionLayer, |
| 107 | armnn::DataType::Float16>(); |
| 108 | } |
| 109 | |
| 110 | BOOST_AUTO_TEST_CASE(CreateMultiplicationFloatWorkloadTest) |
| 111 | { |
Éanna Ó Catháin | d57415d | 2018-11-28 16:24:38 +0000 | [diff] [blame] | 112 | ClCreateElementwiseWorkloadTest<ClMultiplicationWorkload, |
David Beck | 4a8692c | 2018-09-07 16:19:24 +0100 | [diff] [blame] | 113 | MultiplicationQueueDescriptor, |
| 114 | MultiplicationLayer, |
| 115 | armnn::DataType::Float32>(); |
| 116 | } |
| 117 | |
| 118 | BOOST_AUTO_TEST_CASE(CreateMultiplicationFloat16WorkloadTest) |
| 119 | { |
Éanna Ó Catháin | d57415d | 2018-11-28 16:24:38 +0000 | [diff] [blame] | 120 | ClCreateElementwiseWorkloadTest<ClMultiplicationWorkload, |
David Beck | 4a8692c | 2018-09-07 16:19:24 +0100 | [diff] [blame] | 121 | MultiplicationQueueDescriptor, |
| 122 | MultiplicationLayer, |
| 123 | armnn::DataType::Float16>(); |
| 124 | } |
| 125 | |
Matthew Bentham | e2ec330 | 2018-10-01 11:32:48 +0100 | [diff] [blame] | 126 | BOOST_AUTO_TEST_CASE(CreateMultiplicationUint8WorkloadTest) |
| 127 | { |
Éanna Ó Catháin | d57415d | 2018-11-28 16:24:38 +0000 | [diff] [blame] | 128 | ClCreateElementwiseWorkloadTest<ClMultiplicationWorkload, |
Matthew Bentham | e2ec330 | 2018-10-01 11:32:48 +0100 | [diff] [blame] | 129 | MultiplicationQueueDescriptor, |
| 130 | MultiplicationLayer, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 131 | armnn::DataType::QAsymmU8>(); |
Matthew Bentham | e2ec330 | 2018-10-01 11:32:48 +0100 | [diff] [blame] | 132 | } |
| 133 | |
David Beck | 4a8692c | 2018-09-07 16:19:24 +0100 | [diff] [blame] | 134 | BOOST_AUTO_TEST_CASE(CreateDivisionFloatWorkloadTest) |
| 135 | { |
Éanna Ó Catháin | d57415d | 2018-11-28 16:24:38 +0000 | [diff] [blame] | 136 | ClCreateElementwiseWorkloadTest<ClDivisionFloatWorkload, |
David Beck | 4a8692c | 2018-09-07 16:19:24 +0100 | [diff] [blame] | 137 | DivisionQueueDescriptor, |
| 138 | DivisionLayer, |
| 139 | armnn::DataType::Float32>(); |
| 140 | } |
| 141 | |
| 142 | BOOST_AUTO_TEST_CASE(CreateDivisionFloat16WorkloadTest) |
| 143 | { |
Éanna Ó Catháin | d57415d | 2018-11-28 16:24:38 +0000 | [diff] [blame] | 144 | ClCreateElementwiseWorkloadTest<ClDivisionFloatWorkload, |
David Beck | 4a8692c | 2018-09-07 16:19:24 +0100 | [diff] [blame] | 145 | DivisionQueueDescriptor, |
| 146 | DivisionLayer, |
| 147 | armnn::DataType::Float16>(); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 148 | } |
| 149 | |
josh minor | 4a3c610 | 2020-01-06 16:40:46 -0600 | [diff] [blame] | 150 | template <typename WorkloadType, |
Aron Virginas-Tar | 1a763dd | 2019-09-10 12:32:08 +0100 | [diff] [blame] | 151 | typename DescriptorType, |
Aron Virginas-Tar | 1a763dd | 2019-09-10 12:32:08 +0100 | [diff] [blame] | 152 | armnn::DataType DataType> |
josh minor | 4a3c610 | 2020-01-06 16:40:46 -0600 | [diff] [blame] | 153 | static void ClCreateElementwiseUnaryWorkloadTest(armnn::UnaryOperation op) |
Aron Virginas-Tar | 1a763dd | 2019-09-10 12:32:08 +0100 | [diff] [blame] | 154 | { |
| 155 | Graph graph; |
| 156 | ClWorkloadFactory factory = |
| 157 | ClWorkloadFactoryHelper::GetFactory(ClWorkloadFactoryHelper::GetMemoryManager()); |
| 158 | |
josh minor | 4a3c610 | 2020-01-06 16:40:46 -0600 | [diff] [blame] | 159 | auto workload = CreateElementwiseUnaryWorkloadTest<WorkloadType, DescriptorType, DataType>(factory, graph, op); |
Aron Virginas-Tar | 1a763dd | 2019-09-10 12:32:08 +0100 | [diff] [blame] | 160 | |
| 161 | DescriptorType queueDescriptor = workload->GetData(); |
| 162 | |
Jan Eilers | bb446e5 | 2020-04-02 13:56:54 +0100 | [diff] [blame] | 163 | auto inputHandle = PolymorphicDowncast<IClTensorHandle*>(queueDescriptor.m_Inputs[0]); |
| 164 | auto outputHandle = PolymorphicDowncast<IClTensorHandle*>(queueDescriptor.m_Outputs[0]); |
Aron Virginas-Tar | 1a763dd | 2019-09-10 12:32:08 +0100 | [diff] [blame] | 165 | |
| 166 | BOOST_TEST(CompareIClTensorHandleShape(inputHandle, {2, 3})); |
| 167 | BOOST_TEST(CompareIClTensorHandleShape(outputHandle, {2, 3})); |
| 168 | } |
| 169 | |
| 170 | BOOST_AUTO_TEST_CASE(CreateRsqrtFloat32WorkloadTest) |
| 171 | { |
josh minor | 4a3c610 | 2020-01-06 16:40:46 -0600 | [diff] [blame] | 172 | ClCreateElementwiseUnaryWorkloadTest<ClRsqrtWorkload, RsqrtQueueDescriptor, armnn::DataType::Float32>( |
| 173 | UnaryOperation::Rsqrt); |
Aron Virginas-Tar | 1a763dd | 2019-09-10 12:32:08 +0100 | [diff] [blame] | 174 | } |
| 175 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 176 | template <typename BatchNormalizationWorkloadType, armnn::DataType DataType> |
Nikhil Raj | d134093 | 2018-10-18 14:27:50 +0100 | [diff] [blame] | 177 | static void ClCreateBatchNormalizationWorkloadTest(DataLayout dataLayout) |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 178 | { |
| 179 | Graph graph; |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 180 | ClWorkloadFactory factory = |
| 181 | ClWorkloadFactoryHelper::GetFactory(ClWorkloadFactoryHelper::GetMemoryManager()); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 182 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 183 | auto workload = CreateBatchNormalizationWorkloadTest<BatchNormalizationWorkloadType, DataType> |
Nikhil Raj | d134093 | 2018-10-18 14:27:50 +0100 | [diff] [blame] | 184 | (factory, graph, dataLayout); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 185 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 186 | // Checks that inputs/outputs are as we expect them (see definition of CreateBatchNormalizationWorkloadTest). |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 187 | BatchNormalizationQueueDescriptor queueDescriptor = workload->GetData(); |
Jan Eilers | bb446e5 | 2020-04-02 13:56:54 +0100 | [diff] [blame] | 188 | auto inputHandle = PolymorphicDowncast<IClTensorHandle*>(queueDescriptor.m_Inputs[0]); |
| 189 | auto outputHandle = PolymorphicDowncast<IClTensorHandle*>(queueDescriptor.m_Outputs[0]); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 190 | |
Nikhil Raj | d134093 | 2018-10-18 14:27:50 +0100 | [diff] [blame] | 191 | switch (dataLayout) |
| 192 | { |
| 193 | case DataLayout::NHWC: |
| 194 | BOOST_TEST(CompareIClTensorHandleShape(inputHandle, { 2, 4, 4, 3 })); |
| 195 | BOOST_TEST(CompareIClTensorHandleShape(outputHandle, { 2, 4, 4, 3 })); |
| 196 | break; |
| 197 | default: // NCHW |
| 198 | BOOST_TEST(CompareIClTensorHandleShape(inputHandle, { 2, 3, 4, 4 })); |
| 199 | BOOST_TEST(CompareIClTensorHandleShape(outputHandle, { 2, 3, 4, 4 })); |
| 200 | } |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 201 | } |
| 202 | |
Nikhil Raj | d134093 | 2018-10-18 14:27:50 +0100 | [diff] [blame] | 203 | BOOST_AUTO_TEST_CASE(CreateBatchNormalizationFloatNchwWorkload) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 204 | { |
Nikhil Raj | d134093 | 2018-10-18 14:27:50 +0100 | [diff] [blame] | 205 | ClCreateBatchNormalizationWorkloadTest<ClBatchNormalizationFloatWorkload, |
| 206 | armnn::DataType::Float32>(DataLayout::NCHW); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 207 | } |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 208 | |
Nikhil Raj | d134093 | 2018-10-18 14:27:50 +0100 | [diff] [blame] | 209 | BOOST_AUTO_TEST_CASE(CreateBatchNormalizationFloat16NchwWorkload) |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 210 | { |
Nikhil Raj | d134093 | 2018-10-18 14:27:50 +0100 | [diff] [blame] | 211 | ClCreateBatchNormalizationWorkloadTest<ClBatchNormalizationFloatWorkload, |
| 212 | armnn::DataType::Float16>(DataLayout::NCHW); |
| 213 | } |
| 214 | |
| 215 | BOOST_AUTO_TEST_CASE(CreateBatchNormalizationFloatNhwcWorkload) |
| 216 | { |
| 217 | ClCreateBatchNormalizationWorkloadTest<ClBatchNormalizationFloatWorkload, |
| 218 | armnn::DataType::Float32>(DataLayout::NHWC); |
| 219 | } |
| 220 | |
| 221 | BOOST_AUTO_TEST_CASE(CreateBatchNormalizationNhwcFloat16NhwcWorkload) |
| 222 | { |
| 223 | ClCreateBatchNormalizationWorkloadTest<ClBatchNormalizationFloatWorkload, |
| 224 | armnn::DataType::Float16>(DataLayout::NHWC); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 225 | } |
| 226 | |
| 227 | BOOST_AUTO_TEST_CASE(CreateConvertFp16ToFp32Workload) |
| 228 | { |
| 229 | Graph graph; |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 230 | ClWorkloadFactory factory = |
| 231 | ClWorkloadFactoryHelper::GetFactory(ClWorkloadFactoryHelper::GetMemoryManager()); |
| 232 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 233 | auto workload = CreateConvertFp16ToFp32WorkloadTest<ClConvertFp16ToFp32Workload>(factory, graph); |
| 234 | |
| 235 | ConvertFp16ToFp32QueueDescriptor queueDescriptor = workload->GetData(); |
Jan Eilers | bb446e5 | 2020-04-02 13:56:54 +0100 | [diff] [blame] | 236 | auto inputHandle = PolymorphicDowncast<IClTensorHandle*>(queueDescriptor.m_Inputs[0]); |
| 237 | auto outputHandle = PolymorphicDowncast<IClTensorHandle*>(queueDescriptor.m_Outputs[0]); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 238 | |
Matthew Bentham | 8910528 | 2018-11-20 14:33:33 +0000 | [diff] [blame] | 239 | BOOST_TEST(CompareIClTensorHandleShape(inputHandle, {1, 3, 2, 3})); |
| 240 | BOOST_TEST(CompareIClTensorHandleShape(outputHandle, {1, 3, 2, 3})); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 241 | BOOST_TEST((inputHandle->GetTensor().info()->data_type() == arm_compute::DataType::F16)); |
| 242 | BOOST_TEST((outputHandle->GetTensor().info()->data_type() == arm_compute::DataType::F32)); |
| 243 | } |
| 244 | |
| 245 | BOOST_AUTO_TEST_CASE(CreateConvertFp32ToFp16Workload) |
| 246 | { |
| 247 | Graph graph; |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 248 | ClWorkloadFactory factory = |
| 249 | ClWorkloadFactoryHelper::GetFactory(ClWorkloadFactoryHelper::GetMemoryManager()); |
| 250 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 251 | auto workload = CreateConvertFp32ToFp16WorkloadTest<ClConvertFp32ToFp16Workload>(factory, graph); |
| 252 | |
| 253 | ConvertFp32ToFp16QueueDescriptor queueDescriptor = workload->GetData(); |
Jan Eilers | bb446e5 | 2020-04-02 13:56:54 +0100 | [diff] [blame] | 254 | auto inputHandle = PolymorphicDowncast<IClTensorHandle*>(queueDescriptor.m_Inputs[0]); |
| 255 | auto outputHandle = PolymorphicDowncast<IClTensorHandle*>(queueDescriptor.m_Outputs[0]); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 256 | |
Matthew Bentham | 8910528 | 2018-11-20 14:33:33 +0000 | [diff] [blame] | 257 | BOOST_TEST(CompareIClTensorHandleShape(inputHandle, {1, 3, 2, 3})); |
| 258 | BOOST_TEST(CompareIClTensorHandleShape(outputHandle, {1, 3, 2, 3})); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 259 | BOOST_TEST((inputHandle->GetTensor().info()->data_type() == arm_compute::DataType::F32)); |
| 260 | BOOST_TEST((outputHandle->GetTensor().info()->data_type() == arm_compute::DataType::F16)); |
| 261 | } |
| 262 | |
Francis Murtagh | 0d9d419 | 2018-10-09 16:22:33 +0100 | [diff] [blame] | 263 | template <typename Convolution2dWorkloadType, typename armnn::DataType DataType> |
| 264 | static void ClConvolution2dWorkloadTest(DataLayout dataLayout) |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 265 | { |
| 266 | Graph graph; |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 267 | ClWorkloadFactory factory = |
| 268 | ClWorkloadFactoryHelper::GetFactory(ClWorkloadFactoryHelper::GetMemoryManager()); |
| 269 | |
Francis Murtagh | 0d9d419 | 2018-10-09 16:22:33 +0100 | [diff] [blame] | 270 | auto workload = CreateConvolution2dWorkloadTest<ClConvolution2dWorkload, DataType>(factory, |
| 271 | graph, |
| 272 | dataLayout); |
| 273 | |
Mike Kelly | db48288 | 2019-06-14 12:35:24 +0100 | [diff] [blame] | 274 | TensorShape inputShape = (dataLayout == DataLayout::NCHW) ? std::initializer_list<unsigned int>({2, 3, 8, 16}) |
| 275 | : std::initializer_list<unsigned int>({2, 8, 16, 3}); |
| 276 | TensorShape outputShape = (dataLayout == DataLayout::NCHW) ? std::initializer_list<unsigned int>({2, 2, 2, 10}) |
| 277 | : std::initializer_list<unsigned int>({2, 2, 10, 2}); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 278 | |
| 279 | // 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] | 280 | Convolution2dQueueDescriptor queueDescriptor = workload->GetData(); |
Jan Eilers | bb446e5 | 2020-04-02 13:56:54 +0100 | [diff] [blame] | 281 | auto inputHandle = PolymorphicDowncast<IClTensorHandle*>(queueDescriptor.m_Inputs[0]); |
| 282 | auto outputHandle = PolymorphicDowncast<IClTensorHandle*>(queueDescriptor.m_Outputs[0]); |
Mike Kelly | db48288 | 2019-06-14 12:35:24 +0100 | [diff] [blame] | 283 | BOOST_TEST((inputHandle->GetShape() == inputShape)); |
| 284 | BOOST_TEST((outputHandle->GetShape() == outputShape)); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 285 | } |
| 286 | |
Francis Murtagh | 0d9d419 | 2018-10-09 16:22:33 +0100 | [diff] [blame] | 287 | BOOST_AUTO_TEST_CASE(CreateConvolution2dFloatNchwWorkload) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 288 | { |
Francis Murtagh | 0d9d419 | 2018-10-09 16:22:33 +0100 | [diff] [blame] | 289 | ClConvolution2dWorkloadTest<ClConvolution2dWorkload, armnn::DataType::Float32>(DataLayout::NCHW); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 290 | } |
| 291 | |
Francis Murtagh | 0d9d419 | 2018-10-09 16:22:33 +0100 | [diff] [blame] | 292 | BOOST_AUTO_TEST_CASE(CreateConvolution2dFloatNhwcWorkload) |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 293 | { |
Francis Murtagh | 0d9d419 | 2018-10-09 16:22:33 +0100 | [diff] [blame] | 294 | ClConvolution2dWorkloadTest<ClConvolution2dWorkload, armnn::DataType::Float32>(DataLayout::NHWC); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 295 | } |
| 296 | |
Francis Murtagh | 0d9d419 | 2018-10-09 16:22:33 +0100 | [diff] [blame] | 297 | BOOST_AUTO_TEST_CASE(CreateConvolution2dFloat16NchwWorkload) |
| 298 | { |
| 299 | ClConvolution2dWorkloadTest<ClConvolution2dWorkload, armnn::DataType::Float16>(DataLayout::NCHW); |
| 300 | } |
| 301 | |
| 302 | BOOST_AUTO_TEST_CASE(CreateConvolution2dFloat16NhwcWorkload) |
| 303 | { |
| 304 | ClConvolution2dWorkloadTest<ClConvolution2dWorkload, armnn::DataType::Float16>(DataLayout::NHWC); |
| 305 | } |
| 306 | |
Nikhil Raj | cec6b65 | 2018-10-12 13:51:57 +0100 | [diff] [blame] | 307 | template <typename DepthwiseConvolutionWorkloadType, typename armnn::DataType DataType> |
| 308 | static void ClDepthwiseConvolutionWorkloadTest(DataLayout dataLayout) |
| 309 | { |
| 310 | Graph graph; |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 311 | ClWorkloadFactory factory = |
| 312 | ClWorkloadFactoryHelper::GetFactory(ClWorkloadFactoryHelper::GetMemoryManager()); |
Nikhil Raj | cec6b65 | 2018-10-12 13:51:57 +0100 | [diff] [blame] | 313 | |
| 314 | auto workload = CreateDepthwiseConvolution2dWorkloadTest<DepthwiseConvolutionWorkloadType, DataType> |
| 315 | (factory, graph, dataLayout); |
| 316 | |
| 317 | // Checks that inputs/outputs are as we expect them (see definition of CreateDepthwiseConvolution2dWorkloadTest). |
| 318 | DepthwiseConvolution2dQueueDescriptor queueDescriptor = workload->GetData(); |
Jan Eilers | bb446e5 | 2020-04-02 13:56:54 +0100 | [diff] [blame] | 319 | auto inputHandle = PolymorphicDowncast<IClTensorHandle*>(queueDescriptor.m_Inputs[0]); |
| 320 | auto outputHandle = PolymorphicDowncast<IClTensorHandle*>(queueDescriptor.m_Outputs[0]); |
Nikhil Raj | cec6b65 | 2018-10-12 13:51:57 +0100 | [diff] [blame] | 321 | |
Mike Kelly | db48288 | 2019-06-14 12:35:24 +0100 | [diff] [blame] | 322 | TensorShape inputShape = (dataLayout == DataLayout::NCHW) ? std::initializer_list<unsigned int>({ 2, 2, 5, 5 }) |
| 323 | : std::initializer_list<unsigned int>({ 2, 5, 5, 2 }); |
| 324 | TensorShape outputShape = (dataLayout == DataLayout::NCHW) ? std::initializer_list<unsigned int>({ 2, 2, 5, 5 }) |
| 325 | : std::initializer_list<unsigned int>({ 2, 5, 5, 2 }); |
Nikhil Raj | cec6b65 | 2018-10-12 13:51:57 +0100 | [diff] [blame] | 326 | |
Mike Kelly | db48288 | 2019-06-14 12:35:24 +0100 | [diff] [blame] | 327 | BOOST_TEST((inputHandle->GetShape() == inputShape)); |
| 328 | BOOST_TEST((outputHandle->GetShape() == outputShape)); |
Nikhil Raj | cec6b65 | 2018-10-12 13:51:57 +0100 | [diff] [blame] | 329 | } |
| 330 | |
| 331 | BOOST_AUTO_TEST_CASE(CreateDepthwiseConvolutionFloat32NhwcWorkload) |
| 332 | { |
| 333 | ClDepthwiseConvolutionWorkloadTest<ClDepthwiseConvolutionWorkload, DataType::Float32>(DataLayout::NHWC); |
| 334 | } |
| 335 | |
Francis Murtagh | 0d9d419 | 2018-10-09 16:22:33 +0100 | [diff] [blame] | 336 | template <typename Convolution2dWorkloadType, typename armnn::DataType DataType> |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 337 | static void ClDirectConvolution2dWorkloadTest() |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 338 | { |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 339 | Graph graph; |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 340 | ClWorkloadFactory factory = |
| 341 | ClWorkloadFactoryHelper::GetFactory(ClWorkloadFactoryHelper::GetMemoryManager()); |
| 342 | |
Matthew Bentham | d806792 | 2018-10-03 17:18:04 +0100 | [diff] [blame] | 343 | auto workload = CreateDirectConvolution2dWorkloadTest<ClConvolution2dWorkload, DataType>(factory, graph); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 344 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 345 | // 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] | 346 | Convolution2dQueueDescriptor queueDescriptor = workload->GetData(); |
Jan Eilers | bb446e5 | 2020-04-02 13:56:54 +0100 | [diff] [blame] | 347 | auto inputHandle = PolymorphicDowncast<IClTensorHandle*>(queueDescriptor.m_Inputs[0]); |
| 348 | auto outputHandle = PolymorphicDowncast<IClTensorHandle*>(queueDescriptor.m_Outputs[0]); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 349 | BOOST_TEST(CompareIClTensorHandleShape(inputHandle, {2, 3, 6, 6})); |
| 350 | BOOST_TEST(CompareIClTensorHandleShape(outputHandle, {2, 2, 6, 6})); |
| 351 | } |
| 352 | |
arovir01 | 9e53a35 | 2018-08-31 15:26:35 +0100 | [diff] [blame] | 353 | BOOST_AUTO_TEST_CASE(CreateDirectConvolution2dFloatWorkload) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 354 | { |
Francis Murtagh | 0d9d419 | 2018-10-09 16:22:33 +0100 | [diff] [blame] | 355 | ClDirectConvolution2dWorkloadTest<ClConvolution2dWorkload, armnn::DataType::Float32>(); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 356 | } |
| 357 | |
| 358 | BOOST_AUTO_TEST_CASE(CreateDirectConvolution2dFloat16Workload) |
| 359 | { |
Francis Murtagh | 0d9d419 | 2018-10-09 16:22:33 +0100 | [diff] [blame] | 360 | ClDirectConvolution2dWorkloadTest<ClConvolution2dWorkload, armnn::DataType::Float16>(); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 361 | } |
| 362 | |
| 363 | BOOST_AUTO_TEST_CASE(CreateDirectConvolution2dUint8Workload) |
| 364 | { |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 365 | ClDirectConvolution2dWorkloadTest<ClConvolution2dWorkload, armnn::DataType::QAsymmU8>(); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 366 | } |
| 367 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 368 | template <typename FullyConnectedWorkloadType, typename armnn::DataType DataType> |
| 369 | static void ClCreateFullyConnectedWorkloadTest() |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 370 | { |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 371 | Graph graph; |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 372 | ClWorkloadFactory factory = |
| 373 | ClWorkloadFactoryHelper::GetFactory(ClWorkloadFactoryHelper::GetMemoryManager()); |
| 374 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 375 | auto workload = |
| 376 | CreateFullyConnectedWorkloadTest<FullyConnectedWorkloadType, DataType>(factory, graph); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 377 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 378 | // Checks that outputs and inputs are as we expect them (see definition of CreateFullyConnectedWorkloadTest). |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 379 | FullyConnectedQueueDescriptor queueDescriptor = workload->GetData(); |
Jan Eilers | bb446e5 | 2020-04-02 13:56:54 +0100 | [diff] [blame] | 380 | auto inputHandle = PolymorphicDowncast<IClTensorHandle*>(queueDescriptor.m_Inputs[0]); |
| 381 | auto outputHandle = PolymorphicDowncast<IClTensorHandle*>(queueDescriptor.m_Outputs[0]); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 382 | BOOST_TEST(CompareIClTensorHandleShape(inputHandle, {3, 1, 4, 5})); |
| 383 | BOOST_TEST(CompareIClTensorHandleShape(outputHandle, {3, 7})); |
| 384 | } |
| 385 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 386 | |
arovir01 | 9e53a35 | 2018-08-31 15:26:35 +0100 | [diff] [blame] | 387 | BOOST_AUTO_TEST_CASE(CreateFullyConnectedFloatWorkloadTest) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 388 | { |
Matthew Bentham | ab8cdc1 | 2018-09-17 11:17:41 +0100 | [diff] [blame] | 389 | ClCreateFullyConnectedWorkloadTest<ClFullyConnectedWorkload, armnn::DataType::Float32>(); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 390 | } |
| 391 | |
| 392 | BOOST_AUTO_TEST_CASE(CreateFullyConnectedFloat16WorkloadTest) |
| 393 | { |
Matthew Bentham | ab8cdc1 | 2018-09-17 11:17:41 +0100 | [diff] [blame] | 394 | ClCreateFullyConnectedWorkloadTest<ClFullyConnectedWorkload, armnn::DataType::Float16>(); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 395 | } |
| 396 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 397 | template <typename NormalizationWorkloadType, typename armnn::DataType DataType> |
narpra01 | 55a97bc | 2018-10-02 14:35:53 +0100 | [diff] [blame] | 398 | static void ClNormalizationWorkloadTest(DataLayout dataLayout) |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 399 | { |
| 400 | Graph graph; |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 401 | ClWorkloadFactory factory = |
| 402 | ClWorkloadFactoryHelper::GetFactory(ClWorkloadFactoryHelper::GetMemoryManager()); |
| 403 | |
Matteo Martincigh | a160b24 | 2018-10-18 10:33:23 +0100 | [diff] [blame] | 404 | auto workload = CreateNormalizationWorkloadTest<NormalizationWorkloadType, DataType>(factory, graph, dataLayout); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 405 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 406 | // Checks that inputs/outputs are as we expect them (see definition of CreateNormalizationWorkloadTest). |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 407 | NormalizationQueueDescriptor queueDescriptor = workload->GetData(); |
Jan Eilers | bb446e5 | 2020-04-02 13:56:54 +0100 | [diff] [blame] | 408 | auto inputHandle = PolymorphicDowncast<IClTensorHandle*>(queueDescriptor.m_Inputs[0]); |
| 409 | auto outputHandle = PolymorphicDowncast<IClTensorHandle*>(queueDescriptor.m_Outputs[0]); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 410 | |
Mike Kelly | db48288 | 2019-06-14 12:35:24 +0100 | [diff] [blame] | 411 | TensorShape inputShape = (dataLayout == DataLayout::NCHW) ? std::initializer_list<unsigned int>({3, 5, 5, 1}) |
| 412 | : std::initializer_list<unsigned int>({3, 1, 5, 5}); |
| 413 | TensorShape outputShape = (dataLayout == DataLayout::NCHW) ? std::initializer_list<unsigned int>({3, 5, 5, 1}) |
| 414 | : std::initializer_list<unsigned int>({3, 1, 5, 5}); |
Matteo Martincigh | a160b24 | 2018-10-18 10:33:23 +0100 | [diff] [blame] | 415 | |
Mike Kelly | db48288 | 2019-06-14 12:35:24 +0100 | [diff] [blame] | 416 | BOOST_TEST((inputHandle->GetShape() == inputShape)); |
| 417 | BOOST_TEST((outputHandle->GetShape() == outputShape)); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 418 | } |
| 419 | |
narpra01 | 55a97bc | 2018-10-02 14:35:53 +0100 | [diff] [blame] | 420 | BOOST_AUTO_TEST_CASE(CreateNormalizationFloat32NchwWorkload) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 421 | { |
narpra01 | 55a97bc | 2018-10-02 14:35:53 +0100 | [diff] [blame] | 422 | ClNormalizationWorkloadTest<ClNormalizationFloatWorkload, armnn::DataType::Float32>(DataLayout::NCHW); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 423 | } |
| 424 | |
narpra01 | 55a97bc | 2018-10-02 14:35:53 +0100 | [diff] [blame] | 425 | BOOST_AUTO_TEST_CASE(CreateNormalizationFloat16NchwWorkload) |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 426 | { |
narpra01 | 55a97bc | 2018-10-02 14:35:53 +0100 | [diff] [blame] | 427 | ClNormalizationWorkloadTest<ClNormalizationFloatWorkload, armnn::DataType::Float16>(DataLayout::NCHW); |
| 428 | } |
| 429 | |
| 430 | BOOST_AUTO_TEST_CASE(CreateNormalizationFloat32NhwcWorkload) |
| 431 | { |
| 432 | ClNormalizationWorkloadTest<ClNormalizationFloatWorkload, armnn::DataType::Float32>(DataLayout::NHWC); |
| 433 | } |
| 434 | |
| 435 | BOOST_AUTO_TEST_CASE(CreateNormalizationFloat16NhwcWorkload) |
| 436 | { |
| 437 | ClNormalizationWorkloadTest<ClNormalizationFloatWorkload, armnn::DataType::Float16>(DataLayout::NHWC); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 438 | } |
| 439 | |
Nattapat Chaimanowong | ac9e096 | 2018-10-10 17:18:35 +0100 | [diff] [blame] | 440 | template <typename armnn::DataType DataType> |
Nina Drozd | b48e686 | 2018-10-09 12:09:56 +0100 | [diff] [blame] | 441 | static void ClPooling2dWorkloadTest(DataLayout dataLayout) |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 442 | { |
| 443 | Graph graph; |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 444 | ClWorkloadFactory factory = |
| 445 | ClWorkloadFactoryHelper::GetFactory(ClWorkloadFactoryHelper::GetMemoryManager()); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 446 | |
Nattapat Chaimanowong | ac9e096 | 2018-10-10 17:18:35 +0100 | [diff] [blame] | 447 | auto workload = CreatePooling2dWorkloadTest<ClPooling2dWorkload, DataType>(factory, graph, dataLayout); |
Nina Drozd | b48e686 | 2018-10-09 12:09:56 +0100 | [diff] [blame] | 448 | |
Mike Kelly | db48288 | 2019-06-14 12:35:24 +0100 | [diff] [blame] | 449 | TensorShape inputShape = (dataLayout == DataLayout::NCHW) ? std::initializer_list<unsigned int>({3, 2, 5, 5}) |
| 450 | : std::initializer_list<unsigned int>({3, 5, 5, 2}); |
| 451 | TensorShape outputShape = (dataLayout == DataLayout::NCHW) ? std::initializer_list<unsigned int>({3, 2, 2, 4}) |
| 452 | : std::initializer_list<unsigned int>({3, 2, 4, 2}); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 453 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 454 | // Check that inputs/outputs are as we expect them (see definition of CreatePooling2dWorkloadTest). |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 455 | Pooling2dQueueDescriptor queueDescriptor = workload->GetData(); |
Jan Eilers | bb446e5 | 2020-04-02 13:56:54 +0100 | [diff] [blame] | 456 | auto inputHandle = PolymorphicDowncast<IClTensorHandle*>(queueDescriptor.m_Inputs[0]); |
| 457 | auto outputHandle = PolymorphicDowncast<IClTensorHandle*>(queueDescriptor.m_Outputs[0]); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 458 | |
Mike Kelly | db48288 | 2019-06-14 12:35:24 +0100 | [diff] [blame] | 459 | BOOST_TEST((inputHandle->GetShape() == inputShape)); |
| 460 | BOOST_TEST((outputHandle->GetShape() == outputShape)); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 461 | } |
| 462 | |
Nina Drozd | b48e686 | 2018-10-09 12:09:56 +0100 | [diff] [blame] | 463 | BOOST_AUTO_TEST_CASE(CreatePooling2dFloatNchwWorkload) |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 464 | { |
Nattapat Chaimanowong | ac9e096 | 2018-10-10 17:18:35 +0100 | [diff] [blame] | 465 | ClPooling2dWorkloadTest<armnn::DataType::Float32>(DataLayout::NCHW); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 466 | } |
| 467 | |
Nina Drozd | b48e686 | 2018-10-09 12:09:56 +0100 | [diff] [blame] | 468 | BOOST_AUTO_TEST_CASE(CreatePooling2dFloatNhwcWorkload) |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 469 | { |
Nattapat Chaimanowong | ac9e096 | 2018-10-10 17:18:35 +0100 | [diff] [blame] | 470 | ClPooling2dWorkloadTest<armnn::DataType::Float32>(DataLayout::NHWC); |
Nina Drozd | b48e686 | 2018-10-09 12:09:56 +0100 | [diff] [blame] | 471 | } |
| 472 | |
| 473 | BOOST_AUTO_TEST_CASE(CreatePooling2dFloat16NchwWorkload) |
| 474 | { |
Nattapat Chaimanowong | ac9e096 | 2018-10-10 17:18:35 +0100 | [diff] [blame] | 475 | ClPooling2dWorkloadTest<armnn::DataType::Float16>(DataLayout::NCHW); |
Nina Drozd | b48e686 | 2018-10-09 12:09:56 +0100 | [diff] [blame] | 476 | } |
| 477 | |
| 478 | BOOST_AUTO_TEST_CASE(CreatePooling2dFloat16NhwcWorkload) |
| 479 | { |
Nattapat Chaimanowong | ac9e096 | 2018-10-10 17:18:35 +0100 | [diff] [blame] | 480 | ClPooling2dWorkloadTest<armnn::DataType::Float16>(DataLayout::NHWC); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 481 | } |
| 482 | |
Nikhil Raj | 91e4c6d | 2019-07-05 12:22:58 +0100 | [diff] [blame] | 483 | static void ClCreatePreluWorkloadTest(const armnn::TensorShape& inputShape, |
| 484 | const armnn::TensorShape& alphaShape, |
| 485 | const armnn::TensorShape& outputShape, |
| 486 | armnn::DataType dataType) |
| 487 | { |
| 488 | Graph graph; |
| 489 | ClWorkloadFactory factory = |
| 490 | ClWorkloadFactoryHelper::GetFactory(ClWorkloadFactoryHelper::GetMemoryManager()); |
| 491 | |
| 492 | auto workload = CreatePreluWorkloadTest<ClPreluWorkload>(factory, |
| 493 | graph, |
| 494 | inputShape, |
| 495 | alphaShape, |
| 496 | outputShape, |
| 497 | dataType); |
| 498 | |
| 499 | // Checks that outputs and inputs are as we expect them (see definition of CreatePreluWorkloadTest). |
| 500 | PreluQueueDescriptor queueDescriptor = workload->GetData(); |
Jan Eilers | bb446e5 | 2020-04-02 13:56:54 +0100 | [diff] [blame] | 501 | auto inputHandle = PolymorphicDowncast<IClTensorHandle*>(queueDescriptor.m_Inputs[0]); |
| 502 | auto alphaHandle = PolymorphicDowncast<IClTensorHandle*>(queueDescriptor.m_Inputs[1]); |
| 503 | auto outputHandle = PolymorphicDowncast<IClTensorHandle*>(queueDescriptor.m_Outputs[0]); |
Nikhil Raj | 91e4c6d | 2019-07-05 12:22:58 +0100 | [diff] [blame] | 504 | |
| 505 | BOOST_TEST((inputHandle->GetShape() == inputShape)); |
| 506 | BOOST_TEST((alphaHandle->GetShape() == alphaShape)); |
| 507 | BOOST_TEST((outputHandle->GetShape() == outputShape)); |
| 508 | } |
| 509 | |
| 510 | BOOST_AUTO_TEST_CASE(CreatePreluFloat16Workload) |
| 511 | { |
| 512 | ClCreatePreluWorkloadTest({ 1, 4, 1, 2 }, { 5, 4, 3, 1 }, { 5, 4, 3, 2 }, DataType::Float16); |
| 513 | } |
| 514 | |
| 515 | BOOST_AUTO_TEST_CASE(CreatePreluFloatWorkload) |
| 516 | { |
| 517 | ClCreatePreluWorkloadTest({ 1, 4, 1, 2 }, { 5, 4, 3, 1 }, { 5, 4, 3, 2 }, DataType::Float32); |
| 518 | } |
| 519 | |
| 520 | BOOST_AUTO_TEST_CASE(CreatePreluUint8Workload) |
| 521 | { |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 522 | ClCreatePreluWorkloadTest({ 1, 4, 1, 2 }, { 5, 4, 3, 1 }, { 5, 4, 3, 2 }, DataType::QAsymmU8); |
Nikhil Raj | 91e4c6d | 2019-07-05 12:22:58 +0100 | [diff] [blame] | 523 | } |
| 524 | |
Nattapat Chaimanowong | a76698c | 2018-10-11 10:29:15 +0100 | [diff] [blame] | 525 | template <typename armnn::DataType DataType> |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 526 | static void ClCreateReshapeWorkloadTest() |
| 527 | { |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 528 | Graph graph; |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 529 | ClWorkloadFactory factory = |
| 530 | ClWorkloadFactoryHelper::GetFactory(ClWorkloadFactoryHelper::GetMemoryManager()); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 531 | |
Nattapat Chaimanowong | a76698c | 2018-10-11 10:29:15 +0100 | [diff] [blame] | 532 | auto workload = CreateReshapeWorkloadTest<ClReshapeWorkload, DataType>(factory, graph); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 533 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 534 | // 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] | 535 | ReshapeQueueDescriptor queueDescriptor = workload->GetData(); |
Jan Eilers | bb446e5 | 2020-04-02 13:56:54 +0100 | [diff] [blame] | 536 | auto inputHandle = PolymorphicDowncast<IClTensorHandle*>(queueDescriptor.m_Inputs[0]); |
| 537 | auto outputHandle = PolymorphicDowncast<IClTensorHandle*>(queueDescriptor.m_Outputs[0]); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 538 | |
| 539 | BOOST_TEST(CompareIClTensorHandleShape(inputHandle, {4, 1})); |
Matthew Bentham | 8910528 | 2018-11-20 14:33:33 +0000 | [diff] [blame] | 540 | BOOST_TEST(CompareIClTensorHandleShape(outputHandle, {1, 4})); |
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(CreateReshapeFloatWorkload) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 544 | { |
Nattapat Chaimanowong | a76698c | 2018-10-11 10:29:15 +0100 | [diff] [blame] | 545 | ClCreateReshapeWorkloadTest<armnn::DataType::Float32>(); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 546 | } |
| 547 | |
| 548 | BOOST_AUTO_TEST_CASE(CreateReshapeFloat16Workload) |
| 549 | { |
Nattapat Chaimanowong | a76698c | 2018-10-11 10:29:15 +0100 | [diff] [blame] | 550 | ClCreateReshapeWorkloadTest<armnn::DataType::Float16>(); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 551 | } |
| 552 | |
| 553 | BOOST_AUTO_TEST_CASE(CreateReshapeUint8Workload) |
| 554 | { |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 555 | ClCreateReshapeWorkloadTest<armnn::DataType::QAsymmU8>(); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 556 | } |
| 557 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 558 | template <typename SoftmaxWorkloadType, typename armnn::DataType DataType> |
| 559 | static void ClSoftmaxWorkloadTest() |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 560 | { |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 561 | Graph graph; |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 562 | ClWorkloadFactory factory = |
| 563 | ClWorkloadFactoryHelper::GetFactory(ClWorkloadFactoryHelper::GetMemoryManager()); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 564 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 565 | auto workload = CreateSoftmaxWorkloadTest<SoftmaxWorkloadType, DataType>(factory, graph); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 566 | |
arovir01 | 9e53a35 | 2018-08-31 15:26:35 +0100 | [diff] [blame] | 567 | // Checks that inputs/outputs are as we expect them (see definition of ClSoftmaxFloatWorkload). |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 568 | SoftmaxQueueDescriptor queueDescriptor = workload->GetData(); |
Jan Eilers | bb446e5 | 2020-04-02 13:56:54 +0100 | [diff] [blame] | 569 | auto inputHandle = PolymorphicDowncast<IClTensorHandle*>(queueDescriptor.m_Inputs[0]); |
| 570 | auto outputHandle = PolymorphicDowncast<IClTensorHandle*>(queueDescriptor.m_Outputs[0]); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 571 | |
| 572 | BOOST_TEST(CompareIClTensorHandleShape(inputHandle, {4, 1})); |
| 573 | BOOST_TEST(CompareIClTensorHandleShape(outputHandle, {4, 1})); |
| 574 | } |
| 575 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 576 | |
arovir01 | 9e53a35 | 2018-08-31 15:26:35 +0100 | [diff] [blame] | 577 | BOOST_AUTO_TEST_CASE(CreateSoftmaxFloatWorkloadTest) |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 578 | { |
arovir01 | 9e53a35 | 2018-08-31 15:26:35 +0100 | [diff] [blame] | 579 | ClSoftmaxWorkloadTest<ClSoftmaxFloatWorkload, armnn::DataType::Float32>(); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 580 | } |
| 581 | |
| 582 | BOOST_AUTO_TEST_CASE(CreateSoftmaxFloat16WorkloadTest) |
| 583 | { |
arovir01 | 9e53a35 | 2018-08-31 15:26:35 +0100 | [diff] [blame] | 584 | ClSoftmaxWorkloadTest<ClSoftmaxFloatWorkload, armnn::DataType::Float16>(); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 585 | } |
| 586 | |
Matthew Bentham | 29cadb3 | 2018-10-01 17:22:32 +0100 | [diff] [blame] | 587 | template <typename armnn::DataType DataType> |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 588 | static void ClSplitterWorkloadTest() |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 589 | { |
| 590 | Graph graph; |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 591 | ClWorkloadFactory factory = |
| 592 | ClWorkloadFactoryHelper::GetFactory(ClWorkloadFactoryHelper::GetMemoryManager()); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 593 | |
Matthew Bentham | 29cadb3 | 2018-10-01 17:22:32 +0100 | [diff] [blame] | 594 | auto workload = CreateSplitterWorkloadTest<ClSplitterWorkload, DataType>(factory, graph); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 595 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 596 | // Checks that outputs are as we expect them (see definition of CreateSplitterWorkloadTest). |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 597 | SplitterQueueDescriptor queueDescriptor = workload->GetData(); |
Jan Eilers | bb446e5 | 2020-04-02 13:56:54 +0100 | [diff] [blame] | 598 | auto inputHandle = PolymorphicDowncast<IClTensorHandle*>(queueDescriptor.m_Inputs[0]); |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 599 | BOOST_TEST(CompareIClTensorHandleShape(inputHandle, {5, 7, 7})); |
| 600 | |
Jan Eilers | bb446e5 | 2020-04-02 13:56:54 +0100 | [diff] [blame] | 601 | auto outputHandle1 = PolymorphicDowncast<IClTensorHandle*>(queueDescriptor.m_Outputs[1]); |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 602 | BOOST_TEST(CompareIClTensorHandleShape(outputHandle1, {2, 7, 7})); |
| 603 | |
Jan Eilers | bb446e5 | 2020-04-02 13:56:54 +0100 | [diff] [blame] | 604 | auto outputHandle2 = PolymorphicDowncast<IClTensorHandle*>(queueDescriptor.m_Outputs[2]); |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 605 | BOOST_TEST(CompareIClTensorHandleShape(outputHandle2, {2, 7, 7})); |
| 606 | |
Jan Eilers | bb446e5 | 2020-04-02 13:56:54 +0100 | [diff] [blame] | 607 | auto outputHandle0 = PolymorphicDowncast<IClTensorHandle*>(queueDescriptor.m_Outputs[0]); |
Matthew Bentham | 8910528 | 2018-11-20 14:33:33 +0000 | [diff] [blame] | 608 | BOOST_TEST(CompareIClTensorHandleShape(outputHandle0, {1, 7, 7})); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 609 | } |
| 610 | |
arovir01 | 9e53a35 | 2018-08-31 15:26:35 +0100 | [diff] [blame] | 611 | BOOST_AUTO_TEST_CASE(CreateSplitterFloatWorkload) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 612 | { |
Matthew Bentham | 29cadb3 | 2018-10-01 17:22:32 +0100 | [diff] [blame] | 613 | ClSplitterWorkloadTest<armnn::DataType::Float32>(); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 614 | } |
| 615 | |
| 616 | BOOST_AUTO_TEST_CASE(CreateSplitterFloat16Workload) |
| 617 | { |
Matthew Bentham | 29cadb3 | 2018-10-01 17:22:32 +0100 | [diff] [blame] | 618 | ClSplitterWorkloadTest<armnn::DataType::Float16>(); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 619 | } |
| 620 | |
Nattapat Chaimanowong | 02f8bc1 | 2018-10-11 16:16:17 +0100 | [diff] [blame] | 621 | template <typename armnn::DataType DataType> |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 622 | static void ClSplitterConcatTest() |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 623 | { |
| 624 | // Tests that it is possible to decide which output of the splitter layer |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 625 | // should be lined to which input of the concat layer. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 626 | // We test that is is possible to specify 0th output |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 627 | // of the splitter to be the 1st input to the concat and the 1st output of the splitter to be 0th input |
| 628 | // of the concat. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 629 | |
| 630 | Graph graph; |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 631 | ClWorkloadFactory factory = |
| 632 | ClWorkloadFactoryHelper::GetFactory(ClWorkloadFactoryHelper::GetMemoryManager()); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 633 | |
| 634 | auto workloads = |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 635 | CreateSplitterConcatWorkloadTest<ClSplitterWorkload, ClConcatWorkload, DataType> |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 636 | (factory, graph); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 637 | |
| 638 | auto wlSplitter = std::move(workloads.first); |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 639 | auto wlConcat = std::move(workloads.second); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 640 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 641 | //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] | 642 | armnn::ClSubTensorHandle* sOut0 = dynamic_cast<armnn::ClSubTensorHandle*>(wlSplitter->GetData().m_Outputs[0]); |
| 643 | armnn::ClSubTensorHandle* sOut1 = dynamic_cast<armnn::ClSubTensorHandle*>(wlSplitter->GetData().m_Outputs[1]); |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 644 | armnn::ClSubTensorHandle* mIn0 = dynamic_cast<armnn::ClSubTensorHandle*>(wlConcat->GetData().m_Inputs[0]); |
| 645 | armnn::ClSubTensorHandle* mIn1 = dynamic_cast<armnn::ClSubTensorHandle*>(wlConcat->GetData().m_Inputs[1]); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 646 | |
| 647 | BOOST_TEST(sOut0); |
| 648 | BOOST_TEST(sOut1); |
| 649 | BOOST_TEST(mIn0); |
| 650 | BOOST_TEST(mIn1); |
| 651 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 652 | //Fliped order of inputs/outputs. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 653 | bool validDataPointers = (sOut0 == mIn1) && (sOut1 == mIn0); |
| 654 | BOOST_TEST(validDataPointers); |
| 655 | |
| 656 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 657 | //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] | 658 | bool validSubTensorParents = (mIn0->GetTensor().parent() == mIn1->GetTensor().parent()) |
| 659 | && (sOut0->GetTensor().parent() == sOut1->GetTensor().parent()); |
| 660 | |
| 661 | BOOST_TEST(validSubTensorParents); |
| 662 | } |
| 663 | |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 664 | BOOST_AUTO_TEST_CASE(CreateSplitterConcatFloatWorkload) |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 665 | { |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 666 | ClSplitterConcatTest<armnn::DataType::Float32>(); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 667 | } |
| 668 | |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 669 | BOOST_AUTO_TEST_CASE(CreateSplitterConcatFloat16Workload) |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 670 | { |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 671 | ClSplitterConcatTest<armnn::DataType::Float16>(); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 672 | } |
| 673 | |
| 674 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 675 | BOOST_AUTO_TEST_CASE(CreateSingleOutputMultipleInputs) |
| 676 | { |
| 677 | // 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] | 678 | // 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] | 679 | |
| 680 | Graph graph; |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 681 | ClWorkloadFactory factory = |
| 682 | ClWorkloadFactoryHelper::GetFactory(ClWorkloadFactoryHelper::GetMemoryManager()); |
| 683 | |
Matthew Bentham | 29cadb3 | 2018-10-01 17:22:32 +0100 | [diff] [blame] | 684 | std::unique_ptr<ClSplitterWorkload> wlSplitter; |
Nattapat Chaimanowong | e06757e | 2018-10-11 15:39:18 +0100 | [diff] [blame] | 685 | std::unique_ptr<ClActivationWorkload> wlActiv0_0; |
| 686 | std::unique_ptr<ClActivationWorkload> wlActiv0_1; |
| 687 | std::unique_ptr<ClActivationWorkload> wlActiv1_0; |
| 688 | std::unique_ptr<ClActivationWorkload> wlActiv1_1; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 689 | |
Matthew Bentham | 29cadb3 | 2018-10-01 17:22:32 +0100 | [diff] [blame] | 690 | CreateSplitterMultipleInputsOneOutputWorkloadTest<ClSplitterWorkload, |
Nattapat Chaimanowong | e06757e | 2018-10-11 15:39:18 +0100 | [diff] [blame] | 691 | ClActivationWorkload, armnn::DataType::Float32>(factory, graph, wlSplitter, wlActiv0_0, wlActiv0_1, |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 692 | wlActiv1_0, wlActiv1_1); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 693 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 694 | //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] | 695 | armnn::ClSubTensorHandle* sOut0 = dynamic_cast<armnn::ClSubTensorHandle*>(wlSplitter->GetData().m_Outputs[0]); |
| 696 | armnn::ClSubTensorHandle* sOut1 = dynamic_cast<armnn::ClSubTensorHandle*>(wlSplitter->GetData().m_Outputs[1]); |
| 697 | armnn::ClSubTensorHandle* activ0_0Im = dynamic_cast<armnn::ClSubTensorHandle*>(wlActiv0_0->GetData().m_Inputs[0]); |
| 698 | armnn::ClSubTensorHandle* activ0_1Im = dynamic_cast<armnn::ClSubTensorHandle*>(wlActiv0_1->GetData().m_Inputs[0]); |
| 699 | armnn::ClSubTensorHandle* activ1_0Im = dynamic_cast<armnn::ClSubTensorHandle*>(wlActiv1_0->GetData().m_Inputs[0]); |
| 700 | armnn::ClSubTensorHandle* activ1_1Im = dynamic_cast<armnn::ClSubTensorHandle*>(wlActiv1_1->GetData().m_Inputs[0]); |
| 701 | |
| 702 | |
| 703 | BOOST_TEST(sOut0); |
| 704 | BOOST_TEST(sOut1); |
| 705 | BOOST_TEST(activ0_0Im); |
| 706 | BOOST_TEST(activ0_1Im); |
| 707 | BOOST_TEST(activ1_0Im); |
| 708 | BOOST_TEST(activ1_1Im); |
| 709 | |
| 710 | bool validDataPointers = (sOut0 == activ0_0Im) && (sOut0 == activ0_1Im) && |
| 711 | (sOut1 == activ1_0Im) && (sOut1 == activ1_1Im); |
| 712 | |
| 713 | BOOST_TEST(validDataPointers); |
| 714 | } |
| 715 | |
Matteo Martincigh | db16dd3 | 2019-08-27 16:41:11 +0100 | [diff] [blame] | 716 | #if defined(ARMNNREF_ENABLED) |
Matteo Martincigh | e67edb2 | 2019-08-14 14:05:46 +0100 | [diff] [blame] | 717 | |
| 718 | // This test unit needs the reference backend, it's not available if the reference backend is not built |
| 719 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 720 | BOOST_AUTO_TEST_CASE(CreateMemCopyWorkloadsCl) |
| 721 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 722 | ClWorkloadFactory factory = |
| 723 | ClWorkloadFactoryHelper::GetFactory(ClWorkloadFactoryHelper::GetMemoryManager()); |
| 724 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 725 | CreateMemCopyWorkloads<IClTensorHandle>(factory); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 726 | } |
| 727 | |
Matteo Martincigh | e67edb2 | 2019-08-14 14:05:46 +0100 | [diff] [blame] | 728 | #endif |
| 729 | |
Matteo Martincigh | bcd3c85 | 2018-09-28 14:14:12 +0100 | [diff] [blame] | 730 | template <typename L2NormalizationWorkloadType, typename armnn::DataType DataType> |
| 731 | static void ClL2NormalizationWorkloadTest(DataLayout dataLayout) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 732 | { |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 733 | Graph graph; |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 734 | ClWorkloadFactory factory = |
| 735 | ClWorkloadFactoryHelper::GetFactory(ClWorkloadFactoryHelper::GetMemoryManager()); |
| 736 | |
Matteo Martincigh | 2400b6d | 2018-10-09 18:19:20 +0100 | [diff] [blame] | 737 | auto workload = |
| 738 | CreateL2NormalizationWorkloadTest<L2NormalizationWorkloadType, DataType>(factory, graph, dataLayout); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 739 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 740 | // Checks that inputs/outputs are as we expect them (see definition of CreateNormalizationWorkloadTest). |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 741 | L2NormalizationQueueDescriptor queueDescriptor = workload->GetData(); |
Jan Eilers | bb446e5 | 2020-04-02 13:56:54 +0100 | [diff] [blame] | 742 | auto inputHandle = PolymorphicDowncast<IClTensorHandle*>(queueDescriptor.m_Inputs[0]); |
| 743 | auto outputHandle = PolymorphicDowncast<IClTensorHandle*>(queueDescriptor.m_Outputs[0]); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 744 | |
Mike Kelly | db48288 | 2019-06-14 12:35:24 +0100 | [diff] [blame] | 745 | TensorShape inputShape = (dataLayout == DataLayout::NCHW) ? std::initializer_list<unsigned int>({ 5, 20, 50, 67 }) |
| 746 | : std::initializer_list<unsigned int>({ 5, 50, 67, 20 }); |
| 747 | TensorShape outputShape = (dataLayout == DataLayout::NCHW) ? std::initializer_list<unsigned int>({ 5, 20, 50, 67 }) |
| 748 | : std::initializer_list<unsigned int>({ 5, 50, 67, 20 }); |
Matteo Martincigh | 2400b6d | 2018-10-09 18:19:20 +0100 | [diff] [blame] | 749 | |
Mike Kelly | db48288 | 2019-06-14 12:35:24 +0100 | [diff] [blame] | 750 | BOOST_TEST((inputHandle->GetShape() == inputShape)); |
| 751 | BOOST_TEST((outputHandle->GetShape() == outputShape)); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 752 | } |
| 753 | |
Matteo Martincigh | bcd3c85 | 2018-09-28 14:14:12 +0100 | [diff] [blame] | 754 | BOOST_AUTO_TEST_CASE(CreateL2NormalizationFloatNchwWorkload) |
| 755 | { |
| 756 | ClL2NormalizationWorkloadTest<ClL2NormalizationFloatWorkload, armnn::DataType::Float32>(DataLayout::NCHW); |
| 757 | } |
| 758 | |
| 759 | BOOST_AUTO_TEST_CASE(CreateL2NormalizationFloatNhwcWorkload) |
| 760 | { |
| 761 | ClL2NormalizationWorkloadTest<ClL2NormalizationFloatWorkload, armnn::DataType::Float32>(DataLayout::NHWC); |
| 762 | } |
| 763 | |
| 764 | BOOST_AUTO_TEST_CASE(CreateL2NormalizationFloat16NchwWorkload) |
| 765 | { |
| 766 | ClL2NormalizationWorkloadTest<ClL2NormalizationFloatWorkload, armnn::DataType::Float16>(DataLayout::NCHW); |
| 767 | } |
| 768 | |
| 769 | BOOST_AUTO_TEST_CASE(CreateL2NormalizationFloat16NhwcWorkload) |
| 770 | { |
| 771 | ClL2NormalizationWorkloadTest<ClL2NormalizationFloatWorkload, armnn::DataType::Float16>(DataLayout::NHWC); |
| 772 | } |
| 773 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 774 | template <typename LstmWorkloadType> |
| 775 | static void ClCreateLstmWorkloadTest() |
| 776 | { |
| 777 | Graph graph; |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 778 | ClWorkloadFactory factory = |
| 779 | ClWorkloadFactoryHelper::GetFactory(ClWorkloadFactoryHelper::GetMemoryManager()); |
| 780 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 781 | auto workload = CreateLstmWorkloadTest<LstmWorkloadType>(factory, graph); |
| 782 | |
| 783 | LstmQueueDescriptor queueDescriptor = workload->GetData(); |
Jan Eilers | bb446e5 | 2020-04-02 13:56:54 +0100 | [diff] [blame] | 784 | auto inputHandle = PolymorphicDowncast<IClTensorHandle*>(queueDescriptor.m_Inputs[0]); |
| 785 | auto outputHandle = PolymorphicDowncast<IClTensorHandle*>(queueDescriptor.m_Outputs[1]); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 786 | BOOST_TEST(CompareIClTensorHandleShape(inputHandle, { 2, 2 })); |
| 787 | BOOST_TEST(CompareIClTensorHandleShape(outputHandle, { 2, 4 })); |
| 788 | } |
| 789 | |
arovir01 | 9e53a35 | 2018-08-31 15:26:35 +0100 | [diff] [blame] | 790 | BOOST_AUTO_TEST_CASE(CreateLSTMWorkloadFloatWorkload) |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 791 | { |
arovir01 | 9e53a35 | 2018-08-31 15:26:35 +0100 | [diff] [blame] | 792 | ClCreateLstmWorkloadTest<ClLstmFloatWorkload>(); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 793 | } |
| 794 | |
Aron Virginas-Tar | cc0cefb | 2019-07-02 17:25:47 +0100 | [diff] [blame] | 795 | template <typename ResizeWorkloadType, typename armnn::DataType DataType> |
| 796 | static void ClResizeWorkloadTest(DataLayout dataLayout) |
James Conroy | 074f371 | 2018-10-03 09:32:03 +0100 | [diff] [blame] | 797 | { |
| 798 | Graph graph; |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 799 | ClWorkloadFactory factory = |
| 800 | ClWorkloadFactoryHelper::GetFactory(ClWorkloadFactoryHelper::GetMemoryManager()); |
James Conroy | 074f371 | 2018-10-03 09:32:03 +0100 | [diff] [blame] | 801 | |
Aron Virginas-Tar | cc0cefb | 2019-07-02 17:25:47 +0100 | [diff] [blame] | 802 | auto workload = CreateResizeBilinearWorkloadTest<ResizeWorkloadType, DataType>(factory, graph, dataLayout); |
James Conroy | 074f371 | 2018-10-03 09:32:03 +0100 | [diff] [blame] | 803 | |
Aron Virginas-Tar | 169d2f1 | 2019-07-01 19:01:44 +0100 | [diff] [blame] | 804 | auto queueDescriptor = workload->GetData(); |
| 805 | |
Jan Eilers | bb446e5 | 2020-04-02 13:56:54 +0100 | [diff] [blame] | 806 | auto inputHandle = PolymorphicDowncast<IClTensorHandle*>(queueDescriptor.m_Inputs[0]); |
| 807 | auto outputHandle = PolymorphicDowncast<IClTensorHandle*>(queueDescriptor.m_Outputs[0]); |
James Conroy | 074f371 | 2018-10-03 09:32:03 +0100 | [diff] [blame] | 808 | |
| 809 | switch (dataLayout) |
| 810 | { |
| 811 | case DataLayout::NHWC: |
| 812 | BOOST_TEST(CompareIClTensorHandleShape(inputHandle, { 2, 4, 4, 3 })); |
| 813 | BOOST_TEST(CompareIClTensorHandleShape(outputHandle, { 2, 2, 2, 3 })); |
| 814 | break; |
James Conroy | 6948227 | 2018-10-19 10:41:35 +0100 | [diff] [blame] | 815 | case DataLayout::NCHW: |
| 816 | default: |
James Conroy | 074f371 | 2018-10-03 09:32:03 +0100 | [diff] [blame] | 817 | BOOST_TEST(CompareIClTensorHandleShape(inputHandle, { 2, 3, 4, 4 })); |
| 818 | BOOST_TEST(CompareIClTensorHandleShape(outputHandle, { 2, 3, 2, 2 })); |
| 819 | } |
| 820 | } |
| 821 | |
Aron Virginas-Tar | cc0cefb | 2019-07-02 17:25:47 +0100 | [diff] [blame] | 822 | BOOST_AUTO_TEST_CASE(CreateResizeFloat32NchwWorkload) |
James Conroy | 074f371 | 2018-10-03 09:32:03 +0100 | [diff] [blame] | 823 | { |
Aron Virginas-Tar | cc0cefb | 2019-07-02 17:25:47 +0100 | [diff] [blame] | 824 | ClResizeWorkloadTest<ClResizeWorkload, armnn::DataType::Float32>(DataLayout::NCHW); |
James Conroy | 074f371 | 2018-10-03 09:32:03 +0100 | [diff] [blame] | 825 | } |
| 826 | |
Aron Virginas-Tar | cc0cefb | 2019-07-02 17:25:47 +0100 | [diff] [blame] | 827 | BOOST_AUTO_TEST_CASE(CreateResizeFloat16NchwWorkload) |
James Conroy | 074f371 | 2018-10-03 09:32:03 +0100 | [diff] [blame] | 828 | { |
Aron Virginas-Tar | cc0cefb | 2019-07-02 17:25:47 +0100 | [diff] [blame] | 829 | ClResizeWorkloadTest<ClResizeWorkload, armnn::DataType::Float16>(DataLayout::NCHW); |
James Conroy | 074f371 | 2018-10-03 09:32:03 +0100 | [diff] [blame] | 830 | } |
| 831 | |
Aron Virginas-Tar | cc0cefb | 2019-07-02 17:25:47 +0100 | [diff] [blame] | 832 | BOOST_AUTO_TEST_CASE(CreateResizeUint8NchwWorkload) |
James Conroy | 074f371 | 2018-10-03 09:32:03 +0100 | [diff] [blame] | 833 | { |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 834 | ClResizeWorkloadTest<ClResizeWorkload, armnn::DataType::QAsymmU8>(DataLayout::NCHW); |
James Conroy | 074f371 | 2018-10-03 09:32:03 +0100 | [diff] [blame] | 835 | } |
| 836 | |
Aron Virginas-Tar | cc0cefb | 2019-07-02 17:25:47 +0100 | [diff] [blame] | 837 | BOOST_AUTO_TEST_CASE(CreateResizeFloat32NhwcWorkload) |
James Conroy | 074f371 | 2018-10-03 09:32:03 +0100 | [diff] [blame] | 838 | { |
Aron Virginas-Tar | cc0cefb | 2019-07-02 17:25:47 +0100 | [diff] [blame] | 839 | ClResizeWorkloadTest<ClResizeWorkload, armnn::DataType::Float32>(DataLayout::NHWC); |
| 840 | } |
| 841 | |
| 842 | BOOST_AUTO_TEST_CASE(CreateResizeFloat16NhwcWorkload) |
| 843 | { |
| 844 | ClResizeWorkloadTest<ClResizeWorkload, armnn::DataType::Float16>(DataLayout::NHWC); |
| 845 | } |
| 846 | |
| 847 | BOOST_AUTO_TEST_CASE(CreateResizeUint8NhwcWorkload) |
| 848 | { |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 849 | ClResizeWorkloadTest<ClResizeWorkload, armnn::DataType::QAsymmU8>(DataLayout::NHWC); |
James Conroy | 074f371 | 2018-10-03 09:32:03 +0100 | [diff] [blame] | 850 | } |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 851 | |
Matteo Martincigh | 28dcab6 | 2018-10-19 16:40:03 +0100 | [diff] [blame] | 852 | template <typename MeanWorkloadType, typename armnn::DataType DataType> |
| 853 | static void ClMeanWorkloadTest() |
| 854 | { |
| 855 | Graph graph; |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 856 | ClWorkloadFactory factory = |
| 857 | ClWorkloadFactoryHelper::GetFactory(ClWorkloadFactoryHelper::GetMemoryManager()); |
| 858 | |
Matteo Martincigh | 28dcab6 | 2018-10-19 16:40:03 +0100 | [diff] [blame] | 859 | auto workload = CreateMeanWorkloadTest<MeanWorkloadType, DataType>(factory, graph); |
| 860 | |
| 861 | // Checks that inputs/outputs are as we expect them (see definition of CreateMeanWorkloadTest). |
| 862 | MeanQueueDescriptor queueDescriptor = workload->GetData(); |
Jan Eilers | bb446e5 | 2020-04-02 13:56:54 +0100 | [diff] [blame] | 863 | auto inputHandle = PolymorphicDowncast<IClTensorHandle*>(queueDescriptor.m_Inputs[0]); |
| 864 | auto outputHandle = PolymorphicDowncast<IClTensorHandle*>(queueDescriptor.m_Outputs[0]); |
Matteo Martincigh | 28dcab6 | 2018-10-19 16:40:03 +0100 | [diff] [blame] | 865 | |
| 866 | // 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] | 867 | BOOST_TEST(CompareIClTensorHandleShape(inputHandle, { 1, 3, 7, 4 })); |
| 868 | BOOST_TEST(CompareIClTensorHandleShape(outputHandle, { 1, 4 })); |
Matteo Martincigh | 28dcab6 | 2018-10-19 16:40:03 +0100 | [diff] [blame] | 869 | } |
| 870 | |
| 871 | BOOST_AUTO_TEST_CASE(CreateMeanFloat32Workload) |
| 872 | { |
| 873 | ClMeanWorkloadTest<ClMeanWorkload, armnn::DataType::Float32>(); |
| 874 | } |
| 875 | |
| 876 | BOOST_AUTO_TEST_CASE(CreateMeanFloat16Workload) |
| 877 | { |
| 878 | ClMeanWorkloadTest<ClMeanWorkload, armnn::DataType::Float16>(); |
| 879 | } |
| 880 | |
| 881 | BOOST_AUTO_TEST_CASE(CreateMeanUint8Workload) |
| 882 | { |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 883 | ClMeanWorkloadTest<ClMeanWorkload, armnn::DataType::QAsymmU8>(); |
Matteo Martincigh | 28dcab6 | 2018-10-19 16:40:03 +0100 | [diff] [blame] | 884 | } |
| 885 | |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 886 | template <typename ConcatWorkloadType, armnn::DataType DataType> |
| 887 | static void ClCreateConcatWorkloadTest(std::initializer_list<unsigned int> outputShape, |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 888 | unsigned int concatAxis) |
| 889 | { |
| 890 | Graph graph; |
| 891 | ClWorkloadFactory factory = |
| 892 | ClWorkloadFactoryHelper::GetFactory(ClWorkloadFactoryHelper::GetMemoryManager()); |
| 893 | |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 894 | auto workload = CreateConcatWorkloadTest<ConcatWorkloadType, DataType>(factory, graph, outputShape, concatAxis); |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 895 | |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 896 | ConcatQueueDescriptor queueDescriptor = workload->GetData(); |
Jan Eilers | bb446e5 | 2020-04-02 13:56:54 +0100 | [diff] [blame] | 897 | auto inputHandle0 = PolymorphicDowncast<IClTensorHandle*>(queueDescriptor.m_Inputs[0]); |
| 898 | auto inputHandle1 = PolymorphicDowncast<IClTensorHandle*>(queueDescriptor.m_Inputs[1]); |
| 899 | auto outputHandle = PolymorphicDowncast<IClTensorHandle*>(queueDescriptor.m_Outputs[0]); |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 900 | |
| 901 | BOOST_TEST(CompareIClTensorHandleShape(inputHandle0, { 2, 3, 2, 5 })); |
| 902 | BOOST_TEST(CompareIClTensorHandleShape(inputHandle1, { 2, 3, 2, 5 })); |
| 903 | BOOST_TEST(CompareIClTensorHandleShape(outputHandle, outputShape)); |
| 904 | } |
| 905 | |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 906 | BOOST_AUTO_TEST_CASE(CreateConcatDim0Float32Workload) |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 907 | { |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 908 | ClCreateConcatWorkloadTest<ClConcatWorkload, armnn::DataType::Float32>({ 4, 3, 2, 5 }, 0); |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 909 | } |
| 910 | |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 911 | BOOST_AUTO_TEST_CASE(CreateConcatDim1Float32Workload) |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 912 | { |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 913 | ClCreateConcatWorkloadTest<ClConcatWorkload, armnn::DataType::Float32>({ 2, 6, 2, 5 }, 1); |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 914 | } |
| 915 | |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 916 | BOOST_AUTO_TEST_CASE(CreateConcatDim3Float32Workload) |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 917 | { |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 918 | ClCreateConcatWorkloadTest<ClConcatWorkload, armnn::DataType::Float32>({ 2, 3, 2, 10 }, 3); |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 919 | } |
| 920 | |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 921 | BOOST_AUTO_TEST_CASE(CreateConcatDim0Uint8Workload) |
narpra01 | 63b0882 | 2018-11-20 11:29:12 +0000 | [diff] [blame] | 922 | { |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 923 | ClCreateConcatWorkloadTest<ClConcatWorkload, armnn::DataType::QAsymmU8>({ 4, 3, 2, 5 }, 0); |
narpra01 | 63b0882 | 2018-11-20 11:29:12 +0000 | [diff] [blame] | 924 | } |
| 925 | |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 926 | BOOST_AUTO_TEST_CASE(CreateConcatDim1Uint8Workload) |
narpra01 | 63b0882 | 2018-11-20 11:29:12 +0000 | [diff] [blame] | 927 | { |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 928 | ClCreateConcatWorkloadTest<ClConcatWorkload, armnn::DataType::QAsymmU8>({ 2, 6, 2, 5 }, 1); |
narpra01 | 63b0882 | 2018-11-20 11:29:12 +0000 | [diff] [blame] | 929 | } |
| 930 | |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 931 | BOOST_AUTO_TEST_CASE(CreateConcatDim3Uint8Workload) |
narpra01 | 63b0882 | 2018-11-20 11:29:12 +0000 | [diff] [blame] | 932 | { |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 933 | ClCreateConcatWorkloadTest<ClConcatWorkload, armnn::DataType::QAsymmU8>({ 2, 3, 2, 10 }, 3); |
narpra01 | 63b0882 | 2018-11-20 11:29:12 +0000 | [diff] [blame] | 934 | } |
| 935 | |
James Conroy | 6059784 | 2019-07-02 10:57:56 +0100 | [diff] [blame] | 936 | template <typename SpaceToDepthWorkloadType, typename armnn::DataType DataType> |
| 937 | static void ClSpaceToDepthWorkloadTest() |
| 938 | { |
| 939 | Graph graph; |
| 940 | ClWorkloadFactory factory = |
| 941 | ClWorkloadFactoryHelper::GetFactory(ClWorkloadFactoryHelper::GetMemoryManager()); |
| 942 | |
| 943 | auto workload = CreateSpaceToDepthWorkloadTest<SpaceToDepthWorkloadType, DataType>(factory, graph); |
| 944 | |
| 945 | SpaceToDepthQueueDescriptor queueDescriptor = workload->GetData(); |
Jan Eilers | bb446e5 | 2020-04-02 13:56:54 +0100 | [diff] [blame] | 946 | auto inputHandle = PolymorphicDowncast<IClTensorHandle*>(queueDescriptor.m_Inputs[0]); |
| 947 | auto outputHandle = PolymorphicDowncast<IClTensorHandle*>(queueDescriptor.m_Outputs[0]); |
James Conroy | 6059784 | 2019-07-02 10:57:56 +0100 | [diff] [blame] | 948 | |
| 949 | BOOST_TEST(CompareIClTensorHandleShape(inputHandle, { 1, 2, 2, 1 })); |
| 950 | BOOST_TEST(CompareIClTensorHandleShape(outputHandle, { 1, 1, 1, 4 })); |
| 951 | } |
| 952 | |
| 953 | BOOST_AUTO_TEST_CASE(CreateSpaceToDepthFloat32Workload) |
| 954 | { |
| 955 | ClSpaceToDepthWorkloadTest<ClSpaceToDepthWorkload, armnn::DataType::Float32>(); |
| 956 | } |
| 957 | |
| 958 | BOOST_AUTO_TEST_CASE(CreateSpaceToDepthFloat16Workload) |
| 959 | { |
| 960 | ClSpaceToDepthWorkloadTest<ClSpaceToDepthWorkload, armnn::DataType::Float16>(); |
| 961 | } |
| 962 | |
| 963 | BOOST_AUTO_TEST_CASE(CreateSpaceToDepthQAsymm8Workload) |
| 964 | { |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 965 | ClSpaceToDepthWorkloadTest<ClSpaceToDepthWorkload, armnn::DataType::QAsymmU8>(); |
James Conroy | 6059784 | 2019-07-02 10:57:56 +0100 | [diff] [blame] | 966 | } |
| 967 | |
| 968 | BOOST_AUTO_TEST_CASE(CreateSpaceToDepthQSymm16Workload) |
| 969 | { |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 970 | ClSpaceToDepthWorkloadTest<ClSpaceToDepthWorkload, armnn::DataType::QSymmS16>(); |
James Conroy | 6059784 | 2019-07-02 10:57:56 +0100 | [diff] [blame] | 971 | } |
| 972 | |
Matthew Jackson | d516610 | 2019-07-31 14:06:28 +0100 | [diff] [blame] | 973 | template <armnn::DataType DataType> |
| 974 | static void ClCreateStackWorkloadTest(const std::initializer_list<unsigned int>& inputShape, |
| 975 | const std::initializer_list<unsigned int>& outputShape, |
| 976 | unsigned int axis, |
| 977 | unsigned int numInputs) |
| 978 | { |
| 979 | armnn::Graph graph; |
| 980 | ClWorkloadFactory factory = |
| 981 | ClWorkloadFactoryHelper::GetFactory(ClWorkloadFactoryHelper::GetMemoryManager()); |
| 982 | |
| 983 | auto workload = CreateStackWorkloadTest<ClStackWorkload, DataType>(factory, |
| 984 | graph, |
| 985 | TensorShape(inputShape), |
| 986 | TensorShape(outputShape), |
| 987 | axis, |
| 988 | numInputs); |
| 989 | |
| 990 | // Check inputs and output are as expected |
| 991 | StackQueueDescriptor queueDescriptor = workload->GetData(); |
| 992 | for (unsigned int i = 0; i < numInputs; ++i) |
| 993 | { |
Jan Eilers | bb446e5 | 2020-04-02 13:56:54 +0100 | [diff] [blame] | 994 | auto inputHandle = PolymorphicDowncast<IClTensorHandle*>(queueDescriptor.m_Inputs[i]); |
Matthew Jackson | d516610 | 2019-07-31 14:06:28 +0100 | [diff] [blame] | 995 | BOOST_TEST(CompareIClTensorHandleShape(inputHandle, inputShape)); |
| 996 | } |
Jan Eilers | bb446e5 | 2020-04-02 13:56:54 +0100 | [diff] [blame] | 997 | auto outputHandle = PolymorphicDowncast<IClTensorHandle*>(queueDescriptor.m_Outputs[0]); |
Matthew Jackson | d516610 | 2019-07-31 14:06:28 +0100 | [diff] [blame] | 998 | BOOST_TEST(CompareIClTensorHandleShape(outputHandle, outputShape)); |
| 999 | } |
| 1000 | |
| 1001 | BOOST_AUTO_TEST_CASE(CreateStackFloat32Workload) |
| 1002 | { |
| 1003 | ClCreateStackWorkloadTest<armnn::DataType::Float32>({ 3, 4, 5 }, { 3, 4, 2, 5 }, 2, 2); |
| 1004 | } |
| 1005 | |
Matthew Jackson | e69c399 | 2019-09-09 14:31:21 +0100 | [diff] [blame] | 1006 | BOOST_AUTO_TEST_CASE(CreateStackFloat16Workload) |
| 1007 | { |
| 1008 | ClCreateStackWorkloadTest<armnn::DataType::Float16>({ 3, 4, 5 }, { 3, 4, 2, 5 }, 2, 2); |
| 1009 | } |
| 1010 | |
Matthew Jackson | d516610 | 2019-07-31 14:06:28 +0100 | [diff] [blame] | 1011 | BOOST_AUTO_TEST_CASE(CreateStackUint8Workload) |
| 1012 | { |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 1013 | ClCreateStackWorkloadTest<armnn::DataType::QAsymmU8>({ 3, 4, 5 }, { 3, 4, 2, 5 }, 2, 2); |
Matthew Jackson | d516610 | 2019-07-31 14:06:28 +0100 | [diff] [blame] | 1014 | } |
| 1015 | |
Ferran Balaguer | 737d9ff | 2019-08-01 09:58:08 +0100 | [diff] [blame] | 1016 | template <typename QuantizedLstmWorkloadType> |
| 1017 | static void ClCreateQuantizedLstmWorkloadTest() |
| 1018 | { |
| 1019 | using namespace armnn::armcomputetensorutils; |
Ferran Balaguer | 737d9ff | 2019-08-01 09:58:08 +0100 | [diff] [blame] | 1020 | |
| 1021 | Graph graph; |
| 1022 | ClWorkloadFactory factory = |
| 1023 | ClWorkloadFactoryHelper::GetFactory(ClWorkloadFactoryHelper::GetMemoryManager()); |
| 1024 | |
| 1025 | auto workload = CreateQuantizedLstmWorkloadTest<QuantizedLstmWorkloadType>(factory, graph); |
| 1026 | |
| 1027 | QuantizedLstmQueueDescriptor queueDescriptor = workload->GetData(); |
| 1028 | |
Jan Eilers | bb446e5 | 2020-04-02 13:56:54 +0100 | [diff] [blame] | 1029 | IAclTensorHandle* inputHandle = PolymorphicDowncast<IAclTensorHandle*>(queueDescriptor.m_Inputs[0]); |
Ferran Balaguer | 737d9ff | 2019-08-01 09:58:08 +0100 | [diff] [blame] | 1030 | BOOST_TEST((inputHandle->GetShape() == TensorShape({2, 2}))); |
| 1031 | BOOST_TEST((inputHandle->GetDataType() == arm_compute::DataType::QASYMM8)); |
| 1032 | |
Jan Eilers | bb446e5 | 2020-04-02 13:56:54 +0100 | [diff] [blame] | 1033 | IAclTensorHandle* cellStateInHandle = PolymorphicDowncast<IAclTensorHandle*>(queueDescriptor.m_Inputs[1]); |
Ferran Balaguer | 737d9ff | 2019-08-01 09:58:08 +0100 | [diff] [blame] | 1034 | BOOST_TEST((cellStateInHandle->GetShape() == TensorShape({2, 4}))); |
| 1035 | BOOST_TEST((cellStateInHandle->GetDataType() == arm_compute::DataType::QSYMM16)); |
| 1036 | |
Jan Eilers | bb446e5 | 2020-04-02 13:56:54 +0100 | [diff] [blame] | 1037 | IAclTensorHandle* outputStateInHandle = PolymorphicDowncast<IAclTensorHandle*>(queueDescriptor.m_Inputs[2]); |
Ferran Balaguer | 737d9ff | 2019-08-01 09:58:08 +0100 | [diff] [blame] | 1038 | BOOST_TEST((outputStateInHandle->GetShape() == TensorShape({2, 4}))); |
| 1039 | BOOST_TEST((outputStateInHandle->GetDataType() == arm_compute::DataType::QASYMM8)); |
| 1040 | |
Jan Eilers | bb446e5 | 2020-04-02 13:56:54 +0100 | [diff] [blame] | 1041 | IAclTensorHandle* cellStateOutHandle = PolymorphicDowncast<IAclTensorHandle*>(queueDescriptor.m_Outputs[0]); |
Ferran Balaguer | 737d9ff | 2019-08-01 09:58:08 +0100 | [diff] [blame] | 1042 | BOOST_TEST((cellStateOutHandle->GetShape() == TensorShape({2, 4}))); |
| 1043 | BOOST_TEST((cellStateOutHandle->GetDataType() == arm_compute::DataType::QSYMM16)); |
| 1044 | |
Jan Eilers | bb446e5 | 2020-04-02 13:56:54 +0100 | [diff] [blame] | 1045 | IAclTensorHandle* outputStateOutHandle = PolymorphicDowncast<IAclTensorHandle*>(queueDescriptor.m_Outputs[1]); |
Ferran Balaguer | 737d9ff | 2019-08-01 09:58:08 +0100 | [diff] [blame] | 1046 | BOOST_TEST((outputStateOutHandle->GetShape() == TensorShape({2, 4}))); |
| 1047 | BOOST_TEST((outputStateOutHandle->GetDataType() == arm_compute::DataType::QASYMM8)); |
| 1048 | } |
| 1049 | |
| 1050 | BOOST_AUTO_TEST_CASE(CreateQuantizedLstmWorkload) |
| 1051 | { |
| 1052 | ClCreateQuantizedLstmWorkloadTest<ClQuantizedLstmWorkload>(); |
| 1053 | } |
| 1054 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1055 | BOOST_AUTO_TEST_SUITE_END() |