telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1 | // |
Teresa Charlin | 8398edc | 2020-07-20 14:23:02 +0100 | [diff] [blame] | 2 | // Copyright © 2017 Arm Ltd and Contributors. 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 | |
Sadik Armagan | 04a7297 | 2020-09-14 15:44:18 +0100 | [diff] [blame] | 9 | #include <armnn/utility/Assert.hpp> |
| 10 | #include <armnn/utility/IgnoreUnused.hpp> |
Jan Eilers | bb446e5 | 2020-04-02 13:56:54 +0100 | [diff] [blame] | 11 | #include <armnn/utility/PolymorphicDowncast.hpp> |
Colm Donelan | 0c47974 | 2021-12-10 12:43:54 +0000 | [diff] [blame] | 12 | #include <armnn/backends/MemCopyWorkload.hpp> |
Sadik Armagan | a097d2a | 2021-11-24 15:47:28 +0000 | [diff] [blame] | 13 | #include <armnnTestUtils/TensorCopyUtils.hpp> |
Colm Donelan | c42a987 | 2022-02-02 16:35:09 +0000 | [diff] [blame] | 14 | #include <armnnTestUtils/TensorHelpers.hpp> |
Colm Donelan | 0c47974 | 2021-12-10 12:43:54 +0000 | [diff] [blame] | 15 | #include <armnnTestUtils/WorkloadTestUtils.hpp> |
Aron Virginas-Tar | 3b278e9 | 2018-10-12 13:00:55 +0100 | [diff] [blame] | 16 | |
Aron Virginas-Tar | c9cc804 | 2018-11-01 16:15:57 +0000 | [diff] [blame] | 17 | #include <aclCommon/test/CreateWorkloadClNeon.hpp> |
Ferran Balaguer | 737d9ff | 2019-08-01 09:58:08 +0100 | [diff] [blame] | 18 | #include <aclCommon/ArmComputeTensorUtils.hpp> |
Aron Virginas-Tar | 3b278e9 | 2018-10-12 13:00:55 +0100 | [diff] [blame] | 19 | |
Narumol Prangnawarat | e2af6f4 | 2022-01-28 17:59:18 +0000 | [diff] [blame] | 20 | #include <cl/ClImportTensorHandle.hpp> |
| 21 | #include <cl/ClImportTensorHandleFactory.hpp> |
Aron Virginas-Tar | c9cc804 | 2018-11-01 16:15:57 +0000 | [diff] [blame] | 22 | #include <cl/ClTensorHandle.hpp> |
| 23 | #include <cl/ClWorkloadFactory.hpp> |
| 24 | #include <cl/workloads/ClWorkloads.hpp> |
| 25 | #include <cl/workloads/ClWorkloadUtils.hpp> |
arovir01 | 43095f3 | 2018-10-09 18:04:24 +0100 | [diff] [blame] | 26 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 27 | #include <doctest/doctest.h> |
| 28 | |
Colm Donelan | 25ab3a8 | 2021-05-17 13:01:52 +0100 | [diff] [blame] | 29 | armnn::PredicateResult CompareIClTensorHandleShape(IClTensorHandle* tensorHandle, |
| 30 | std::initializer_list<unsigned int> expectedDimensions) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 31 | { |
| 32 | return CompareTensorHandleShape<IClTensorHandle>(tensorHandle, expectedDimensions); |
| 33 | } |
| 34 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 35 | TEST_SUITE("CreateWorkloadCl") |
| 36 | { |
Nattapat Chaimanowong | e06757e | 2018-10-11 15:39:18 +0100 | [diff] [blame] | 37 | template <armnn::DataType DataType> |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 38 | static void ClCreateActivationWorkloadTest() |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 39 | { |
| 40 | Graph graph; |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 41 | ClWorkloadFactory factory = |
| 42 | ClWorkloadFactoryHelper::GetFactory(ClWorkloadFactoryHelper::GetMemoryManager()); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 43 | |
Nattapat Chaimanowong | e06757e | 2018-10-11 15:39:18 +0100 | [diff] [blame] | 44 | auto workload = CreateActivationWorkloadTest<ClActivationWorkload, DataType>(factory, graph); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 45 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 46 | // Checks that inputs/outputs are as we expect them (see definition of CreateActivationWorkloadTest). |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 47 | ActivationQueueDescriptor queueDescriptor = workload->GetData(); |
Jan Eilers | bb446e5 | 2020-04-02 13:56:54 +0100 | [diff] [blame] | 48 | auto inputHandle = PolymorphicDowncast<IClTensorHandle*>(queueDescriptor.m_Inputs[0]); |
| 49 | auto outputHandle = PolymorphicDowncast<IClTensorHandle*>(queueDescriptor.m_Outputs[0]); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 50 | |
Colm Donelan | 25ab3a8 | 2021-05-17 13:01:52 +0100 | [diff] [blame] | 51 | auto predResult = CompareIClTensorHandleShape(inputHandle, {1, 1}); |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 52 | CHECK_MESSAGE(predResult.m_Result, predResult.m_Message.str()); |
Colm Donelan | 25ab3a8 | 2021-05-17 13:01:52 +0100 | [diff] [blame] | 53 | |
| 54 | predResult = CompareIClTensorHandleShape(outputHandle, {1, 1}); |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 55 | CHECK_MESSAGE(predResult.m_Result, predResult.m_Message.str()); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 56 | } |
| 57 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 58 | TEST_CASE_FIXTURE(ClContextControlFixture, "CreateActivationFloatWorkload") |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 59 | { |
Nattapat Chaimanowong | e06757e | 2018-10-11 15:39:18 +0100 | [diff] [blame] | 60 | ClCreateActivationWorkloadTest<armnn::DataType::Float32>(); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 61 | } |
| 62 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 63 | TEST_CASE_FIXTURE(ClContextControlFixture, "CreateActivationFloat16Workload") |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 64 | { |
Nattapat Chaimanowong | e06757e | 2018-10-11 15:39:18 +0100 | [diff] [blame] | 65 | ClCreateActivationWorkloadTest<armnn::DataType::Float16>(); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 66 | } |
| 67 | |
David Beck | 4a8692c | 2018-09-07 16:19:24 +0100 | [diff] [blame] | 68 | template <typename WorkloadType, |
| 69 | typename DescriptorType, |
| 70 | typename LayerType, |
| 71 | armnn::DataType DataType> |
Éanna Ó Catháin | d57415d | 2018-11-28 16:24:38 +0000 | [diff] [blame] | 72 | static void ClCreateElementwiseWorkloadTest() |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 73 | { |
| 74 | Graph graph; |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 75 | ClWorkloadFactory factory = |
| 76 | ClWorkloadFactoryHelper::GetFactory(ClWorkloadFactoryHelper::GetMemoryManager()); |
| 77 | |
Éanna Ó Catháin | d57415d | 2018-11-28 16:24:38 +0000 | [diff] [blame] | 78 | auto workload = CreateElementwiseWorkloadTest<WorkloadType, DescriptorType, LayerType, DataType>(factory, graph); |
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 | // 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] | 81 | DescriptorType queueDescriptor = workload->GetData(); |
Jan Eilers | bb446e5 | 2020-04-02 13:56:54 +0100 | [diff] [blame] | 82 | auto inputHandle1 = PolymorphicDowncast<IClTensorHandle*>(queueDescriptor.m_Inputs[0]); |
| 83 | auto inputHandle2 = PolymorphicDowncast<IClTensorHandle*>(queueDescriptor.m_Inputs[1]); |
| 84 | auto outputHandle = PolymorphicDowncast<IClTensorHandle*>(queueDescriptor.m_Outputs[0]); |
Colm Donelan | 25ab3a8 | 2021-05-17 13:01:52 +0100 | [diff] [blame] | 85 | auto predResult = CompareIClTensorHandleShape(inputHandle1, {2, 3}); |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 86 | CHECK_MESSAGE(predResult.m_Result, predResult.m_Message.str()); |
Colm Donelan | 25ab3a8 | 2021-05-17 13:01:52 +0100 | [diff] [blame] | 87 | predResult = CompareIClTensorHandleShape(inputHandle2, {2, 3}); |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 88 | CHECK_MESSAGE(predResult.m_Result, predResult.m_Message.str()); |
Colm Donelan | 25ab3a8 | 2021-05-17 13:01:52 +0100 | [diff] [blame] | 89 | predResult = CompareIClTensorHandleShape(outputHandle, {2, 3}); |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 90 | CHECK_MESSAGE(predResult.m_Result, predResult.m_Message.str()); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 91 | } |
| 92 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 93 | TEST_CASE_FIXTURE(ClContextControlFixture, "CreateAdditionFloatWorkload") |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 94 | { |
Éanna Ó Catháin | d57415d | 2018-11-28 16:24:38 +0000 | [diff] [blame] | 95 | ClCreateElementwiseWorkloadTest<ClAdditionWorkload, |
David Beck | 4a8692c | 2018-09-07 16:19:24 +0100 | [diff] [blame] | 96 | AdditionQueueDescriptor, |
| 97 | AdditionLayer, |
| 98 | armnn::DataType::Float32>(); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 99 | } |
| 100 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 101 | TEST_CASE_FIXTURE(ClContextControlFixture, "CreateAdditionFloat16Workload") |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 102 | { |
Éanna Ó Catháin | d57415d | 2018-11-28 16:24:38 +0000 | [diff] [blame] | 103 | ClCreateElementwiseWorkloadTest<ClAdditionWorkload, |
David Beck | 4a8692c | 2018-09-07 16:19:24 +0100 | [diff] [blame] | 104 | AdditionQueueDescriptor, |
| 105 | AdditionLayer, |
| 106 | armnn::DataType::Float16>(); |
| 107 | } |
| 108 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 109 | TEST_CASE_FIXTURE(ClContextControlFixture, "CreateSubtractionFloatWorkload") |
David Beck | 4a8692c | 2018-09-07 16:19:24 +0100 | [diff] [blame] | 110 | { |
Éanna Ó Catháin | d57415d | 2018-11-28 16:24:38 +0000 | [diff] [blame] | 111 | ClCreateElementwiseWorkloadTest<ClSubtractionWorkload, |
David Beck | 4a8692c | 2018-09-07 16:19:24 +0100 | [diff] [blame] | 112 | SubtractionQueueDescriptor, |
| 113 | SubtractionLayer, |
| 114 | armnn::DataType::Float32>(); |
| 115 | } |
| 116 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 117 | TEST_CASE_FIXTURE(ClContextControlFixture, "CreateSubtractionFloat16Workload") |
David Beck | 4a8692c | 2018-09-07 16:19:24 +0100 | [diff] [blame] | 118 | { |
Éanna Ó Catháin | d57415d | 2018-11-28 16:24:38 +0000 | [diff] [blame] | 119 | ClCreateElementwiseWorkloadTest<ClSubtractionWorkload, |
David Beck | 4a8692c | 2018-09-07 16:19:24 +0100 | [diff] [blame] | 120 | SubtractionQueueDescriptor, |
| 121 | SubtractionLayer, |
| 122 | armnn::DataType::Float16>(); |
| 123 | } |
| 124 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 125 | TEST_CASE_FIXTURE(ClContextControlFixture, "CreateMultiplicationFloatWorkloadTest") |
David Beck | 4a8692c | 2018-09-07 16:19:24 +0100 | [diff] [blame] | 126 | { |
Éanna Ó Catháin | d57415d | 2018-11-28 16:24:38 +0000 | [diff] [blame] | 127 | ClCreateElementwiseWorkloadTest<ClMultiplicationWorkload, |
David Beck | 4a8692c | 2018-09-07 16:19:24 +0100 | [diff] [blame] | 128 | MultiplicationQueueDescriptor, |
| 129 | MultiplicationLayer, |
| 130 | armnn::DataType::Float32>(); |
| 131 | } |
| 132 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 133 | TEST_CASE_FIXTURE(ClContextControlFixture, "CreateMultiplicationFloat16WorkloadTest") |
David Beck | 4a8692c | 2018-09-07 16:19:24 +0100 | [diff] [blame] | 134 | { |
Éanna Ó Catháin | d57415d | 2018-11-28 16:24:38 +0000 | [diff] [blame] | 135 | ClCreateElementwiseWorkloadTest<ClMultiplicationWorkload, |
David Beck | 4a8692c | 2018-09-07 16:19:24 +0100 | [diff] [blame] | 136 | MultiplicationQueueDescriptor, |
| 137 | MultiplicationLayer, |
| 138 | armnn::DataType::Float16>(); |
| 139 | } |
| 140 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 141 | TEST_CASE_FIXTURE(ClContextControlFixture, "CreateMultiplicationUint8WorkloadTest") |
Matthew Bentham | e2ec330 | 2018-10-01 11:32:48 +0100 | [diff] [blame] | 142 | { |
Éanna Ó Catháin | d57415d | 2018-11-28 16:24:38 +0000 | [diff] [blame] | 143 | ClCreateElementwiseWorkloadTest<ClMultiplicationWorkload, |
Matthew Bentham | e2ec330 | 2018-10-01 11:32:48 +0100 | [diff] [blame] | 144 | MultiplicationQueueDescriptor, |
| 145 | MultiplicationLayer, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 146 | armnn::DataType::QAsymmU8>(); |
Matthew Bentham | e2ec330 | 2018-10-01 11:32:48 +0100 | [diff] [blame] | 147 | } |
| 148 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 149 | TEST_CASE_FIXTURE(ClContextControlFixture, "CreateDivisionFloatWorkloadTest") |
David Beck | 4a8692c | 2018-09-07 16:19:24 +0100 | [diff] [blame] | 150 | { |
Teresa Charlin | e11e63d | 2021-04-21 12:56:45 +0100 | [diff] [blame] | 151 | ClCreateElementwiseWorkloadTest<ClDivisionWorkload, |
David Beck | 4a8692c | 2018-09-07 16:19:24 +0100 | [diff] [blame] | 152 | DivisionQueueDescriptor, |
| 153 | DivisionLayer, |
| 154 | armnn::DataType::Float32>(); |
| 155 | } |
| 156 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 157 | TEST_CASE_FIXTURE(ClContextControlFixture, "CreateDivisionFloat16WorkloadTest") |
David Beck | 4a8692c | 2018-09-07 16:19:24 +0100 | [diff] [blame] | 158 | { |
Teresa Charlin | e11e63d | 2021-04-21 12:56:45 +0100 | [diff] [blame] | 159 | ClCreateElementwiseWorkloadTest<ClDivisionWorkload, |
David Beck | 4a8692c | 2018-09-07 16:19:24 +0100 | [diff] [blame] | 160 | DivisionQueueDescriptor, |
| 161 | DivisionLayer, |
| 162 | armnn::DataType::Float16>(); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 163 | } |
| 164 | |
josh minor | 4a3c610 | 2020-01-06 16:40:46 -0600 | [diff] [blame] | 165 | template <typename WorkloadType, |
Aron Virginas-Tar | 1a763dd | 2019-09-10 12:32:08 +0100 | [diff] [blame] | 166 | typename DescriptorType, |
Aron Virginas-Tar | 1a763dd | 2019-09-10 12:32:08 +0100 | [diff] [blame] | 167 | armnn::DataType DataType> |
josh minor | 4a3c610 | 2020-01-06 16:40:46 -0600 | [diff] [blame] | 168 | static void ClCreateElementwiseUnaryWorkloadTest(armnn::UnaryOperation op) |
Aron Virginas-Tar | 1a763dd | 2019-09-10 12:32:08 +0100 | [diff] [blame] | 169 | { |
| 170 | Graph graph; |
| 171 | ClWorkloadFactory factory = |
| 172 | ClWorkloadFactoryHelper::GetFactory(ClWorkloadFactoryHelper::GetMemoryManager()); |
| 173 | |
josh minor | 4a3c610 | 2020-01-06 16:40:46 -0600 | [diff] [blame] | 174 | auto workload = CreateElementwiseUnaryWorkloadTest<WorkloadType, DescriptorType, DataType>(factory, graph, op); |
Aron Virginas-Tar | 1a763dd | 2019-09-10 12:32:08 +0100 | [diff] [blame] | 175 | |
| 176 | DescriptorType queueDescriptor = workload->GetData(); |
| 177 | |
Jan Eilers | bb446e5 | 2020-04-02 13:56:54 +0100 | [diff] [blame] | 178 | auto inputHandle = PolymorphicDowncast<IClTensorHandle*>(queueDescriptor.m_Inputs[0]); |
| 179 | auto outputHandle = PolymorphicDowncast<IClTensorHandle*>(queueDescriptor.m_Outputs[0]); |
Aron Virginas-Tar | 1a763dd | 2019-09-10 12:32:08 +0100 | [diff] [blame] | 180 | |
Colm Donelan | 25ab3a8 | 2021-05-17 13:01:52 +0100 | [diff] [blame] | 181 | auto predResult = CompareIClTensorHandleShape(inputHandle, {2, 3}); |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 182 | CHECK_MESSAGE(predResult.m_Result, predResult.m_Message.str()); |
Colm Donelan | 25ab3a8 | 2021-05-17 13:01:52 +0100 | [diff] [blame] | 183 | |
| 184 | predResult = CompareIClTensorHandleShape(outputHandle, {2, 3}); |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 185 | CHECK_MESSAGE(predResult.m_Result, predResult.m_Message.str()); |
Aron Virginas-Tar | 1a763dd | 2019-09-10 12:32:08 +0100 | [diff] [blame] | 186 | } |
| 187 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 188 | TEST_CASE_FIXTURE(ClContextControlFixture, "CreateRsqrtFloat32WorkloadTest") |
Aron Virginas-Tar | 1a763dd | 2019-09-10 12:32:08 +0100 | [diff] [blame] | 189 | { |
josh minor | 4a3c610 | 2020-01-06 16:40:46 -0600 | [diff] [blame] | 190 | ClCreateElementwiseUnaryWorkloadTest<ClRsqrtWorkload, RsqrtQueueDescriptor, armnn::DataType::Float32>( |
| 191 | UnaryOperation::Rsqrt); |
Aron Virginas-Tar | 1a763dd | 2019-09-10 12:32:08 +0100 | [diff] [blame] | 192 | } |
| 193 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 194 | template <typename BatchNormalizationWorkloadType, armnn::DataType DataType> |
Nikhil Raj | d134093 | 2018-10-18 14:27:50 +0100 | [diff] [blame] | 195 | static void ClCreateBatchNormalizationWorkloadTest(DataLayout dataLayout) |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 196 | { |
| 197 | Graph graph; |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 198 | ClWorkloadFactory factory = |
| 199 | ClWorkloadFactoryHelper::GetFactory(ClWorkloadFactoryHelper::GetMemoryManager()); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 200 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 201 | auto workload = CreateBatchNormalizationWorkloadTest<BatchNormalizationWorkloadType, DataType> |
Nikhil Raj | d134093 | 2018-10-18 14:27:50 +0100 | [diff] [blame] | 202 | (factory, graph, dataLayout); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 203 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 204 | // Checks that inputs/outputs are as we expect them (see definition of CreateBatchNormalizationWorkloadTest). |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 205 | BatchNormalizationQueueDescriptor queueDescriptor = workload->GetData(); |
Jan Eilers | bb446e5 | 2020-04-02 13:56:54 +0100 | [diff] [blame] | 206 | auto inputHandle = PolymorphicDowncast<IClTensorHandle*>(queueDescriptor.m_Inputs[0]); |
| 207 | auto outputHandle = PolymorphicDowncast<IClTensorHandle*>(queueDescriptor.m_Outputs[0]); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 208 | |
Colm Donelan | 25ab3a8 | 2021-05-17 13:01:52 +0100 | [diff] [blame] | 209 | armnn::PredicateResult predResult(true); |
| 210 | switch (dataLayout) |
Nikhil Raj | d134093 | 2018-10-18 14:27:50 +0100 | [diff] [blame] | 211 | { |
| 212 | case DataLayout::NHWC: |
Colm Donelan | 25ab3a8 | 2021-05-17 13:01:52 +0100 | [diff] [blame] | 213 | predResult = CompareIClTensorHandleShape(inputHandle, { 2, 4, 4, 3 }); |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 214 | CHECK_MESSAGE(predResult.m_Result, predResult.m_Message.str()); |
Colm Donelan | 25ab3a8 | 2021-05-17 13:01:52 +0100 | [diff] [blame] | 215 | predResult = CompareIClTensorHandleShape(outputHandle, { 2, 4, 4, 3 }); |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 216 | CHECK_MESSAGE(predResult.m_Result, predResult.m_Message.str()); |
Nikhil Raj | d134093 | 2018-10-18 14:27:50 +0100 | [diff] [blame] | 217 | break; |
| 218 | default: // NCHW |
Colm Donelan | 25ab3a8 | 2021-05-17 13:01:52 +0100 | [diff] [blame] | 219 | predResult = CompareIClTensorHandleShape(inputHandle, { 2, 3, 4, 4 }); |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 220 | CHECK_MESSAGE(predResult.m_Result, predResult.m_Message.str()); |
Colm Donelan | 25ab3a8 | 2021-05-17 13:01:52 +0100 | [diff] [blame] | 221 | predResult = CompareIClTensorHandleShape(outputHandle, { 2, 3, 4, 4 }); |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 222 | CHECK_MESSAGE(predResult.m_Result, predResult.m_Message.str()); |
Nikhil Raj | d134093 | 2018-10-18 14:27:50 +0100 | [diff] [blame] | 223 | } |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 224 | } |
| 225 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 226 | TEST_CASE_FIXTURE(ClContextControlFixture, "CreateBatchNormalizationFloatNchwWorkload") |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 227 | { |
Nikhil Raj | d134093 | 2018-10-18 14:27:50 +0100 | [diff] [blame] | 228 | ClCreateBatchNormalizationWorkloadTest<ClBatchNormalizationFloatWorkload, |
| 229 | armnn::DataType::Float32>(DataLayout::NCHW); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 230 | } |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 231 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 232 | TEST_CASE_FIXTURE(ClContextControlFixture, "CreateBatchNormalizationFloat16NchwWorkload") |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 233 | { |
Nikhil Raj | d134093 | 2018-10-18 14:27:50 +0100 | [diff] [blame] | 234 | ClCreateBatchNormalizationWorkloadTest<ClBatchNormalizationFloatWorkload, |
| 235 | armnn::DataType::Float16>(DataLayout::NCHW); |
| 236 | } |
| 237 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 238 | TEST_CASE_FIXTURE(ClContextControlFixture, "CreateBatchNormalizationFloatNhwcWorkload") |
Nikhil Raj | d134093 | 2018-10-18 14:27:50 +0100 | [diff] [blame] | 239 | { |
| 240 | ClCreateBatchNormalizationWorkloadTest<ClBatchNormalizationFloatWorkload, |
| 241 | armnn::DataType::Float32>(DataLayout::NHWC); |
| 242 | } |
| 243 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 244 | TEST_CASE_FIXTURE(ClContextControlFixture, "CreateBatchNormalizationNhwcFloat16NhwcWorkload") |
Nikhil Raj | d134093 | 2018-10-18 14:27:50 +0100 | [diff] [blame] | 245 | { |
| 246 | ClCreateBatchNormalizationWorkloadTest<ClBatchNormalizationFloatWorkload, |
| 247 | armnn::DataType::Float16>(DataLayout::NHWC); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 248 | } |
| 249 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 250 | TEST_CASE_FIXTURE(ClContextControlFixture, "CreateConvertFp16ToFp32Workload") |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 251 | { |
| 252 | Graph graph; |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 253 | ClWorkloadFactory factory = |
| 254 | ClWorkloadFactoryHelper::GetFactory(ClWorkloadFactoryHelper::GetMemoryManager()); |
| 255 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 256 | auto workload = CreateConvertFp16ToFp32WorkloadTest<ClConvertFp16ToFp32Workload>(factory, graph); |
| 257 | |
| 258 | ConvertFp16ToFp32QueueDescriptor queueDescriptor = workload->GetData(); |
Jan Eilers | bb446e5 | 2020-04-02 13:56:54 +0100 | [diff] [blame] | 259 | auto inputHandle = PolymorphicDowncast<IClTensorHandle*>(queueDescriptor.m_Inputs[0]); |
| 260 | auto outputHandle = PolymorphicDowncast<IClTensorHandle*>(queueDescriptor.m_Outputs[0]); |
Colm Donelan | 25ab3a8 | 2021-05-17 13:01:52 +0100 | [diff] [blame] | 261 | auto predResult = CompareIClTensorHandleShape(inputHandle, {1, 3, 2, 3}); |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 262 | CHECK_MESSAGE(predResult.m_Result, predResult.m_Message.str()); |
Colm Donelan | 25ab3a8 | 2021-05-17 13:01:52 +0100 | [diff] [blame] | 263 | predResult = CompareIClTensorHandleShape(outputHandle, {1, 3, 2, 3}); |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 264 | CHECK_MESSAGE(predResult.m_Result, predResult.m_Message.str()); |
| 265 | CHECK((inputHandle->GetTensor().info()->data_type() == arm_compute::DataType::F16)); |
| 266 | CHECK((outputHandle->GetTensor().info()->data_type() == arm_compute::DataType::F32)); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 267 | } |
| 268 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 269 | TEST_CASE_FIXTURE(ClContextControlFixture, "CreateConvertFp32ToFp16Workload") |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 270 | { |
| 271 | Graph graph; |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 272 | ClWorkloadFactory factory = |
| 273 | ClWorkloadFactoryHelper::GetFactory(ClWorkloadFactoryHelper::GetMemoryManager()); |
| 274 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 275 | auto workload = CreateConvertFp32ToFp16WorkloadTest<ClConvertFp32ToFp16Workload>(factory, graph); |
| 276 | |
| 277 | ConvertFp32ToFp16QueueDescriptor queueDescriptor = workload->GetData(); |
Jan Eilers | bb446e5 | 2020-04-02 13:56:54 +0100 | [diff] [blame] | 278 | auto inputHandle = PolymorphicDowncast<IClTensorHandle*>(queueDescriptor.m_Inputs[0]); |
| 279 | auto outputHandle = PolymorphicDowncast<IClTensorHandle*>(queueDescriptor.m_Outputs[0]); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 280 | |
Colm Donelan | 25ab3a8 | 2021-05-17 13:01:52 +0100 | [diff] [blame] | 281 | auto predResult = CompareIClTensorHandleShape(inputHandle, {1, 3, 2, 3}); |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 282 | CHECK_MESSAGE(predResult.m_Result, predResult.m_Message.str()); |
Colm Donelan | 25ab3a8 | 2021-05-17 13:01:52 +0100 | [diff] [blame] | 283 | predResult = CompareIClTensorHandleShape(outputHandle, {1, 3, 2, 3}); |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 284 | CHECK_MESSAGE(predResult.m_Result, predResult.m_Message.str()); |
| 285 | CHECK((inputHandle->GetTensor().info()->data_type() == arm_compute::DataType::F32)); |
| 286 | CHECK((outputHandle->GetTensor().info()->data_type() == arm_compute::DataType::F16)); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 287 | } |
| 288 | |
Francis Murtagh | 0d9d419 | 2018-10-09 16:22:33 +0100 | [diff] [blame] | 289 | template <typename Convolution2dWorkloadType, typename armnn::DataType DataType> |
| 290 | static void ClConvolution2dWorkloadTest(DataLayout dataLayout) |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 291 | { |
| 292 | Graph graph; |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 293 | ClWorkloadFactory factory = |
| 294 | ClWorkloadFactoryHelper::GetFactory(ClWorkloadFactoryHelper::GetMemoryManager()); |
| 295 | |
Francis Murtagh | 0d9d419 | 2018-10-09 16:22:33 +0100 | [diff] [blame] | 296 | auto workload = CreateConvolution2dWorkloadTest<ClConvolution2dWorkload, DataType>(factory, |
| 297 | graph, |
| 298 | dataLayout); |
| 299 | |
Mike Kelly | db48288 | 2019-06-14 12:35:24 +0100 | [diff] [blame] | 300 | TensorShape inputShape = (dataLayout == DataLayout::NCHW) ? std::initializer_list<unsigned int>({2, 3, 8, 16}) |
| 301 | : std::initializer_list<unsigned int>({2, 8, 16, 3}); |
| 302 | TensorShape outputShape = (dataLayout == DataLayout::NCHW) ? std::initializer_list<unsigned int>({2, 2, 2, 10}) |
| 303 | : std::initializer_list<unsigned int>({2, 2, 10, 2}); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 304 | |
| 305 | // 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] | 306 | Convolution2dQueueDescriptor queueDescriptor = workload->GetData(); |
Jan Eilers | bb446e5 | 2020-04-02 13:56:54 +0100 | [diff] [blame] | 307 | auto inputHandle = PolymorphicDowncast<IClTensorHandle*>(queueDescriptor.m_Inputs[0]); |
| 308 | auto outputHandle = PolymorphicDowncast<IClTensorHandle*>(queueDescriptor.m_Outputs[0]); |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 309 | CHECK((inputHandle->GetShape() == inputShape)); |
| 310 | CHECK((outputHandle->GetShape() == outputShape)); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 311 | } |
| 312 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 313 | TEST_CASE_FIXTURE(ClContextControlFixture, "CreateConvolution2dFloatNchwWorkload") |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 314 | { |
Francis Murtagh | 0d9d419 | 2018-10-09 16:22:33 +0100 | [diff] [blame] | 315 | ClConvolution2dWorkloadTest<ClConvolution2dWorkload, armnn::DataType::Float32>(DataLayout::NCHW); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 316 | } |
| 317 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 318 | TEST_CASE_FIXTURE(ClContextControlFixture, "CreateConvolution2dFloatNhwcWorkload") |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 319 | { |
Francis Murtagh | 0d9d419 | 2018-10-09 16:22:33 +0100 | [diff] [blame] | 320 | ClConvolution2dWorkloadTest<ClConvolution2dWorkload, armnn::DataType::Float32>(DataLayout::NHWC); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 321 | } |
| 322 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 323 | TEST_CASE_FIXTURE(ClContextControlFixture, "CreateConvolution2dFloat16NchwWorkload") |
Francis Murtagh | 0d9d419 | 2018-10-09 16:22:33 +0100 | [diff] [blame] | 324 | { |
| 325 | ClConvolution2dWorkloadTest<ClConvolution2dWorkload, armnn::DataType::Float16>(DataLayout::NCHW); |
| 326 | } |
| 327 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 328 | TEST_CASE_FIXTURE(ClContextControlFixture, "CreateConvolution2dFloat16NhwcWorkload") |
Francis Murtagh | 0d9d419 | 2018-10-09 16:22:33 +0100 | [diff] [blame] | 329 | { |
| 330 | ClConvolution2dWorkloadTest<ClConvolution2dWorkload, armnn::DataType::Float16>(DataLayout::NHWC); |
| 331 | } |
| 332 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 333 | TEST_CASE_FIXTURE(ClContextControlFixture, "CreateConvolution2dFastMathEnabledWorkload") |
Sadik Armagan | 04a7297 | 2020-09-14 15:44:18 +0100 | [diff] [blame] | 334 | { |
| 335 | Graph graph; |
| 336 | |
| 337 | using ModelOptions = std::vector<BackendOptions>; |
| 338 | ModelOptions modelOptions = {}; |
| 339 | BackendOptions gpuAcc("GpuAcc", |
| 340 | { |
| 341 | { "FastMathEnabled", true } |
| 342 | }); |
| 343 | modelOptions.push_back(gpuAcc); |
| 344 | |
| 345 | ClWorkloadFactory factory = |
| 346 | ClWorkloadFactoryHelper::GetFactory(ClWorkloadFactoryHelper::GetMemoryManager(), modelOptions); |
| 347 | |
| 348 | auto workload = |
Sadik Armagan | 283a8b4 | 2020-09-22 14:35:19 +0100 | [diff] [blame] | 349 | CreateConvolution2dWorkloadFastMathTest<ClConvolution2dWorkload, armnn::DataType::Float32>(factory, |
Sadik Armagan | 04a7297 | 2020-09-14 15:44:18 +0100 | [diff] [blame] | 350 | graph, |
| 351 | DataLayout::NCHW, |
| 352 | modelOptions); |
| 353 | |
| 354 | ARMNN_ASSERT(workload != nullptr); |
| 355 | auto conv2dWorkload = PolymorphicDowncast<ClConvolution2dWorkload*>(workload.get()); |
| 356 | IgnoreUnused(conv2dWorkload); |
| 357 | ARMNN_ASSERT(conv2dWorkload != nullptr); |
Sadik Armagan | 283a8b4 | 2020-09-22 14:35:19 +0100 | [diff] [blame] | 358 | ARMNN_ASSERT(conv2dWorkload->GetConvolutionMethod() == arm_compute::ConvolutionMethod::WINOGRAD); |
Sadik Armagan | 04a7297 | 2020-09-14 15:44:18 +0100 | [diff] [blame] | 359 | } |
| 360 | |
Narumol Prangnawarat | e2af6f4 | 2022-01-28 17:59:18 +0000 | [diff] [blame] | 361 | TEST_CASE_FIXTURE(ClContextControlFixture, "ClReplaceInputOutputConvolution2dWorkload") |
| 362 | { |
| 363 | // Create Convolution2dWorkload with ClTensorHandle input and output |
| 364 | // Then replace the input and output with ClImportTensorHandle |
| 365 | Graph graph; |
| 366 | ClWorkloadFactory factory = |
| 367 | ClWorkloadFactoryHelper::GetFactory(ClWorkloadFactoryHelper::GetMemoryManager()); |
| 368 | |
| 369 | auto workload = |
| 370 | CreateConvolution2dWorkloadTest<ClConvolution2dWorkload, DataType::Float32>(factory, |
| 371 | graph, |
| 372 | DataLayout::NHWC); |
| 373 | |
| 374 | TensorShape inputShape = std::initializer_list<unsigned int>({2, 8, 16, 3}); |
| 375 | TensorShape outputShape = std::initializer_list<unsigned int>({2, 2, 10, 2}); |
| 376 | |
| 377 | // Checks that outputs and inputs are as we expect them (see definition of CreateConvolution2dWorkloadTest). |
| 378 | Convolution2dQueueDescriptor queueDescriptor = workload->GetData(); |
| 379 | auto inputHandle = PolymorphicDowncast<ITensorHandle*>(queueDescriptor.m_Inputs[0]); |
| 380 | auto outputHandle = PolymorphicDowncast<ITensorHandle*>(queueDescriptor.m_Outputs[0]); |
| 381 | CHECK((inputHandle->GetShape() == inputShape)); |
| 382 | CHECK((outputHandle->GetShape() == outputShape)); |
| 383 | // The input and output handles are created correctly as ClTensorHandle |
| 384 | CHECK((dynamic_cast<ClTensorHandle*>(inputHandle) != nullptr)); |
| 385 | CHECK((dynamic_cast<ClTensorHandle*>(outputHandle) != nullptr)); |
| 386 | |
| 387 | // Replace with ImportTensorHandle |
| 388 | ClImportTensorHandleFactory importFactory(static_cast<MemorySourceFlags>(MemorySource::Malloc), |
| 389 | static_cast<MemorySourceFlags>(MemorySource::Malloc)); |
| 390 | |
| 391 | TensorInfo inputInfo({ 2, 8, 16, 3 }, DataType::Float32); |
| 392 | TensorInfo outputInfo({ 2, 2, 10, 2 }, DataType::Float32); |
| 393 | |
| 394 | // create TensorHandle for memory import |
| 395 | auto inputImportHandle = importFactory.CreateTensorHandle(inputInfo); |
| 396 | auto outputImportHandle = importFactory.CreateTensorHandle(outputInfo); |
| 397 | |
| 398 | // Calling ReplaceInputTensorHandle and ReplaceOutputTensorHandle does not throw exception |
| 399 | // as Reconfigure function is implemented |
| 400 | workload->ReplaceInputTensorHandle(inputImportHandle.get(), 0); |
| 401 | workload->ReplaceOutputTensorHandle(outputImportHandle.get(), 0); |
| 402 | |
| 403 | // Correctly replaced with the import handles with correct information |
| 404 | queueDescriptor = workload->GetData(); |
| 405 | auto replacedInputHandle = PolymorphicDowncast<ITensorHandle*>(queueDescriptor.m_Inputs[0]); |
| 406 | auto replacedOutputHandle = PolymorphicDowncast<ITensorHandle*>(queueDescriptor.m_Outputs[0]); |
| 407 | CHECK((replacedInputHandle->GetShape() == inputShape)); |
| 408 | CHECK((replacedOutputHandle->GetShape() == outputShape)); |
| 409 | |
| 410 | CHECK((inputImportHandle.get() == replacedInputHandle)); |
| 411 | CHECK((inputImportHandle.get() == replacedInputHandle)); |
| 412 | |
| 413 | CHECK((dynamic_cast<ClTensorHandle*>(replacedInputHandle) == nullptr)); |
| 414 | CHECK((dynamic_cast<ClImportTensorHandle*>(replacedInputHandle) != nullptr)); |
| 415 | CHECK((dynamic_cast<ClTensorHandle*>(replacedOutputHandle) == nullptr)); |
| 416 | CHECK((dynamic_cast<ClImportTensorHandle*>(replacedOutputHandle) != nullptr)); |
| 417 | } |
| 418 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 419 | TEST_CASE_FIXTURE(ClContextControlFixture, "CreateConvolution2dClCompiledContextWorkload") |
Sadik Armagan | e944475 | 2020-12-02 11:28:58 +0000 | [diff] [blame] | 420 | { |
| 421 | using namespace armnn; |
| 422 | |
| 423 | const DataType inputType = DataType::QAsymmU8; |
| 424 | const DataType kernelType = DataType::QSymmS8; |
| 425 | const DataType biasType = DataType::Signed32; |
| 426 | |
| 427 | TensorInfo inputInfo ({ 1, 3, 1, 2 }, inputType, 0.5f, 128); |
| 428 | TensorInfo outputInfo({ 1, 3, 1, 3 }, inputType, 1.0f, 128); |
| 429 | |
| 430 | const std::vector<float> quantScales{ 0.5f, 0.75f, 1.0f }; |
| 431 | constexpr unsigned int quantDimension = 0; |
| 432 | |
| 433 | TensorInfo kernelInfo({ 3, 1, 1, 2 }, kernelType, quantScales, quantDimension); |
| 434 | |
| 435 | const std::vector<float> biasQuantScales{ 0.25f, 0.375f, 0.5f }; |
| 436 | TensorInfo biasInfo({ 3 }, biasType, biasQuantScales, quantDimension); |
| 437 | |
| 438 | std::vector<uint8_t> inputData = |
| 439 | { |
| 440 | 138, 108, 138, 108, 138, 108 |
| 441 | }; |
| 442 | |
| 443 | std::vector<int8_t> kernelData = |
| 444 | { |
| 445 | 1, 2, 1, 2, 1, 2 |
| 446 | }; |
| 447 | |
| 448 | std::vector<int32_t> biasData = |
| 449 | { |
| 450 | 4, 4, 4 |
| 451 | }; |
| 452 | |
| 453 | std::vector<uint8_t> expectedOutputData = |
| 454 | { |
| 455 | 121, 118, 115, 121, 118, 115, 121, 118, 115 |
| 456 | }; |
| 457 | |
| 458 | |
| 459 | Convolution2dDescriptor descriptor; |
| 460 | descriptor.m_StrideX = 1; |
| 461 | descriptor.m_StrideY = 1; |
| 462 | descriptor.m_PadLeft = 0; |
| 463 | descriptor.m_PadRight = 0; |
| 464 | descriptor.m_PadTop = 0; |
| 465 | descriptor.m_PadBottom = 0; |
| 466 | descriptor.m_BiasEnabled = true; |
| 467 | descriptor.m_DataLayout = DataLayout::NHWC; |
| 468 | |
| 469 | auto memoryManager = ClWorkloadFactoryHelper::GetMemoryManager(); |
| 470 | auto clMemoryManager = armnn::PolymorphicPointerDowncast<armnn::ClMemoryManager>(memoryManager); |
| 471 | auto tensorHandleFactory = ClWorkloadFactoryHelper::GetTensorHandleFactory(memoryManager); |
| 472 | |
| 473 | std::unique_ptr<ITensorHandle> inputHandle = tensorHandleFactory.CreateTensorHandle(inputInfo); |
Keith Davis | 2cddc72 | 2022-04-07 11:32:00 +0100 | [diff] [blame] | 474 | std::unique_ptr<armnn::ITensorHandle> weightsHandle = tensorHandleFactory.CreateTensorHandle(kernelInfo); |
| 475 | std::unique_ptr<armnn::ITensorHandle> biasHandle = tensorHandleFactory.CreateTensorHandle(biasInfo); |
Sadik Armagan | e944475 | 2020-12-02 11:28:58 +0000 | [diff] [blame] | 476 | std::unique_ptr<ITensorHandle> outputHandle = tensorHandleFactory.CreateTensorHandle(outputInfo); |
| 477 | |
| 478 | |
| 479 | WorkloadInfo workloadInfo; |
James Conroy | 1f58f03 | 2021-04-27 17:13:27 +0100 | [diff] [blame] | 480 | ScopedTensorHandle weightTensor(kernelInfo); |
| 481 | ScopedTensorHandle biasTensor(biasInfo); |
Sadik Armagan | e944475 | 2020-12-02 11:28:58 +0000 | [diff] [blame] | 482 | |
| 483 | AllocateAndCopyDataToITensorHandle(&weightTensor, kernelData.data()); |
| 484 | AllocateAndCopyDataToITensorHandle(&biasTensor, biasData.data()); |
| 485 | |
| 486 | Convolution2dQueueDescriptor queueDescriptor; |
| 487 | queueDescriptor.m_Parameters = descriptor; |
| 488 | queueDescriptor.m_Weight = &weightTensor; |
| 489 | queueDescriptor.m_Bias = &biasTensor; |
| 490 | |
| 491 | AddInputToWorkload(queueDescriptor, workloadInfo, inputInfo, inputHandle.get()); |
Keith Davis | 2cddc72 | 2022-04-07 11:32:00 +0100 | [diff] [blame] | 492 | AddInputToWorkload(queueDescriptor, workloadInfo, kernelInfo, weightsHandle.get()); |
| 493 | AddInputToWorkload(queueDescriptor, workloadInfo, biasInfo, biasHandle.get()); |
Sadik Armagan | e944475 | 2020-12-02 11:28:58 +0000 | [diff] [blame] | 494 | AddOutputToWorkload(queueDescriptor, workloadInfo, outputInfo, outputHandle.get()); |
| 495 | |
| 496 | // Initialize our m_CLCompileContext using default device and context |
| 497 | auto context = arm_compute::CLKernelLibrary::get().context(); |
| 498 | auto device = arm_compute::CLKernelLibrary::get().get_device(); |
| 499 | auto clCompileContext = arm_compute::CLCompileContext(context, device); |
| 500 | |
| 501 | |
| 502 | |
| 503 | // Check built programs are empty in context |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 504 | CHECK(clCompileContext.get_built_programs().empty()); |
Sadik Armagan | e944475 | 2020-12-02 11:28:58 +0000 | [diff] [blame] | 505 | |
| 506 | auto workload = std::make_unique<ClConvolution2dWorkload>(queueDescriptor, |
| 507 | workloadInfo, |
| 508 | clMemoryManager->GetIntraLayerManager(), |
| 509 | clCompileContext); |
| 510 | ARMNN_ASSERT(workload != nullptr); |
| 511 | // Check built programs are not empty in context |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 512 | CHECK(!clCompileContext.get_built_programs().empty()); |
Sadik Armagan | e944475 | 2020-12-02 11:28:58 +0000 | [diff] [blame] | 513 | } |
| 514 | |
Nikhil Raj | cec6b65 | 2018-10-12 13:51:57 +0100 | [diff] [blame] | 515 | template <typename DepthwiseConvolutionWorkloadType, typename armnn::DataType DataType> |
| 516 | static void ClDepthwiseConvolutionWorkloadTest(DataLayout dataLayout) |
| 517 | { |
| 518 | Graph graph; |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 519 | ClWorkloadFactory factory = |
| 520 | ClWorkloadFactoryHelper::GetFactory(ClWorkloadFactoryHelper::GetMemoryManager()); |
Nikhil Raj | cec6b65 | 2018-10-12 13:51:57 +0100 | [diff] [blame] | 521 | |
| 522 | auto workload = CreateDepthwiseConvolution2dWorkloadTest<DepthwiseConvolutionWorkloadType, DataType> |
| 523 | (factory, graph, dataLayout); |
| 524 | |
| 525 | // Checks that inputs/outputs are as we expect them (see definition of CreateDepthwiseConvolution2dWorkloadTest). |
| 526 | DepthwiseConvolution2dQueueDescriptor queueDescriptor = workload->GetData(); |
Jan Eilers | bb446e5 | 2020-04-02 13:56:54 +0100 | [diff] [blame] | 527 | auto inputHandle = PolymorphicDowncast<IClTensorHandle*>(queueDescriptor.m_Inputs[0]); |
| 528 | auto outputHandle = PolymorphicDowncast<IClTensorHandle*>(queueDescriptor.m_Outputs[0]); |
Nikhil Raj | cec6b65 | 2018-10-12 13:51:57 +0100 | [diff] [blame] | 529 | |
Mike Kelly | db48288 | 2019-06-14 12:35:24 +0100 | [diff] [blame] | 530 | TensorShape inputShape = (dataLayout == DataLayout::NCHW) ? std::initializer_list<unsigned int>({ 2, 2, 5, 5 }) |
| 531 | : std::initializer_list<unsigned int>({ 2, 5, 5, 2 }); |
| 532 | TensorShape outputShape = (dataLayout == DataLayout::NCHW) ? std::initializer_list<unsigned int>({ 2, 2, 5, 5 }) |
| 533 | : std::initializer_list<unsigned int>({ 2, 5, 5, 2 }); |
Nikhil Raj | cec6b65 | 2018-10-12 13:51:57 +0100 | [diff] [blame] | 534 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 535 | CHECK((inputHandle->GetShape() == inputShape)); |
| 536 | CHECK((outputHandle->GetShape() == outputShape)); |
Nikhil Raj | cec6b65 | 2018-10-12 13:51:57 +0100 | [diff] [blame] | 537 | } |
| 538 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 539 | TEST_CASE_FIXTURE(ClContextControlFixture, "CreateDepthwiseConvolutionFloat32NhwcWorkload") |
Nikhil Raj | cec6b65 | 2018-10-12 13:51:57 +0100 | [diff] [blame] | 540 | { |
| 541 | ClDepthwiseConvolutionWorkloadTest<ClDepthwiseConvolutionWorkload, DataType::Float32>(DataLayout::NHWC); |
| 542 | } |
| 543 | |
Francis Murtagh | 0d9d419 | 2018-10-09 16:22:33 +0100 | [diff] [blame] | 544 | template <typename Convolution2dWorkloadType, typename armnn::DataType DataType> |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 545 | static void ClDirectConvolution2dWorkloadTest() |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 546 | { |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 547 | Graph graph; |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 548 | ClWorkloadFactory factory = |
| 549 | ClWorkloadFactoryHelper::GetFactory(ClWorkloadFactoryHelper::GetMemoryManager()); |
| 550 | |
Matthew Bentham | d806792 | 2018-10-03 17:18:04 +0100 | [diff] [blame] | 551 | auto workload = CreateDirectConvolution2dWorkloadTest<ClConvolution2dWorkload, DataType>(factory, graph); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 552 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 553 | // 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] | 554 | Convolution2dQueueDescriptor queueDescriptor = workload->GetData(); |
Jan Eilers | bb446e5 | 2020-04-02 13:56:54 +0100 | [diff] [blame] | 555 | auto inputHandle = PolymorphicDowncast<IClTensorHandle*>(queueDescriptor.m_Inputs[0]); |
| 556 | auto outputHandle = PolymorphicDowncast<IClTensorHandle*>(queueDescriptor.m_Outputs[0]); |
Colm Donelan | 25ab3a8 | 2021-05-17 13:01:52 +0100 | [diff] [blame] | 557 | auto predResult = CompareIClTensorHandleShape(inputHandle, {2, 3, 6, 6}); |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 558 | CHECK_MESSAGE(predResult.m_Result, predResult.m_Message.str()); |
Colm Donelan | 25ab3a8 | 2021-05-17 13:01:52 +0100 | [diff] [blame] | 559 | predResult = CompareIClTensorHandleShape(outputHandle, {2, 2, 6, 6}); |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 560 | CHECK_MESSAGE(predResult.m_Result, predResult.m_Message.str()); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 561 | } |
| 562 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 563 | TEST_CASE_FIXTURE(ClContextControlFixture, "CreateDirectConvolution2dFloatWorkload") |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 564 | { |
Francis Murtagh | 0d9d419 | 2018-10-09 16:22:33 +0100 | [diff] [blame] | 565 | ClDirectConvolution2dWorkloadTest<ClConvolution2dWorkload, armnn::DataType::Float32>(); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 566 | } |
| 567 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 568 | TEST_CASE_FIXTURE(ClContextControlFixture, "CreateDirectConvolution2dFloat16Workload") |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 569 | { |
Francis Murtagh | 0d9d419 | 2018-10-09 16:22:33 +0100 | [diff] [blame] | 570 | ClDirectConvolution2dWorkloadTest<ClConvolution2dWorkload, armnn::DataType::Float16>(); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 571 | } |
| 572 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 573 | TEST_CASE_FIXTURE(ClContextControlFixture, "CreateDirectConvolution2dUint8Workload") |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 574 | { |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 575 | ClDirectConvolution2dWorkloadTest<ClConvolution2dWorkload, armnn::DataType::QAsymmU8>(); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 576 | } |
| 577 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 578 | template <typename FullyConnectedWorkloadType, typename armnn::DataType DataType> |
| 579 | static void ClCreateFullyConnectedWorkloadTest() |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 580 | { |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 581 | Graph graph; |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 582 | ClWorkloadFactory factory = |
| 583 | ClWorkloadFactoryHelper::GetFactory(ClWorkloadFactoryHelper::GetMemoryManager()); |
| 584 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 585 | auto workload = |
| 586 | CreateFullyConnectedWorkloadTest<FullyConnectedWorkloadType, DataType>(factory, graph); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 587 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 588 | // 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] | 589 | FullyConnectedQueueDescriptor queueDescriptor = workload->GetData(); |
Jan Eilers | bb446e5 | 2020-04-02 13:56:54 +0100 | [diff] [blame] | 590 | auto inputHandle = PolymorphicDowncast<IClTensorHandle*>(queueDescriptor.m_Inputs[0]); |
| 591 | auto outputHandle = PolymorphicDowncast<IClTensorHandle*>(queueDescriptor.m_Outputs[0]); |
Colm Donelan | 25ab3a8 | 2021-05-17 13:01:52 +0100 | [diff] [blame] | 592 | auto predResult = CompareIClTensorHandleShape(inputHandle, {3, 1, 4, 5}); |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 593 | CHECK_MESSAGE(predResult.m_Result, predResult.m_Message.str()); |
Colm Donelan | 25ab3a8 | 2021-05-17 13:01:52 +0100 | [diff] [blame] | 594 | predResult = CompareIClTensorHandleShape(outputHandle, {3, 7}); |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 595 | CHECK_MESSAGE(predResult.m_Result, predResult.m_Message.str()); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 596 | } |
| 597 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 598 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 599 | TEST_CASE_FIXTURE(ClContextControlFixture, "CreateFullyConnectedFloatWorkloadTest") |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 600 | { |
Matthew Bentham | ab8cdc1 | 2018-09-17 11:17:41 +0100 | [diff] [blame] | 601 | ClCreateFullyConnectedWorkloadTest<ClFullyConnectedWorkload, armnn::DataType::Float32>(); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 602 | } |
| 603 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 604 | TEST_CASE_FIXTURE(ClContextControlFixture, "CreateFullyConnectedFloat16WorkloadTest") |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 605 | { |
Matthew Bentham | ab8cdc1 | 2018-09-17 11:17:41 +0100 | [diff] [blame] | 606 | ClCreateFullyConnectedWorkloadTest<ClFullyConnectedWorkload, armnn::DataType::Float16>(); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 607 | } |
| 608 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 609 | template <typename NormalizationWorkloadType, typename armnn::DataType DataType> |
narpra01 | 55a97bc | 2018-10-02 14:35:53 +0100 | [diff] [blame] | 610 | static void ClNormalizationWorkloadTest(DataLayout dataLayout) |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [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 | |
Matteo Martincigh | a160b24 | 2018-10-18 10:33:23 +0100 | [diff] [blame] | 616 | auto workload = CreateNormalizationWorkloadTest<NormalizationWorkloadType, DataType>(factory, graph, dataLayout); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 617 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 618 | // Checks that inputs/outputs are as we expect them (see definition of CreateNormalizationWorkloadTest). |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 619 | NormalizationQueueDescriptor queueDescriptor = workload->GetData(); |
Jan Eilers | bb446e5 | 2020-04-02 13:56:54 +0100 | [diff] [blame] | 620 | auto inputHandle = PolymorphicDowncast<IClTensorHandle*>(queueDescriptor.m_Inputs[0]); |
| 621 | auto outputHandle = PolymorphicDowncast<IClTensorHandle*>(queueDescriptor.m_Outputs[0]); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 622 | |
Mike Kelly | db48288 | 2019-06-14 12:35:24 +0100 | [diff] [blame] | 623 | TensorShape inputShape = (dataLayout == DataLayout::NCHW) ? std::initializer_list<unsigned int>({3, 5, 5, 1}) |
| 624 | : std::initializer_list<unsigned int>({3, 1, 5, 5}); |
| 625 | TensorShape outputShape = (dataLayout == DataLayout::NCHW) ? std::initializer_list<unsigned int>({3, 5, 5, 1}) |
| 626 | : std::initializer_list<unsigned int>({3, 1, 5, 5}); |
Matteo Martincigh | a160b24 | 2018-10-18 10:33:23 +0100 | [diff] [blame] | 627 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 628 | CHECK((inputHandle->GetShape() == inputShape)); |
| 629 | CHECK((outputHandle->GetShape() == outputShape)); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 630 | } |
| 631 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 632 | TEST_CASE_FIXTURE(ClContextControlFixture, "CreateNormalizationFloat32NchwWorkload") |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 633 | { |
narpra01 | 55a97bc | 2018-10-02 14:35:53 +0100 | [diff] [blame] | 634 | ClNormalizationWorkloadTest<ClNormalizationFloatWorkload, armnn::DataType::Float32>(DataLayout::NCHW); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 635 | } |
| 636 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 637 | TEST_CASE_FIXTURE(ClContextControlFixture, "CreateNormalizationFloat16NchwWorkload") |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 638 | { |
narpra01 | 55a97bc | 2018-10-02 14:35:53 +0100 | [diff] [blame] | 639 | ClNormalizationWorkloadTest<ClNormalizationFloatWorkload, armnn::DataType::Float16>(DataLayout::NCHW); |
| 640 | } |
| 641 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 642 | TEST_CASE_FIXTURE(ClContextControlFixture, "CreateNormalizationFloat32NhwcWorkload") |
narpra01 | 55a97bc | 2018-10-02 14:35:53 +0100 | [diff] [blame] | 643 | { |
| 644 | ClNormalizationWorkloadTest<ClNormalizationFloatWorkload, armnn::DataType::Float32>(DataLayout::NHWC); |
| 645 | } |
| 646 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 647 | TEST_CASE_FIXTURE(ClContextControlFixture, "CreateNormalizationFloat16NhwcWorkload") |
narpra01 | 55a97bc | 2018-10-02 14:35:53 +0100 | [diff] [blame] | 648 | { |
| 649 | ClNormalizationWorkloadTest<ClNormalizationFloatWorkload, armnn::DataType::Float16>(DataLayout::NHWC); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 650 | } |
| 651 | |
Nattapat Chaimanowong | ac9e096 | 2018-10-10 17:18:35 +0100 | [diff] [blame] | 652 | template <typename armnn::DataType DataType> |
Nina Drozd | b48e686 | 2018-10-09 12:09:56 +0100 | [diff] [blame] | 653 | static void ClPooling2dWorkloadTest(DataLayout dataLayout) |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 654 | { |
| 655 | Graph graph; |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 656 | ClWorkloadFactory factory = |
| 657 | ClWorkloadFactoryHelper::GetFactory(ClWorkloadFactoryHelper::GetMemoryManager()); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 658 | |
Nattapat Chaimanowong | ac9e096 | 2018-10-10 17:18:35 +0100 | [diff] [blame] | 659 | auto workload = CreatePooling2dWorkloadTest<ClPooling2dWorkload, DataType>(factory, graph, dataLayout); |
Nina Drozd | b48e686 | 2018-10-09 12:09:56 +0100 | [diff] [blame] | 660 | |
Mike Kelly | db48288 | 2019-06-14 12:35:24 +0100 | [diff] [blame] | 661 | TensorShape inputShape = (dataLayout == DataLayout::NCHW) ? std::initializer_list<unsigned int>({3, 2, 5, 5}) |
| 662 | : std::initializer_list<unsigned int>({3, 5, 5, 2}); |
| 663 | TensorShape outputShape = (dataLayout == DataLayout::NCHW) ? std::initializer_list<unsigned int>({3, 2, 2, 4}) |
| 664 | : std::initializer_list<unsigned int>({3, 2, 4, 2}); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 665 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 666 | // Check that inputs/outputs are as we expect them (see definition of CreatePooling2dWorkloadTest). |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 667 | Pooling2dQueueDescriptor queueDescriptor = workload->GetData(); |
Jan Eilers | bb446e5 | 2020-04-02 13:56:54 +0100 | [diff] [blame] | 668 | auto inputHandle = PolymorphicDowncast<IClTensorHandle*>(queueDescriptor.m_Inputs[0]); |
| 669 | auto outputHandle = PolymorphicDowncast<IClTensorHandle*>(queueDescriptor.m_Outputs[0]); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 670 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 671 | CHECK((inputHandle->GetShape() == inputShape)); |
| 672 | CHECK((outputHandle->GetShape() == outputShape)); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 673 | } |
| 674 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 675 | TEST_CASE_FIXTURE(ClContextControlFixture, "CreatePooling2dFloatNchwWorkload") |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 676 | { |
Nattapat Chaimanowong | ac9e096 | 2018-10-10 17:18:35 +0100 | [diff] [blame] | 677 | ClPooling2dWorkloadTest<armnn::DataType::Float32>(DataLayout::NCHW); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 678 | } |
| 679 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 680 | TEST_CASE_FIXTURE(ClContextControlFixture, "CreatePooling2dFloatNhwcWorkload") |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 681 | { |
Nattapat Chaimanowong | ac9e096 | 2018-10-10 17:18:35 +0100 | [diff] [blame] | 682 | ClPooling2dWorkloadTest<armnn::DataType::Float32>(DataLayout::NHWC); |
Nina Drozd | b48e686 | 2018-10-09 12:09:56 +0100 | [diff] [blame] | 683 | } |
| 684 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 685 | TEST_CASE_FIXTURE(ClContextControlFixture, "CreatePooling2dFloat16NchwWorkload") |
Nina Drozd | b48e686 | 2018-10-09 12:09:56 +0100 | [diff] [blame] | 686 | { |
Nattapat Chaimanowong | ac9e096 | 2018-10-10 17:18:35 +0100 | [diff] [blame] | 687 | ClPooling2dWorkloadTest<armnn::DataType::Float16>(DataLayout::NCHW); |
Nina Drozd | b48e686 | 2018-10-09 12:09:56 +0100 | [diff] [blame] | 688 | } |
| 689 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 690 | TEST_CASE_FIXTURE(ClContextControlFixture, "CreatePooling2dFloat16NhwcWorkload") |
Nina Drozd | b48e686 | 2018-10-09 12:09:56 +0100 | [diff] [blame] | 691 | { |
Nattapat Chaimanowong | ac9e096 | 2018-10-10 17:18:35 +0100 | [diff] [blame] | 692 | ClPooling2dWorkloadTest<armnn::DataType::Float16>(DataLayout::NHWC); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 693 | } |
| 694 | |
Nikhil Raj | 91e4c6d | 2019-07-05 12:22:58 +0100 | [diff] [blame] | 695 | static void ClCreatePreluWorkloadTest(const armnn::TensorShape& inputShape, |
| 696 | const armnn::TensorShape& alphaShape, |
| 697 | const armnn::TensorShape& outputShape, |
| 698 | armnn::DataType dataType) |
| 699 | { |
| 700 | Graph graph; |
| 701 | ClWorkloadFactory factory = |
| 702 | ClWorkloadFactoryHelper::GetFactory(ClWorkloadFactoryHelper::GetMemoryManager()); |
| 703 | |
| 704 | auto workload = CreatePreluWorkloadTest<ClPreluWorkload>(factory, |
| 705 | graph, |
| 706 | inputShape, |
| 707 | alphaShape, |
| 708 | outputShape, |
| 709 | dataType); |
| 710 | |
| 711 | // Checks that outputs and inputs are as we expect them (see definition of CreatePreluWorkloadTest). |
| 712 | PreluQueueDescriptor queueDescriptor = workload->GetData(); |
Jan Eilers | bb446e5 | 2020-04-02 13:56:54 +0100 | [diff] [blame] | 713 | auto inputHandle = PolymorphicDowncast<IClTensorHandle*>(queueDescriptor.m_Inputs[0]); |
| 714 | auto alphaHandle = PolymorphicDowncast<IClTensorHandle*>(queueDescriptor.m_Inputs[1]); |
| 715 | auto outputHandle = PolymorphicDowncast<IClTensorHandle*>(queueDescriptor.m_Outputs[0]); |
Nikhil Raj | 91e4c6d | 2019-07-05 12:22:58 +0100 | [diff] [blame] | 716 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 717 | CHECK((inputHandle->GetShape() == inputShape)); |
| 718 | CHECK((alphaHandle->GetShape() == alphaShape)); |
| 719 | CHECK((outputHandle->GetShape() == outputShape)); |
Nikhil Raj | 91e4c6d | 2019-07-05 12:22:58 +0100 | [diff] [blame] | 720 | } |
| 721 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 722 | TEST_CASE_FIXTURE(ClContextControlFixture, "CreatePreluFloat16Workload") |
Nikhil Raj | 91e4c6d | 2019-07-05 12:22:58 +0100 | [diff] [blame] | 723 | { |
| 724 | ClCreatePreluWorkloadTest({ 1, 4, 1, 2 }, { 5, 4, 3, 1 }, { 5, 4, 3, 2 }, DataType::Float16); |
| 725 | } |
| 726 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 727 | TEST_CASE_FIXTURE(ClContextControlFixture, "CreatePreluFloatWorkload") |
Nikhil Raj | 91e4c6d | 2019-07-05 12:22:58 +0100 | [diff] [blame] | 728 | { |
| 729 | ClCreatePreluWorkloadTest({ 1, 4, 1, 2 }, { 5, 4, 3, 1 }, { 5, 4, 3, 2 }, DataType::Float32); |
| 730 | } |
| 731 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 732 | TEST_CASE_FIXTURE(ClContextControlFixture, "CreatePreluUint8Workload") |
Nikhil Raj | 91e4c6d | 2019-07-05 12:22:58 +0100 | [diff] [blame] | 733 | { |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 734 | 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] | 735 | } |
| 736 | |
Nattapat Chaimanowong | a76698c | 2018-10-11 10:29:15 +0100 | [diff] [blame] | 737 | template <typename armnn::DataType DataType> |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 738 | static void ClCreateReshapeWorkloadTest() |
| 739 | { |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 740 | Graph graph; |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 741 | ClWorkloadFactory factory = |
| 742 | ClWorkloadFactoryHelper::GetFactory(ClWorkloadFactoryHelper::GetMemoryManager()); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 743 | |
Nattapat Chaimanowong | a76698c | 2018-10-11 10:29:15 +0100 | [diff] [blame] | 744 | auto workload = CreateReshapeWorkloadTest<ClReshapeWorkload, DataType>(factory, graph); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 745 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 746 | // 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] | 747 | ReshapeQueueDescriptor queueDescriptor = workload->GetData(); |
Jan Eilers | bb446e5 | 2020-04-02 13:56:54 +0100 | [diff] [blame] | 748 | auto inputHandle = PolymorphicDowncast<IClTensorHandle*>(queueDescriptor.m_Inputs[0]); |
| 749 | auto outputHandle = PolymorphicDowncast<IClTensorHandle*>(queueDescriptor.m_Outputs[0]); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 750 | |
Colm Donelan | 25ab3a8 | 2021-05-17 13:01:52 +0100 | [diff] [blame] | 751 | auto predResult = CompareIClTensorHandleShape(inputHandle, {4, 1}); |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 752 | CHECK_MESSAGE(predResult.m_Result, predResult.m_Message.str()); |
Colm Donelan | 25ab3a8 | 2021-05-17 13:01:52 +0100 | [diff] [blame] | 753 | predResult = CompareIClTensorHandleShape(outputHandle, {1, 4}); |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 754 | CHECK_MESSAGE(predResult.m_Result, predResult.m_Message.str()); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 755 | } |
| 756 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 757 | TEST_CASE_FIXTURE(ClContextControlFixture, "CreateReshapeFloatWorkload") |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 758 | { |
Nattapat Chaimanowong | a76698c | 2018-10-11 10:29:15 +0100 | [diff] [blame] | 759 | ClCreateReshapeWorkloadTest<armnn::DataType::Float32>(); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 760 | } |
| 761 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 762 | TEST_CASE_FIXTURE(ClContextControlFixture, "CreateReshapeFloat16Workload") |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 763 | { |
Nattapat Chaimanowong | a76698c | 2018-10-11 10:29:15 +0100 | [diff] [blame] | 764 | ClCreateReshapeWorkloadTest<armnn::DataType::Float16>(); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 765 | } |
| 766 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 767 | TEST_CASE_FIXTURE(ClContextControlFixture, "CreateReshapeUint8Workload") |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 768 | { |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 769 | ClCreateReshapeWorkloadTest<armnn::DataType::QAsymmU8>(); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 770 | } |
| 771 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 772 | template <typename SoftmaxWorkloadType, typename armnn::DataType DataType> |
| 773 | static void ClSoftmaxWorkloadTest() |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 774 | { |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 775 | Graph graph; |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 776 | ClWorkloadFactory factory = |
| 777 | ClWorkloadFactoryHelper::GetFactory(ClWorkloadFactoryHelper::GetMemoryManager()); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 778 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 779 | auto workload = CreateSoftmaxWorkloadTest<SoftmaxWorkloadType, DataType>(factory, graph); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 780 | |
arovir01 | 9e53a35 | 2018-08-31 15:26:35 +0100 | [diff] [blame] | 781 | // Checks that inputs/outputs are as we expect them (see definition of ClSoftmaxFloatWorkload). |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 782 | SoftmaxQueueDescriptor queueDescriptor = workload->GetData(); |
Jan Eilers | bb446e5 | 2020-04-02 13:56:54 +0100 | [diff] [blame] | 783 | auto inputHandle = PolymorphicDowncast<IClTensorHandle*>(queueDescriptor.m_Inputs[0]); |
| 784 | auto outputHandle = PolymorphicDowncast<IClTensorHandle*>(queueDescriptor.m_Outputs[0]); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 785 | |
Teresa Charlin | c1f6b09 | 2020-05-11 16:10:38 +0100 | [diff] [blame] | 786 | armnn::TensorInfo tensorInfo({4, 1}, DataType); |
| 787 | if (DataType == armnn::DataType::QAsymmU8) |
| 788 | { |
| 789 | tensorInfo.SetQuantizationOffset(0); |
| 790 | tensorInfo.SetQuantizationScale(1.f / 256); |
| 791 | } |
| 792 | else if (DataType == armnn::DataType::QAsymmS8) |
| 793 | { |
| 794 | tensorInfo.SetQuantizationOffset(-128); |
| 795 | tensorInfo.SetQuantizationScale(1.f / 256); |
| 796 | } |
| 797 | |
Colm Donelan | 25ab3a8 | 2021-05-17 13:01:52 +0100 | [diff] [blame] | 798 | auto predResult = CompareIClTensorHandleShape(inputHandle, {4, 1}); |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 799 | CHECK_MESSAGE(predResult.m_Result, predResult.m_Message.str()); |
Colm Donelan | 25ab3a8 | 2021-05-17 13:01:52 +0100 | [diff] [blame] | 800 | predResult = CompareIClTensorHandleShape(outputHandle, {4, 1}); |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 801 | CHECK_MESSAGE(predResult.m_Result, predResult.m_Message.str()); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 802 | } |
| 803 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 804 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 805 | TEST_CASE_FIXTURE(ClContextControlFixture, "CreateSoftmaxFloat32WorkloadTest") |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 806 | { |
Teresa Charlin | c1f6b09 | 2020-05-11 16:10:38 +0100 | [diff] [blame] | 807 | ClSoftmaxWorkloadTest<ClSoftmaxWorkload, armnn::DataType::Float32>(); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 808 | } |
| 809 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 810 | TEST_CASE_FIXTURE(ClContextControlFixture, "CreateSoftmaxFloat16WorkloadTest") |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 811 | { |
Teresa Charlin | c1f6b09 | 2020-05-11 16:10:38 +0100 | [diff] [blame] | 812 | ClSoftmaxWorkloadTest<ClSoftmaxWorkload, armnn::DataType::Float16>(); |
| 813 | } |
| 814 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 815 | TEST_CASE_FIXTURE(ClContextControlFixture, "CreateSoftmaxQAsymmU8Workload") |
Teresa Charlin | c1f6b09 | 2020-05-11 16:10:38 +0100 | [diff] [blame] | 816 | { |
| 817 | ClSoftmaxWorkloadTest<ClSoftmaxWorkload, armnn::DataType::QAsymmU8>(); |
| 818 | } |
| 819 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 820 | TEST_CASE_FIXTURE(ClContextControlFixture, "CreateSoftmaxQAsymmS8Workload") |
Teresa Charlin | c1f6b09 | 2020-05-11 16:10:38 +0100 | [diff] [blame] | 821 | { |
| 822 | ClSoftmaxWorkloadTest<ClSoftmaxWorkload, armnn::DataType::QAsymmS8>(); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 823 | } |
| 824 | |
Matthew Bentham | 29cadb3 | 2018-10-01 17:22:32 +0100 | [diff] [blame] | 825 | template <typename armnn::DataType DataType> |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 826 | static void ClSplitterWorkloadTest() |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 827 | { |
| 828 | Graph graph; |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 829 | ClWorkloadFactory factory = |
| 830 | ClWorkloadFactoryHelper::GetFactory(ClWorkloadFactoryHelper::GetMemoryManager()); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 831 | |
Matthew Bentham | 29cadb3 | 2018-10-01 17:22:32 +0100 | [diff] [blame] | 832 | auto workload = CreateSplitterWorkloadTest<ClSplitterWorkload, DataType>(factory, graph); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 833 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 834 | // Checks that outputs are as we expect them (see definition of CreateSplitterWorkloadTest). |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 835 | SplitterQueueDescriptor queueDescriptor = workload->GetData(); |
Jan Eilers | bb446e5 | 2020-04-02 13:56:54 +0100 | [diff] [blame] | 836 | auto inputHandle = PolymorphicDowncast<IClTensorHandle*>(queueDescriptor.m_Inputs[0]); |
Colm Donelan | 25ab3a8 | 2021-05-17 13:01:52 +0100 | [diff] [blame] | 837 | auto predResult = CompareIClTensorHandleShape(inputHandle, {5, 7, 7}); |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 838 | CHECK_MESSAGE(predResult.m_Result, predResult.m_Message.str()); |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 839 | |
Jan Eilers | bb446e5 | 2020-04-02 13:56:54 +0100 | [diff] [blame] | 840 | auto outputHandle1 = PolymorphicDowncast<IClTensorHandle*>(queueDescriptor.m_Outputs[1]); |
Colm Donelan | 25ab3a8 | 2021-05-17 13:01:52 +0100 | [diff] [blame] | 841 | predResult = CompareIClTensorHandleShape(outputHandle1, {2, 7, 7}); |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 842 | CHECK_MESSAGE(predResult.m_Result, predResult.m_Message.str()); |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 843 | |
Jan Eilers | bb446e5 | 2020-04-02 13:56:54 +0100 | [diff] [blame] | 844 | auto outputHandle2 = PolymorphicDowncast<IClTensorHandle*>(queueDescriptor.m_Outputs[2]); |
Colm Donelan | 25ab3a8 | 2021-05-17 13:01:52 +0100 | [diff] [blame] | 845 | predResult = CompareIClTensorHandleShape(outputHandle2, {2, 7, 7}); |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 846 | CHECK_MESSAGE(predResult.m_Result, predResult.m_Message.str()); |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 847 | |
Jan Eilers | bb446e5 | 2020-04-02 13:56:54 +0100 | [diff] [blame] | 848 | auto outputHandle0 = PolymorphicDowncast<IClTensorHandle*>(queueDescriptor.m_Outputs[0]); |
Colm Donelan | 25ab3a8 | 2021-05-17 13:01:52 +0100 | [diff] [blame] | 849 | predResult = CompareIClTensorHandleShape(outputHandle0, {1, 7, 7}); |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 850 | CHECK_MESSAGE(predResult.m_Result, predResult.m_Message.str()); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 851 | } |
| 852 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 853 | TEST_CASE_FIXTURE(ClContextControlFixture, "CreateSplitterFloatWorkload") |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 854 | { |
Matthew Bentham | 29cadb3 | 2018-10-01 17:22:32 +0100 | [diff] [blame] | 855 | ClSplitterWorkloadTest<armnn::DataType::Float32>(); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 856 | } |
| 857 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 858 | TEST_CASE_FIXTURE(ClContextControlFixture, "CreateSplitterFloat16Workload") |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 859 | { |
Matthew Bentham | 29cadb3 | 2018-10-01 17:22:32 +0100 | [diff] [blame] | 860 | ClSplitterWorkloadTest<armnn::DataType::Float16>(); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 861 | } |
| 862 | |
Nattapat Chaimanowong | 02f8bc1 | 2018-10-11 16:16:17 +0100 | [diff] [blame] | 863 | template <typename armnn::DataType DataType> |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 864 | static void ClSplitterConcatTest() |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 865 | { |
| 866 | // 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] | 867 | // should be lined to which input of the concat layer. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 868 | // We test that is is possible to specify 0th output |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 869 | // of the splitter to be the 1st input to the concat and the 1st output of the splitter to be 0th input |
| 870 | // of the concat. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 871 | |
| 872 | Graph graph; |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 873 | ClWorkloadFactory factory = |
| 874 | ClWorkloadFactoryHelper::GetFactory(ClWorkloadFactoryHelper::GetMemoryManager()); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 875 | |
| 876 | auto workloads = |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 877 | CreateSplitterConcatWorkloadTest<ClSplitterWorkload, ClConcatWorkload, DataType> |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 878 | (factory, graph); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 879 | |
| 880 | auto wlSplitter = std::move(workloads.first); |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 881 | auto wlConcat = std::move(workloads.second); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 882 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 883 | //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] | 884 | armnn::ClSubTensorHandle* sOut0 = dynamic_cast<armnn::ClSubTensorHandle*>(wlSplitter->GetData().m_Outputs[0]); |
| 885 | armnn::ClSubTensorHandle* sOut1 = dynamic_cast<armnn::ClSubTensorHandle*>(wlSplitter->GetData().m_Outputs[1]); |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 886 | armnn::ClSubTensorHandle* mIn0 = dynamic_cast<armnn::ClSubTensorHandle*>(wlConcat->GetData().m_Inputs[0]); |
| 887 | armnn::ClSubTensorHandle* mIn1 = dynamic_cast<armnn::ClSubTensorHandle*>(wlConcat->GetData().m_Inputs[1]); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 888 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 889 | CHECK(sOut0); |
| 890 | CHECK(sOut1); |
| 891 | CHECK(mIn0); |
| 892 | CHECK(mIn1); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 893 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 894 | //Fliped order of inputs/outputs. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 895 | bool validDataPointers = (sOut0 == mIn1) && (sOut1 == mIn0); |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 896 | CHECK(validDataPointers); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 897 | |
| 898 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 899 | //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] | 900 | bool validSubTensorParents = (mIn0->GetTensor().parent() == mIn1->GetTensor().parent()) |
| 901 | && (sOut0->GetTensor().parent() == sOut1->GetTensor().parent()); |
| 902 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 903 | CHECK(validSubTensorParents); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 904 | } |
| 905 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 906 | TEST_CASE_FIXTURE(ClContextControlFixture, "CreateSplitterConcatFloatWorkload") |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 907 | { |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 908 | ClSplitterConcatTest<armnn::DataType::Float32>(); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 909 | } |
| 910 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 911 | TEST_CASE_FIXTURE(ClContextControlFixture, "CreateSplitterConcatFloat16Workload") |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 912 | { |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 913 | ClSplitterConcatTest<armnn::DataType::Float16>(); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 914 | } |
| 915 | |
| 916 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 917 | TEST_CASE_FIXTURE(ClContextControlFixture, "CreateSingleOutputMultipleInputs") |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 918 | { |
| 919 | // 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] | 920 | // 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] | 921 | |
| 922 | Graph graph; |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 923 | ClWorkloadFactory factory = |
| 924 | ClWorkloadFactoryHelper::GetFactory(ClWorkloadFactoryHelper::GetMemoryManager()); |
| 925 | |
Matthew Bentham | 29cadb3 | 2018-10-01 17:22:32 +0100 | [diff] [blame] | 926 | std::unique_ptr<ClSplitterWorkload> wlSplitter; |
Nattapat Chaimanowong | e06757e | 2018-10-11 15:39:18 +0100 | [diff] [blame] | 927 | std::unique_ptr<ClActivationWorkload> wlActiv0_0; |
| 928 | std::unique_ptr<ClActivationWorkload> wlActiv0_1; |
| 929 | std::unique_ptr<ClActivationWorkload> wlActiv1_0; |
| 930 | std::unique_ptr<ClActivationWorkload> wlActiv1_1; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 931 | |
Matthew Bentham | 29cadb3 | 2018-10-01 17:22:32 +0100 | [diff] [blame] | 932 | CreateSplitterMultipleInputsOneOutputWorkloadTest<ClSplitterWorkload, |
Nattapat Chaimanowong | e06757e | 2018-10-11 15:39:18 +0100 | [diff] [blame] | 933 | ClActivationWorkload, armnn::DataType::Float32>(factory, graph, wlSplitter, wlActiv0_0, wlActiv0_1, |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 934 | wlActiv1_0, wlActiv1_1); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 935 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 936 | //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] | 937 | armnn::ClSubTensorHandle* sOut0 = dynamic_cast<armnn::ClSubTensorHandle*>(wlSplitter->GetData().m_Outputs[0]); |
| 938 | armnn::ClSubTensorHandle* sOut1 = dynamic_cast<armnn::ClSubTensorHandle*>(wlSplitter->GetData().m_Outputs[1]); |
| 939 | armnn::ClSubTensorHandle* activ0_0Im = dynamic_cast<armnn::ClSubTensorHandle*>(wlActiv0_0->GetData().m_Inputs[0]); |
| 940 | armnn::ClSubTensorHandle* activ0_1Im = dynamic_cast<armnn::ClSubTensorHandle*>(wlActiv0_1->GetData().m_Inputs[0]); |
| 941 | armnn::ClSubTensorHandle* activ1_0Im = dynamic_cast<armnn::ClSubTensorHandle*>(wlActiv1_0->GetData().m_Inputs[0]); |
| 942 | armnn::ClSubTensorHandle* activ1_1Im = dynamic_cast<armnn::ClSubTensorHandle*>(wlActiv1_1->GetData().m_Inputs[0]); |
| 943 | |
| 944 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 945 | CHECK(sOut0); |
| 946 | CHECK(sOut1); |
| 947 | CHECK(activ0_0Im); |
| 948 | CHECK(activ0_1Im); |
| 949 | CHECK(activ1_0Im); |
| 950 | CHECK(activ1_1Im); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 951 | |
| 952 | bool validDataPointers = (sOut0 == activ0_0Im) && (sOut0 == activ0_1Im) && |
| 953 | (sOut1 == activ1_0Im) && (sOut1 == activ1_1Im); |
| 954 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 955 | CHECK(validDataPointers); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 956 | } |
| 957 | |
Matteo Martincigh | db16dd3 | 2019-08-27 16:41:11 +0100 | [diff] [blame] | 958 | #if defined(ARMNNREF_ENABLED) |
Matteo Martincigh | e67edb2 | 2019-08-14 14:05:46 +0100 | [diff] [blame] | 959 | |
| 960 | // This test unit needs the reference backend, it's not available if the reference backend is not built |
| 961 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 962 | TEST_CASE_FIXTURE(ClContextControlFixture, "CreateMemCopyWorkloadsCl") |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 963 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 964 | ClWorkloadFactory factory = |
| 965 | ClWorkloadFactoryHelper::GetFactory(ClWorkloadFactoryHelper::GetMemoryManager()); |
| 966 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 967 | CreateMemCopyWorkloads<IClTensorHandle>(factory); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 968 | } |
| 969 | |
Matteo Martincigh | e67edb2 | 2019-08-14 14:05:46 +0100 | [diff] [blame] | 970 | #endif |
| 971 | |
Matteo Martincigh | bcd3c85 | 2018-09-28 14:14:12 +0100 | [diff] [blame] | 972 | template <typename L2NormalizationWorkloadType, typename armnn::DataType DataType> |
| 973 | static void ClL2NormalizationWorkloadTest(DataLayout dataLayout) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 974 | { |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 975 | Graph graph; |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 976 | ClWorkloadFactory factory = |
| 977 | ClWorkloadFactoryHelper::GetFactory(ClWorkloadFactoryHelper::GetMemoryManager()); |
| 978 | |
Matteo Martincigh | 2400b6d | 2018-10-09 18:19:20 +0100 | [diff] [blame] | 979 | auto workload = |
| 980 | CreateL2NormalizationWorkloadTest<L2NormalizationWorkloadType, DataType>(factory, graph, dataLayout); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 981 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 982 | // Checks that inputs/outputs are as we expect them (see definition of CreateNormalizationWorkloadTest). |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 983 | L2NormalizationQueueDescriptor queueDescriptor = workload->GetData(); |
Jan Eilers | bb446e5 | 2020-04-02 13:56:54 +0100 | [diff] [blame] | 984 | auto inputHandle = PolymorphicDowncast<IClTensorHandle*>(queueDescriptor.m_Inputs[0]); |
| 985 | auto outputHandle = PolymorphicDowncast<IClTensorHandle*>(queueDescriptor.m_Outputs[0]); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 986 | |
Mike Kelly | db48288 | 2019-06-14 12:35:24 +0100 | [diff] [blame] | 987 | TensorShape inputShape = (dataLayout == DataLayout::NCHW) ? std::initializer_list<unsigned int>({ 5, 20, 50, 67 }) |
| 988 | : std::initializer_list<unsigned int>({ 5, 50, 67, 20 }); |
| 989 | TensorShape outputShape = (dataLayout == DataLayout::NCHW) ? std::initializer_list<unsigned int>({ 5, 20, 50, 67 }) |
| 990 | : std::initializer_list<unsigned int>({ 5, 50, 67, 20 }); |
Matteo Martincigh | 2400b6d | 2018-10-09 18:19:20 +0100 | [diff] [blame] | 991 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 992 | CHECK((inputHandle->GetShape() == inputShape)); |
| 993 | CHECK((outputHandle->GetShape() == outputShape)); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 994 | } |
| 995 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 996 | TEST_CASE_FIXTURE(ClContextControlFixture, "CreateL2NormalizationFloatNchwWorkload") |
Matteo Martincigh | bcd3c85 | 2018-09-28 14:14:12 +0100 | [diff] [blame] | 997 | { |
| 998 | ClL2NormalizationWorkloadTest<ClL2NormalizationFloatWorkload, armnn::DataType::Float32>(DataLayout::NCHW); |
| 999 | } |
| 1000 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 1001 | TEST_CASE_FIXTURE(ClContextControlFixture, "CreateL2NormalizationFloatNhwcWorkload") |
Matteo Martincigh | bcd3c85 | 2018-09-28 14:14:12 +0100 | [diff] [blame] | 1002 | { |
| 1003 | ClL2NormalizationWorkloadTest<ClL2NormalizationFloatWorkload, armnn::DataType::Float32>(DataLayout::NHWC); |
| 1004 | } |
| 1005 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 1006 | TEST_CASE_FIXTURE(ClContextControlFixture, "CreateL2NormalizationFloat16NchwWorkload") |
Matteo Martincigh | bcd3c85 | 2018-09-28 14:14:12 +0100 | [diff] [blame] | 1007 | { |
| 1008 | ClL2NormalizationWorkloadTest<ClL2NormalizationFloatWorkload, armnn::DataType::Float16>(DataLayout::NCHW); |
| 1009 | } |
| 1010 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 1011 | TEST_CASE_FIXTURE(ClContextControlFixture, "CreateL2NormalizationFloat16NhwcWorkload") |
Matteo Martincigh | bcd3c85 | 2018-09-28 14:14:12 +0100 | [diff] [blame] | 1012 | { |
| 1013 | ClL2NormalizationWorkloadTest<ClL2NormalizationFloatWorkload, armnn::DataType::Float16>(DataLayout::NHWC); |
| 1014 | } |
| 1015 | |
Teresa Charlin | 8398edc | 2020-07-20 14:23:02 +0100 | [diff] [blame] | 1016 | template <typename LogSoftmaxWorkloadType, typename armnn::DataType DataType> |
| 1017 | static void ClCreateLogSoftmaxWorkloadTest() |
| 1018 | { |
| 1019 | Graph graph; |
| 1020 | ClWorkloadFactory factory = |
| 1021 | ClWorkloadFactoryHelper::GetFactory(ClWorkloadFactoryHelper::GetMemoryManager()); |
| 1022 | |
| 1023 | auto workload = CreateLogSoftmaxWorkloadTest<LogSoftmaxWorkloadType, DataType>(factory, graph); |
| 1024 | |
| 1025 | // Checks that outputs and inputs are as we expect them (see definition of CreateLogSoftmaxWorkloadTest). |
| 1026 | LogSoftmaxQueueDescriptor queueDescriptor = workload->GetData(); |
| 1027 | auto inputHandle = PolymorphicDowncast<IClTensorHandle*>(queueDescriptor.m_Inputs[0]); |
| 1028 | auto outputHandle = PolymorphicDowncast<IClTensorHandle*>(queueDescriptor.m_Outputs[0]); |
| 1029 | |
Colm Donelan | 25ab3a8 | 2021-05-17 13:01:52 +0100 | [diff] [blame] | 1030 | auto predResult = CompareIClTensorHandleShape(inputHandle, {4, 1}); |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 1031 | CHECK_MESSAGE(predResult.m_Result, predResult.m_Message.str()); |
Colm Donelan | 25ab3a8 | 2021-05-17 13:01:52 +0100 | [diff] [blame] | 1032 | predResult = CompareIClTensorHandleShape(outputHandle, {4, 1}); |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 1033 | CHECK_MESSAGE(predResult.m_Result, predResult.m_Message.str()); |
Teresa Charlin | 8398edc | 2020-07-20 14:23:02 +0100 | [diff] [blame] | 1034 | } |
| 1035 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 1036 | TEST_CASE_FIXTURE(ClContextControlFixture, "CreateLogSoftmaxFloat32WorkloadTest") |
Teresa Charlin | 8398edc | 2020-07-20 14:23:02 +0100 | [diff] [blame] | 1037 | { |
| 1038 | ClCreateLogSoftmaxWorkloadTest<ClLogSoftmaxWorkload, armnn::DataType::Float32>(); |
| 1039 | } |
| 1040 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 1041 | template <typename LstmWorkloadType> |
| 1042 | static void ClCreateLstmWorkloadTest() |
| 1043 | { |
| 1044 | Graph graph; |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 1045 | ClWorkloadFactory factory = |
| 1046 | ClWorkloadFactoryHelper::GetFactory(ClWorkloadFactoryHelper::GetMemoryManager()); |
| 1047 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 1048 | auto workload = CreateLstmWorkloadTest<LstmWorkloadType>(factory, graph); |
| 1049 | |
| 1050 | LstmQueueDescriptor queueDescriptor = workload->GetData(); |
Jan Eilers | bb446e5 | 2020-04-02 13:56:54 +0100 | [diff] [blame] | 1051 | auto inputHandle = PolymorphicDowncast<IClTensorHandle*>(queueDescriptor.m_Inputs[0]); |
| 1052 | auto outputHandle = PolymorphicDowncast<IClTensorHandle*>(queueDescriptor.m_Outputs[1]); |
Colm Donelan | 25ab3a8 | 2021-05-17 13:01:52 +0100 | [diff] [blame] | 1053 | auto predResult = CompareIClTensorHandleShape(inputHandle, {2, 2}); |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 1054 | CHECK_MESSAGE(predResult.m_Result, predResult.m_Message.str()); |
Colm Donelan | 25ab3a8 | 2021-05-17 13:01:52 +0100 | [diff] [blame] | 1055 | predResult = CompareIClTensorHandleShape(outputHandle, {2, 4}); |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 1056 | CHECK_MESSAGE(predResult.m_Result, predResult.m_Message.str()); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 1057 | } |
| 1058 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 1059 | TEST_CASE_FIXTURE(ClContextControlFixture, "CreateLSTMWorkloadFloatWorkload") |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 1060 | { |
arovir01 | 9e53a35 | 2018-08-31 15:26:35 +0100 | [diff] [blame] | 1061 | ClCreateLstmWorkloadTest<ClLstmFloatWorkload>(); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 1062 | } |
| 1063 | |
Aron Virginas-Tar | cc0cefb | 2019-07-02 17:25:47 +0100 | [diff] [blame] | 1064 | template <typename ResizeWorkloadType, typename armnn::DataType DataType> |
| 1065 | static void ClResizeWorkloadTest(DataLayout dataLayout) |
James Conroy | 074f371 | 2018-10-03 09:32:03 +0100 | [diff] [blame] | 1066 | { |
| 1067 | Graph graph; |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 1068 | ClWorkloadFactory factory = |
| 1069 | ClWorkloadFactoryHelper::GetFactory(ClWorkloadFactoryHelper::GetMemoryManager()); |
James Conroy | 074f371 | 2018-10-03 09:32:03 +0100 | [diff] [blame] | 1070 | |
Aron Virginas-Tar | cc0cefb | 2019-07-02 17:25:47 +0100 | [diff] [blame] | 1071 | auto workload = CreateResizeBilinearWorkloadTest<ResizeWorkloadType, DataType>(factory, graph, dataLayout); |
James Conroy | 074f371 | 2018-10-03 09:32:03 +0100 | [diff] [blame] | 1072 | |
Aron Virginas-Tar | 169d2f1 | 2019-07-01 19:01:44 +0100 | [diff] [blame] | 1073 | auto queueDescriptor = workload->GetData(); |
| 1074 | |
Jan Eilers | bb446e5 | 2020-04-02 13:56:54 +0100 | [diff] [blame] | 1075 | auto inputHandle = PolymorphicDowncast<IClTensorHandle*>(queueDescriptor.m_Inputs[0]); |
| 1076 | auto outputHandle = PolymorphicDowncast<IClTensorHandle*>(queueDescriptor.m_Outputs[0]); |
James Conroy | 074f371 | 2018-10-03 09:32:03 +0100 | [diff] [blame] | 1077 | |
Colm Donelan | 25ab3a8 | 2021-05-17 13:01:52 +0100 | [diff] [blame] | 1078 | armnn::PredicateResult predResult(true); |
James Conroy | 074f371 | 2018-10-03 09:32:03 +0100 | [diff] [blame] | 1079 | switch (dataLayout) |
| 1080 | { |
| 1081 | case DataLayout::NHWC: |
Colm Donelan | 25ab3a8 | 2021-05-17 13:01:52 +0100 | [diff] [blame] | 1082 | predResult = CompareIClTensorHandleShape(inputHandle, { 2, 4, 4, 3 }); |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 1083 | CHECK_MESSAGE(predResult.m_Result, predResult.m_Message.str()); |
Colm Donelan | 25ab3a8 | 2021-05-17 13:01:52 +0100 | [diff] [blame] | 1084 | predResult = CompareIClTensorHandleShape(outputHandle, { 2, 2, 2, 3 }); |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 1085 | CHECK_MESSAGE(predResult.m_Result, predResult.m_Message.str()); |
James Conroy | 074f371 | 2018-10-03 09:32:03 +0100 | [diff] [blame] | 1086 | break; |
Colm Donelan | 25ab3a8 | 2021-05-17 13:01:52 +0100 | [diff] [blame] | 1087 | default: // DataLayout::NCHW |
| 1088 | predResult = CompareIClTensorHandleShape(inputHandle, { 2, 3, 4, 4 }); |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 1089 | CHECK_MESSAGE(predResult.m_Result, predResult.m_Message.str()); |
Colm Donelan | 25ab3a8 | 2021-05-17 13:01:52 +0100 | [diff] [blame] | 1090 | predResult = CompareIClTensorHandleShape(outputHandle, { 2, 3, 2, 2 }); |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 1091 | CHECK_MESSAGE(predResult.m_Result, predResult.m_Message.str()); |
James Conroy | 074f371 | 2018-10-03 09:32:03 +0100 | [diff] [blame] | 1092 | } |
| 1093 | } |
| 1094 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 1095 | TEST_CASE_FIXTURE(ClContextControlFixture, "CreateResizeFloat32NchwWorkload") |
James Conroy | 074f371 | 2018-10-03 09:32:03 +0100 | [diff] [blame] | 1096 | { |
Aron Virginas-Tar | cc0cefb | 2019-07-02 17:25:47 +0100 | [diff] [blame] | 1097 | ClResizeWorkloadTest<ClResizeWorkload, armnn::DataType::Float32>(DataLayout::NCHW); |
James Conroy | 074f371 | 2018-10-03 09:32:03 +0100 | [diff] [blame] | 1098 | } |
| 1099 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 1100 | TEST_CASE_FIXTURE(ClContextControlFixture, "CreateResizeFloat16NchwWorkload") |
James Conroy | 074f371 | 2018-10-03 09:32:03 +0100 | [diff] [blame] | 1101 | { |
Aron Virginas-Tar | cc0cefb | 2019-07-02 17:25:47 +0100 | [diff] [blame] | 1102 | ClResizeWorkloadTest<ClResizeWorkload, armnn::DataType::Float16>(DataLayout::NCHW); |
James Conroy | 074f371 | 2018-10-03 09:32:03 +0100 | [diff] [blame] | 1103 | } |
| 1104 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 1105 | TEST_CASE_FIXTURE(ClContextControlFixture, "CreateResizeUint8NchwWorkload") |
James Conroy | 074f371 | 2018-10-03 09:32:03 +0100 | [diff] [blame] | 1106 | { |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 1107 | ClResizeWorkloadTest<ClResizeWorkload, armnn::DataType::QAsymmU8>(DataLayout::NCHW); |
James Conroy | 074f371 | 2018-10-03 09:32:03 +0100 | [diff] [blame] | 1108 | } |
| 1109 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 1110 | TEST_CASE_FIXTURE(ClContextControlFixture, "CreateResizeFloat32NhwcWorkload") |
James Conroy | 074f371 | 2018-10-03 09:32:03 +0100 | [diff] [blame] | 1111 | { |
Aron Virginas-Tar | cc0cefb | 2019-07-02 17:25:47 +0100 | [diff] [blame] | 1112 | ClResizeWorkloadTest<ClResizeWorkload, armnn::DataType::Float32>(DataLayout::NHWC); |
| 1113 | } |
| 1114 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 1115 | TEST_CASE_FIXTURE(ClContextControlFixture, "CreateResizeFloat16NhwcWorkload") |
Aron Virginas-Tar | cc0cefb | 2019-07-02 17:25:47 +0100 | [diff] [blame] | 1116 | { |
| 1117 | ClResizeWorkloadTest<ClResizeWorkload, armnn::DataType::Float16>(DataLayout::NHWC); |
| 1118 | } |
| 1119 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 1120 | TEST_CASE_FIXTURE(ClContextControlFixture, "CreateResizeUint8NhwcWorkload") |
Aron Virginas-Tar | cc0cefb | 2019-07-02 17:25:47 +0100 | [diff] [blame] | 1121 | { |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 1122 | ClResizeWorkloadTest<ClResizeWorkload, armnn::DataType::QAsymmU8>(DataLayout::NHWC); |
James Conroy | 074f371 | 2018-10-03 09:32:03 +0100 | [diff] [blame] | 1123 | } |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 1124 | |
Matteo Martincigh | 28dcab6 | 2018-10-19 16:40:03 +0100 | [diff] [blame] | 1125 | template <typename MeanWorkloadType, typename armnn::DataType DataType> |
| 1126 | static void ClMeanWorkloadTest() |
| 1127 | { |
| 1128 | Graph graph; |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 1129 | ClWorkloadFactory factory = |
| 1130 | ClWorkloadFactoryHelper::GetFactory(ClWorkloadFactoryHelper::GetMemoryManager()); |
| 1131 | |
Matteo Martincigh | 28dcab6 | 2018-10-19 16:40:03 +0100 | [diff] [blame] | 1132 | auto workload = CreateMeanWorkloadTest<MeanWorkloadType, DataType>(factory, graph); |
| 1133 | |
| 1134 | // Checks that inputs/outputs are as we expect them (see definition of CreateMeanWorkloadTest). |
| 1135 | MeanQueueDescriptor queueDescriptor = workload->GetData(); |
Jan Eilers | bb446e5 | 2020-04-02 13:56:54 +0100 | [diff] [blame] | 1136 | auto inputHandle = PolymorphicDowncast<IClTensorHandle*>(queueDescriptor.m_Inputs[0]); |
| 1137 | auto outputHandle = PolymorphicDowncast<IClTensorHandle*>(queueDescriptor.m_Outputs[0]); |
Matteo Martincigh | 28dcab6 | 2018-10-19 16:40:03 +0100 | [diff] [blame] | 1138 | |
| 1139 | // The first dimension (batch size) in both input and output is singular thus it has been reduced by ACL. |
Colm Donelan | 25ab3a8 | 2021-05-17 13:01:52 +0100 | [diff] [blame] | 1140 | auto predResult = CompareIClTensorHandleShape(inputHandle, { 1, 3, 7, 4 }); |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 1141 | CHECK_MESSAGE(predResult.m_Result, predResult.m_Message.str()); |
Colm Donelan | 25ab3a8 | 2021-05-17 13:01:52 +0100 | [diff] [blame] | 1142 | predResult = CompareIClTensorHandleShape(outputHandle, { 1, 4 }); |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 1143 | CHECK_MESSAGE(predResult.m_Result, predResult.m_Message.str()); |
Matteo Martincigh | 28dcab6 | 2018-10-19 16:40:03 +0100 | [diff] [blame] | 1144 | } |
| 1145 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 1146 | TEST_CASE_FIXTURE(ClContextControlFixture, "CreateMeanFloat32Workload") |
Matteo Martincigh | 28dcab6 | 2018-10-19 16:40:03 +0100 | [diff] [blame] | 1147 | { |
| 1148 | ClMeanWorkloadTest<ClMeanWorkload, armnn::DataType::Float32>(); |
| 1149 | } |
| 1150 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 1151 | TEST_CASE_FIXTURE(ClContextControlFixture, "CreateMeanFloat16Workload") |
Matteo Martincigh | 28dcab6 | 2018-10-19 16:40:03 +0100 | [diff] [blame] | 1152 | { |
| 1153 | ClMeanWorkloadTest<ClMeanWorkload, armnn::DataType::Float16>(); |
| 1154 | } |
| 1155 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 1156 | TEST_CASE_FIXTURE(ClContextControlFixture, "CreateMeanUint8Workload") |
Matteo Martincigh | 28dcab6 | 2018-10-19 16:40:03 +0100 | [diff] [blame] | 1157 | { |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 1158 | ClMeanWorkloadTest<ClMeanWorkload, armnn::DataType::QAsymmU8>(); |
Matteo Martincigh | 28dcab6 | 2018-10-19 16:40:03 +0100 | [diff] [blame] | 1159 | } |
| 1160 | |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 1161 | template <typename ConcatWorkloadType, armnn::DataType DataType> |
| 1162 | static void ClCreateConcatWorkloadTest(std::initializer_list<unsigned int> outputShape, |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 1163 | unsigned int concatAxis) |
| 1164 | { |
| 1165 | Graph graph; |
| 1166 | ClWorkloadFactory factory = |
| 1167 | ClWorkloadFactoryHelper::GetFactory(ClWorkloadFactoryHelper::GetMemoryManager()); |
| 1168 | |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 1169 | auto workload = CreateConcatWorkloadTest<ConcatWorkloadType, DataType>(factory, graph, outputShape, concatAxis); |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 1170 | |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 1171 | ConcatQueueDescriptor queueDescriptor = workload->GetData(); |
Jan Eilers | bb446e5 | 2020-04-02 13:56:54 +0100 | [diff] [blame] | 1172 | auto inputHandle0 = PolymorphicDowncast<IClTensorHandle*>(queueDescriptor.m_Inputs[0]); |
| 1173 | auto inputHandle1 = PolymorphicDowncast<IClTensorHandle*>(queueDescriptor.m_Inputs[1]); |
| 1174 | auto outputHandle = PolymorphicDowncast<IClTensorHandle*>(queueDescriptor.m_Outputs[0]); |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 1175 | |
Colm Donelan | 25ab3a8 | 2021-05-17 13:01:52 +0100 | [diff] [blame] | 1176 | auto predResult = CompareIClTensorHandleShape(inputHandle0, { 2, 3, 2, 5 }); |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 1177 | CHECK_MESSAGE(predResult.m_Result, predResult.m_Message.str()); |
Colm Donelan | 25ab3a8 | 2021-05-17 13:01:52 +0100 | [diff] [blame] | 1178 | predResult = CompareIClTensorHandleShape(inputHandle1, { 2, 3, 2, 5 }); |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 1179 | CHECK_MESSAGE(predResult.m_Result, predResult.m_Message.str()); |
Colm Donelan | 25ab3a8 | 2021-05-17 13:01:52 +0100 | [diff] [blame] | 1180 | predResult = CompareIClTensorHandleShape(outputHandle, outputShape); |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 1181 | CHECK_MESSAGE(predResult.m_Result, predResult.m_Message.str()); |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 1182 | } |
| 1183 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 1184 | TEST_CASE_FIXTURE(ClContextControlFixture, "CreateConcatDim0Float32Workload") |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 1185 | { |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 1186 | ClCreateConcatWorkloadTest<ClConcatWorkload, armnn::DataType::Float32>({ 4, 3, 2, 5 }, 0); |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 1187 | } |
| 1188 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 1189 | TEST_CASE_FIXTURE(ClContextControlFixture, "CreateConcatDim1Float32Workload") |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 1190 | { |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 1191 | ClCreateConcatWorkloadTest<ClConcatWorkload, armnn::DataType::Float32>({ 2, 6, 2, 5 }, 1); |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 1192 | } |
| 1193 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 1194 | TEST_CASE_FIXTURE(ClContextControlFixture, "CreateConcatDim3Float32Workload") |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 1195 | { |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 1196 | ClCreateConcatWorkloadTest<ClConcatWorkload, armnn::DataType::Float32>({ 2, 3, 2, 10 }, 3); |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 1197 | } |
| 1198 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 1199 | TEST_CASE_FIXTURE(ClContextControlFixture, "CreateConcatDim0Uint8Workload") |
narpra01 | 63b0882 | 2018-11-20 11:29:12 +0000 | [diff] [blame] | 1200 | { |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 1201 | ClCreateConcatWorkloadTest<ClConcatWorkload, armnn::DataType::QAsymmU8>({ 4, 3, 2, 5 }, 0); |
narpra01 | 63b0882 | 2018-11-20 11:29:12 +0000 | [diff] [blame] | 1202 | } |
| 1203 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 1204 | TEST_CASE_FIXTURE(ClContextControlFixture, "CreateConcatDim1Uint8Workload") |
narpra01 | 63b0882 | 2018-11-20 11:29:12 +0000 | [diff] [blame] | 1205 | { |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 1206 | ClCreateConcatWorkloadTest<ClConcatWorkload, armnn::DataType::QAsymmU8>({ 2, 6, 2, 5 }, 1); |
narpra01 | 63b0882 | 2018-11-20 11:29:12 +0000 | [diff] [blame] | 1207 | } |
| 1208 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 1209 | TEST_CASE_FIXTURE(ClContextControlFixture, "CreateConcatDim3Uint8Workload") |
narpra01 | 63b0882 | 2018-11-20 11:29:12 +0000 | [diff] [blame] | 1210 | { |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 1211 | ClCreateConcatWorkloadTest<ClConcatWorkload, armnn::DataType::QAsymmU8>({ 2, 3, 2, 10 }, 3); |
narpra01 | 63b0882 | 2018-11-20 11:29:12 +0000 | [diff] [blame] | 1212 | } |
| 1213 | |
James Conroy | 6059784 | 2019-07-02 10:57:56 +0100 | [diff] [blame] | 1214 | template <typename SpaceToDepthWorkloadType, typename armnn::DataType DataType> |
| 1215 | static void ClSpaceToDepthWorkloadTest() |
| 1216 | { |
| 1217 | Graph graph; |
| 1218 | ClWorkloadFactory factory = |
| 1219 | ClWorkloadFactoryHelper::GetFactory(ClWorkloadFactoryHelper::GetMemoryManager()); |
| 1220 | |
| 1221 | auto workload = CreateSpaceToDepthWorkloadTest<SpaceToDepthWorkloadType, DataType>(factory, graph); |
| 1222 | |
| 1223 | SpaceToDepthQueueDescriptor queueDescriptor = workload->GetData(); |
Jan Eilers | bb446e5 | 2020-04-02 13:56:54 +0100 | [diff] [blame] | 1224 | auto inputHandle = PolymorphicDowncast<IClTensorHandle*>(queueDescriptor.m_Inputs[0]); |
| 1225 | auto outputHandle = PolymorphicDowncast<IClTensorHandle*>(queueDescriptor.m_Outputs[0]); |
James Conroy | 6059784 | 2019-07-02 10:57:56 +0100 | [diff] [blame] | 1226 | |
Colm Donelan | 25ab3a8 | 2021-05-17 13:01:52 +0100 | [diff] [blame] | 1227 | auto predResult = CompareIClTensorHandleShape(inputHandle, { 1, 2, 2, 1 }); |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 1228 | CHECK_MESSAGE(predResult.m_Result, predResult.m_Message.str()); |
Colm Donelan | 25ab3a8 | 2021-05-17 13:01:52 +0100 | [diff] [blame] | 1229 | predResult = CompareIClTensorHandleShape(outputHandle, { 1, 1, 1, 4 }); |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 1230 | CHECK_MESSAGE(predResult.m_Result, predResult.m_Message.str()); |
James Conroy | 6059784 | 2019-07-02 10:57:56 +0100 | [diff] [blame] | 1231 | } |
| 1232 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 1233 | TEST_CASE_FIXTURE(ClContextControlFixture, "CreateSpaceToDepthFloat32Workload") |
James Conroy | 6059784 | 2019-07-02 10:57:56 +0100 | [diff] [blame] | 1234 | { |
| 1235 | ClSpaceToDepthWorkloadTest<ClSpaceToDepthWorkload, armnn::DataType::Float32>(); |
| 1236 | } |
| 1237 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 1238 | TEST_CASE_FIXTURE(ClContextControlFixture, "CreateSpaceToDepthFloat16Workload") |
James Conroy | 6059784 | 2019-07-02 10:57:56 +0100 | [diff] [blame] | 1239 | { |
| 1240 | ClSpaceToDepthWorkloadTest<ClSpaceToDepthWorkload, armnn::DataType::Float16>(); |
| 1241 | } |
| 1242 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 1243 | TEST_CASE_FIXTURE(ClContextControlFixture, "CreateSpaceToDepthQAsymm8Workload") |
James Conroy | 6059784 | 2019-07-02 10:57:56 +0100 | [diff] [blame] | 1244 | { |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 1245 | ClSpaceToDepthWorkloadTest<ClSpaceToDepthWorkload, armnn::DataType::QAsymmU8>(); |
James Conroy | 6059784 | 2019-07-02 10:57:56 +0100 | [diff] [blame] | 1246 | } |
| 1247 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 1248 | TEST_CASE_FIXTURE(ClContextControlFixture, "CreateSpaceToDepthQSymm16Workload") |
James Conroy | 6059784 | 2019-07-02 10:57:56 +0100 | [diff] [blame] | 1249 | { |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 1250 | ClSpaceToDepthWorkloadTest<ClSpaceToDepthWorkload, armnn::DataType::QSymmS16>(); |
James Conroy | 6059784 | 2019-07-02 10:57:56 +0100 | [diff] [blame] | 1251 | } |
| 1252 | |
Matthew Jackson | d516610 | 2019-07-31 14:06:28 +0100 | [diff] [blame] | 1253 | template <armnn::DataType DataType> |
| 1254 | static void ClCreateStackWorkloadTest(const std::initializer_list<unsigned int>& inputShape, |
| 1255 | const std::initializer_list<unsigned int>& outputShape, |
| 1256 | unsigned int axis, |
| 1257 | unsigned int numInputs) |
| 1258 | { |
| 1259 | armnn::Graph graph; |
| 1260 | ClWorkloadFactory factory = |
| 1261 | ClWorkloadFactoryHelper::GetFactory(ClWorkloadFactoryHelper::GetMemoryManager()); |
| 1262 | |
| 1263 | auto workload = CreateStackWorkloadTest<ClStackWorkload, DataType>(factory, |
| 1264 | graph, |
| 1265 | TensorShape(inputShape), |
| 1266 | TensorShape(outputShape), |
| 1267 | axis, |
| 1268 | numInputs); |
| 1269 | |
| 1270 | // Check inputs and output are as expected |
| 1271 | StackQueueDescriptor queueDescriptor = workload->GetData(); |
| 1272 | for (unsigned int i = 0; i < numInputs; ++i) |
| 1273 | { |
Jan Eilers | bb446e5 | 2020-04-02 13:56:54 +0100 | [diff] [blame] | 1274 | auto inputHandle = PolymorphicDowncast<IClTensorHandle*>(queueDescriptor.m_Inputs[i]); |
Colm Donelan | 25ab3a8 | 2021-05-17 13:01:52 +0100 | [diff] [blame] | 1275 | auto predResult1 = CompareIClTensorHandleShape(inputHandle, inputShape); |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 1276 | CHECK_MESSAGE(predResult1.m_Result, predResult1.m_Message.str()); |
Matthew Jackson | d516610 | 2019-07-31 14:06:28 +0100 | [diff] [blame] | 1277 | } |
Jan Eilers | bb446e5 | 2020-04-02 13:56:54 +0100 | [diff] [blame] | 1278 | auto outputHandle = PolymorphicDowncast<IClTensorHandle*>(queueDescriptor.m_Outputs[0]); |
Colm Donelan | 25ab3a8 | 2021-05-17 13:01:52 +0100 | [diff] [blame] | 1279 | auto predResult2 = CompareIClTensorHandleShape(outputHandle, outputShape); |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 1280 | CHECK_MESSAGE(predResult2.m_Result, predResult2.m_Message.str()); |
Matthew Jackson | d516610 | 2019-07-31 14:06:28 +0100 | [diff] [blame] | 1281 | } |
| 1282 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 1283 | TEST_CASE_FIXTURE(ClContextControlFixture, "CreateStackFloat32Workload") |
Matthew Jackson | d516610 | 2019-07-31 14:06:28 +0100 | [diff] [blame] | 1284 | { |
| 1285 | ClCreateStackWorkloadTest<armnn::DataType::Float32>({ 3, 4, 5 }, { 3, 4, 2, 5 }, 2, 2); |
| 1286 | } |
| 1287 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 1288 | TEST_CASE_FIXTURE(ClContextControlFixture, "CreateStackFloat16Workload") |
Matthew Jackson | e69c399 | 2019-09-09 14:31:21 +0100 | [diff] [blame] | 1289 | { |
| 1290 | ClCreateStackWorkloadTest<armnn::DataType::Float16>({ 3, 4, 5 }, { 3, 4, 2, 5 }, 2, 2); |
| 1291 | } |
| 1292 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 1293 | TEST_CASE_FIXTURE(ClContextControlFixture, "CreateStackUint8Workload") |
Matthew Jackson | d516610 | 2019-07-31 14:06:28 +0100 | [diff] [blame] | 1294 | { |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 1295 | 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] | 1296 | } |
| 1297 | |
Ryan OShea | 2323af4 | 2020-05-13 16:36:19 +0100 | [diff] [blame] | 1298 | |
| 1299 | template <typename QLstmWorkloadType> |
| 1300 | static void ClCreateQLstmWorkloadTest() |
| 1301 | { |
| 1302 | Graph graph; |
| 1303 | ClWorkloadFactory factory = ClWorkloadFactoryHelper::GetFactory(ClWorkloadFactoryHelper::GetMemoryManager()); |
| 1304 | |
| 1305 | auto workload = CreateQLstmWorkloadTest<QLstmWorkloadType>(factory, graph); |
| 1306 | QLstmQueueDescriptor queueDescriptor = workload->GetData(); |
| 1307 | |
| 1308 | IAclTensorHandle* inputHandle = PolymorphicDowncast<IAclTensorHandle*>(queueDescriptor.m_Inputs[0]); |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 1309 | CHECK((inputHandle->GetShape() == TensorShape({2, 4}))); |
| 1310 | CHECK((inputHandle->GetDataType() == arm_compute::DataType::QASYMM8_SIGNED)); |
Ryan OShea | 2323af4 | 2020-05-13 16:36:19 +0100 | [diff] [blame] | 1311 | |
| 1312 | IAclTensorHandle* cellStateOutHandle = PolymorphicDowncast<IAclTensorHandle*>(queueDescriptor.m_Outputs[1]); |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 1313 | CHECK((cellStateOutHandle->GetShape() == TensorShape({2, 4}))); |
| 1314 | CHECK((cellStateOutHandle->GetDataType() == arm_compute::DataType::QSYMM16)); |
Ryan OShea | 2323af4 | 2020-05-13 16:36:19 +0100 | [diff] [blame] | 1315 | |
| 1316 | IAclTensorHandle* outputHandle = PolymorphicDowncast<IAclTensorHandle*>(queueDescriptor.m_Outputs[2]); |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 1317 | CHECK((outputHandle->GetShape() == TensorShape({2, 4}))); |
| 1318 | CHECK((outputHandle->GetDataType() == arm_compute::DataType::QASYMM8_SIGNED)); |
Ryan OShea | 2323af4 | 2020-05-13 16:36:19 +0100 | [diff] [blame] | 1319 | } |
| 1320 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 1321 | TEST_CASE_FIXTURE(ClContextControlFixture, "CreateQLstmWorkloadTest") |
Ryan OShea | 2323af4 | 2020-05-13 16:36:19 +0100 | [diff] [blame] | 1322 | { |
| 1323 | ClCreateQLstmWorkloadTest<ClQLstmWorkload>(); |
| 1324 | } |
| 1325 | |
Ferran Balaguer | 737d9ff | 2019-08-01 09:58:08 +0100 | [diff] [blame] | 1326 | template <typename QuantizedLstmWorkloadType> |
| 1327 | static void ClCreateQuantizedLstmWorkloadTest() |
| 1328 | { |
| 1329 | using namespace armnn::armcomputetensorutils; |
Ferran Balaguer | 737d9ff | 2019-08-01 09:58:08 +0100 | [diff] [blame] | 1330 | |
| 1331 | Graph graph; |
| 1332 | ClWorkloadFactory factory = |
| 1333 | ClWorkloadFactoryHelper::GetFactory(ClWorkloadFactoryHelper::GetMemoryManager()); |
| 1334 | |
| 1335 | auto workload = CreateQuantizedLstmWorkloadTest<QuantizedLstmWorkloadType>(factory, graph); |
| 1336 | |
| 1337 | QuantizedLstmQueueDescriptor queueDescriptor = workload->GetData(); |
| 1338 | |
Jan Eilers | bb446e5 | 2020-04-02 13:56:54 +0100 | [diff] [blame] | 1339 | IAclTensorHandle* inputHandle = PolymorphicDowncast<IAclTensorHandle*>(queueDescriptor.m_Inputs[0]); |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 1340 | CHECK((inputHandle->GetShape() == TensorShape({2, 2}))); |
| 1341 | CHECK((inputHandle->GetDataType() == arm_compute::DataType::QASYMM8)); |
Ferran Balaguer | 737d9ff | 2019-08-01 09:58:08 +0100 | [diff] [blame] | 1342 | |
Jan Eilers | bb446e5 | 2020-04-02 13:56:54 +0100 | [diff] [blame] | 1343 | IAclTensorHandle* cellStateInHandle = PolymorphicDowncast<IAclTensorHandle*>(queueDescriptor.m_Inputs[1]); |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 1344 | CHECK((cellStateInHandle->GetShape() == TensorShape({2, 4}))); |
| 1345 | CHECK((cellStateInHandle->GetDataType() == arm_compute::DataType::QSYMM16)); |
Ferran Balaguer | 737d9ff | 2019-08-01 09:58:08 +0100 | [diff] [blame] | 1346 | |
Jan Eilers | bb446e5 | 2020-04-02 13:56:54 +0100 | [diff] [blame] | 1347 | IAclTensorHandle* outputStateInHandle = PolymorphicDowncast<IAclTensorHandle*>(queueDescriptor.m_Inputs[2]); |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 1348 | CHECK((outputStateInHandle->GetShape() == TensorShape({2, 4}))); |
| 1349 | CHECK((outputStateInHandle->GetDataType() == arm_compute::DataType::QASYMM8)); |
Ferran Balaguer | 737d9ff | 2019-08-01 09:58:08 +0100 | [diff] [blame] | 1350 | |
Jan Eilers | bb446e5 | 2020-04-02 13:56:54 +0100 | [diff] [blame] | 1351 | IAclTensorHandle* cellStateOutHandle = PolymorphicDowncast<IAclTensorHandle*>(queueDescriptor.m_Outputs[0]); |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 1352 | CHECK((cellStateOutHandle->GetShape() == TensorShape({2, 4}))); |
| 1353 | CHECK((cellStateOutHandle->GetDataType() == arm_compute::DataType::QSYMM16)); |
Ferran Balaguer | 737d9ff | 2019-08-01 09:58:08 +0100 | [diff] [blame] | 1354 | |
Jan Eilers | bb446e5 | 2020-04-02 13:56:54 +0100 | [diff] [blame] | 1355 | IAclTensorHandle* outputStateOutHandle = PolymorphicDowncast<IAclTensorHandle*>(queueDescriptor.m_Outputs[1]); |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 1356 | CHECK((outputStateOutHandle->GetShape() == TensorShape({2, 4}))); |
| 1357 | CHECK((outputStateOutHandle->GetDataType() == arm_compute::DataType::QASYMM8)); |
Ferran Balaguer | 737d9ff | 2019-08-01 09:58:08 +0100 | [diff] [blame] | 1358 | } |
| 1359 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 1360 | TEST_CASE_FIXTURE(ClContextControlFixture, "CreateQuantizedLstmWorkload") |
Ferran Balaguer | 737d9ff | 2019-08-01 09:58:08 +0100 | [diff] [blame] | 1361 | { |
| 1362 | ClCreateQuantizedLstmWorkloadTest<ClQuantizedLstmWorkload>(); |
| 1363 | } |
| 1364 | |
Teresa Charlin | 98b0dcb | 2022-01-18 22:09:29 +0000 | [diff] [blame] | 1365 | template <armnn::DataType DataType> |
| 1366 | static void ClCreateActivationWorkloadReplaceFunctionsTest() |
| 1367 | { |
| 1368 | std::shared_ptr<ClMemoryManager> memoryManager = std::make_shared<ClMemoryManager>( |
| 1369 | std::make_unique<arm_compute::CLBufferAllocator>()); |
| 1370 | |
| 1371 | Graph graph; |
| 1372 | ClWorkloadFactory factory = ClWorkloadFactoryHelper::GetFactory(memoryManager); |
| 1373 | // input and output are created as armnn::TensorInfo tensorInfo({1, 1}, DataType) |
| 1374 | auto workloadPtr = CreateActivationWorkloadTest<ClActivationWorkload, DataType>(factory, graph); |
| 1375 | |
| 1376 | // new input and output tensor handlers are created and then replace in the workload |
| 1377 | const ClTensorHandleFactory tensorHandleFactory(memoryManager); |
| 1378 | TensorInfo inputInfo({2 , 2}, DataType::Float16); |
| 1379 | TensorInfo outputInfo({2 , 2}, DataType::Float16); |
| 1380 | unique_ptr<ITensorHandle> inputHandle = tensorHandleFactory.CreateTensorHandle(inputInfo, true); |
| 1381 | inputHandle->Manage(); |
| 1382 | inputHandle->Allocate(); |
| 1383 | unique_ptr<ITensorHandle> outputHandle = tensorHandleFactory.CreateTensorHandle(outputInfo, true); |
| 1384 | outputHandle->Manage(); |
| 1385 | outputHandle->Allocate(); |
| 1386 | |
| 1387 | unsigned int slot = 0; |
| 1388 | CHECK_THROWS_AS(workloadPtr->ReplaceInputTensorHandle(inputHandle.get(), slot), UnimplementedException); |
| 1389 | CHECK_THROWS_AS(workloadPtr->ReplaceOutputTensorHandle(outputHandle.get(), slot), UnimplementedException); |
| 1390 | } |
| 1391 | |
| 1392 | TEST_CASE("ClReplaceFunctionsfromFloat32toFloat16ActivationWorkload") |
| 1393 | { |
| 1394 | ClCreateActivationWorkloadReplaceFunctionsTest<armnn::DataType::Float32>(); |
| 1395 | } |
| 1396 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 1397 | } |