telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1 | // |
| 2 | // Copyright © 2017 Arm Ltd. All rights reserved. |
David Beck | ecb56cd | 2018-09-05 12:52:57 +0100 | [diff] [blame] | 3 | // SPDX-License-Identifier: MIT |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 4 | // |
| 5 | #pragma once |
| 6 | |
Aron Virginas-Tar | c9cc804 | 2018-11-01 16:15:57 +0000 | [diff] [blame] | 7 | #include <Graph.hpp> |
| 8 | |
| 9 | #include <backendsCommon/WorkloadFactory.hpp> |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 10 | |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 11 | #include <armnn/utility/IgnoreUnused.hpp> |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 12 | |
| 13 | namespace |
| 14 | { |
| 15 | armnn::Graph dummyGraph; |
| 16 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 17 | // Make a dummy TensorInfo object. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 18 | template<armnn::DataType DataType> |
| 19 | armnn::TensorInfo MakeDummyTensorInfo() |
| 20 | { |
Teresa Charlin | 33d5827 | 2020-01-28 12:24:34 +0000 | [diff] [blame] | 21 | return armnn::TensorInfo({2,2,2,2}, DataType, 1.0, 0); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 22 | } |
| 23 | |
| 24 | |
| 25 | // Make a dummy WorkloadInfo using a dummy TensorInfo. |
| 26 | template<armnn::DataType DataType> |
| 27 | armnn::WorkloadInfo MakeDummyWorkloadInfo(unsigned int numInputs, unsigned int numOutputs) |
| 28 | { |
| 29 | armnn::WorkloadInfo info; |
James Conroy | ee18dc8 | 2019-07-17 11:27:46 +0100 | [diff] [blame] | 30 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 31 | for (unsigned int i=0; i < numInputs; i++) |
| 32 | { |
| 33 | info.m_InputTensorInfos.push_back(MakeDummyTensorInfo<DataType>()); |
| 34 | } |
James Conroy | ee18dc8 | 2019-07-17 11:27:46 +0100 | [diff] [blame] | 35 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 36 | for (unsigned int o=0; o < numOutputs; o++) |
| 37 | { |
| 38 | info.m_OutputTensorInfos.push_back(MakeDummyTensorInfo<DataType>()); |
| 39 | } |
James Conroy | ee18dc8 | 2019-07-17 11:27:46 +0100 | [diff] [blame] | 40 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 41 | return info; |
| 42 | } |
| 43 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 44 | // Template class to create a dummy layer (2 parameters). |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 45 | template<typename LayerType, typename DescType = typename LayerType::DescriptorType> |
| 46 | struct DummyLayer |
| 47 | { |
| 48 | DummyLayer() |
| 49 | { |
| 50 | m_Layer = dummyGraph.AddLayer<LayerType>(DescType(), ""); |
| 51 | } |
James Conroy | ee18dc8 | 2019-07-17 11:27:46 +0100 | [diff] [blame] | 52 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 53 | ~DummyLayer() |
| 54 | { |
| 55 | dummyGraph.EraseLayer(m_Layer); |
| 56 | } |
James Conroy | ee18dc8 | 2019-07-17 11:27:46 +0100 | [diff] [blame] | 57 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 58 | LayerType* m_Layer; |
| 59 | }; |
| 60 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 61 | // Template class to create a dummy layer (1 parameter). |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 62 | template<typename LayerType> |
| 63 | struct DummyLayer<LayerType, void> |
| 64 | { |
| 65 | DummyLayer() |
| 66 | { |
| 67 | m_Layer = dummyGraph.AddLayer<LayerType>(""); |
| 68 | } |
James Conroy | ee18dc8 | 2019-07-17 11:27:46 +0100 | [diff] [blame] | 69 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 70 | ~DummyLayer() |
| 71 | { |
| 72 | dummyGraph.EraseLayer(m_Layer); |
| 73 | } |
James Conroy | ee18dc8 | 2019-07-17 11:27:46 +0100 | [diff] [blame] | 74 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 75 | LayerType* m_Layer; |
| 76 | }; |
| 77 | |
| 78 | template<> |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 79 | struct DummyLayer<armnn::BatchNormalizationLayer> |
| 80 | { |
| 81 | DummyLayer() |
| 82 | { |
| 83 | m_Layer = dummyGraph.AddLayer<armnn::BatchNormalizationLayer>(armnn::BatchNormalizationDescriptor(), ""); |
| 84 | m_Layer->m_Mean = std::make_unique<armnn::ScopedCpuTensorHandle>( |
| 85 | armnn::TensorInfo(armnn::TensorShape({1,1,1,1}), armnn::DataType::Float32)); |
| 86 | m_Layer->m_Variance = std::make_unique<armnn::ScopedCpuTensorHandle>( |
| 87 | armnn::TensorInfo(armnn::TensorShape({1,1,1,1}), armnn::DataType::Float32)); |
| 88 | m_Layer->m_Beta = std::make_unique<armnn::ScopedCpuTensorHandle>( |
| 89 | armnn::TensorInfo(armnn::TensorShape({1,1,1,1}), armnn::DataType::Float32)); |
| 90 | m_Layer->m_Gamma = std::make_unique<armnn::ScopedCpuTensorHandle>( |
| 91 | armnn::TensorInfo(armnn::TensorShape({1,1,1,1}), armnn::DataType::Float32)); |
| 92 | } |
James Conroy | ee18dc8 | 2019-07-17 11:27:46 +0100 | [diff] [blame] | 93 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 94 | ~DummyLayer() |
| 95 | { |
| 96 | dummyGraph.EraseLayer(m_Layer); |
| 97 | } |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 98 | |
James Conroy | ee18dc8 | 2019-07-17 11:27:46 +0100 | [diff] [blame] | 99 | armnn::BatchNormalizationLayer* m_Layer; |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 100 | }; |
| 101 | |
| 102 | template<> |
Éanna Ó Catháin | 4e1e136 | 2018-11-12 11:36:34 +0000 | [diff] [blame] | 103 | struct DummyLayer<armnn::BatchToSpaceNdLayer> |
| 104 | { |
| 105 | DummyLayer() |
| 106 | { |
| 107 | m_Layer = dummyGraph.AddLayer<armnn::BatchToSpaceNdLayer>(armnn::BatchToSpaceNdDescriptor(), ""); |
| 108 | } |
James Conroy | ee18dc8 | 2019-07-17 11:27:46 +0100 | [diff] [blame] | 109 | |
Éanna Ó Catháin | 4e1e136 | 2018-11-12 11:36:34 +0000 | [diff] [blame] | 110 | ~DummyLayer() |
| 111 | { |
| 112 | dummyGraph.EraseLayer(m_Layer); |
| 113 | } |
James Conroy | ee18dc8 | 2019-07-17 11:27:46 +0100 | [diff] [blame] | 114 | |
Éanna Ó Catháin | 4e1e136 | 2018-11-12 11:36:34 +0000 | [diff] [blame] | 115 | armnn::BatchToSpaceNdLayer* m_Layer; |
| 116 | }; |
| 117 | |
| 118 | template<> |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 119 | struct DummyLayer<armnn::ConstantLayer, void> |
| 120 | { |
| 121 | DummyLayer() |
| 122 | { |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 123 | m_Layer = dummyGraph.AddLayer<armnn::ConstantLayer>(""); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 124 | } |
James Conroy | ee18dc8 | 2019-07-17 11:27:46 +0100 | [diff] [blame] | 125 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 126 | ~DummyLayer() |
| 127 | { |
| 128 | dummyGraph.EraseLayer(m_Layer); |
| 129 | } |
James Conroy | ee18dc8 | 2019-07-17 11:27:46 +0100 | [diff] [blame] | 130 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 131 | armnn::ConstantLayer* m_Layer; |
| 132 | }; |
| 133 | |
| 134 | template<> |
| 135 | struct DummyLayer<armnn::InputLayer, armnn::LayerBindingId> |
| 136 | { |
| 137 | DummyLayer() |
| 138 | { |
| 139 | m_Layer = dummyGraph.AddLayer<armnn::InputLayer>(armnn::LayerBindingId(), ""); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 140 | } |
James Conroy | ee18dc8 | 2019-07-17 11:27:46 +0100 | [diff] [blame] | 141 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 142 | ~DummyLayer() |
| 143 | { |
| 144 | dummyGraph.EraseLayer(m_Layer); |
| 145 | } |
James Conroy | ee18dc8 | 2019-07-17 11:27:46 +0100 | [diff] [blame] | 146 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 147 | armnn::InputLayer* m_Layer; |
| 148 | }; |
| 149 | |
| 150 | template<> |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 151 | struct DummyLayer<armnn::ConcatLayer> |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 152 | { |
| 153 | DummyLayer() |
| 154 | { |
| 155 | armnn::OriginsDescriptor desc(2); |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 156 | m_Layer = dummyGraph.AddLayer<armnn::ConcatLayer>(desc, ""); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 157 | } |
James Conroy | ee18dc8 | 2019-07-17 11:27:46 +0100 | [diff] [blame] | 158 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 159 | ~DummyLayer() |
| 160 | { |
| 161 | dummyGraph.EraseLayer(m_Layer); |
| 162 | } |
James Conroy | ee18dc8 | 2019-07-17 11:27:46 +0100 | [diff] [blame] | 163 | |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 164 | armnn::ConcatLayer* m_Layer; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 165 | }; |
| 166 | |
| 167 | template<> |
| 168 | struct DummyLayer<armnn::OutputLayer, armnn::LayerBindingId> |
| 169 | { |
| 170 | DummyLayer() |
| 171 | { |
| 172 | m_Layer = dummyGraph.AddLayer<armnn::OutputLayer>(armnn::LayerBindingId(), ""); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 173 | } |
James Conroy | ee18dc8 | 2019-07-17 11:27:46 +0100 | [diff] [blame] | 174 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 175 | ~DummyLayer() |
| 176 | { |
| 177 | dummyGraph.EraseLayer(m_Layer); |
| 178 | } |
James Conroy | ee18dc8 | 2019-07-17 11:27:46 +0100 | [diff] [blame] | 179 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 180 | armnn::OutputLayer* m_Layer; |
| 181 | }; |
| 182 | |
| 183 | template<> |
| 184 | struct DummyLayer<armnn::SplitterLayer> |
| 185 | { |
| 186 | DummyLayer() |
| 187 | { |
| 188 | armnn::ViewsDescriptor desc(1); |
| 189 | m_Layer = dummyGraph.AddLayer<armnn::SplitterLayer>(desc, ""); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 190 | } |
James Conroy | ee18dc8 | 2019-07-17 11:27:46 +0100 | [diff] [blame] | 191 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 192 | ~DummyLayer() |
| 193 | { |
| 194 | dummyGraph.EraseLayer(m_Layer); |
| 195 | } |
James Conroy | ee18dc8 | 2019-07-17 11:27:46 +0100 | [diff] [blame] | 196 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 197 | armnn::SplitterLayer* m_Layer; |
| 198 | }; |
| 199 | |
| 200 | template <typename ConvolutionLayerType> |
| 201 | struct DummyConvolutionLayer |
| 202 | { |
| 203 | DummyConvolutionLayer() |
| 204 | { |
| 205 | typename ConvolutionLayerType::DescriptorType desc; |
James Conroy | 663c184 | 2019-11-01 15:21:48 +0000 | [diff] [blame] | 206 | desc.m_StrideX = 1; |
| 207 | desc.m_StrideY = 1; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 208 | m_Layer = dummyGraph.AddLayer<ConvolutionLayerType>(desc, ""); |
| 209 | m_Layer->m_Weight = std::make_unique<armnn::ScopedCpuTensorHandle>( |
| 210 | armnn::TensorInfo(armnn::TensorShape({1,1,1,1}), armnn::DataType::Float32)); |
| 211 | m_Layer->m_Bias = std::make_unique<armnn::ScopedCpuTensorHandle>( |
| 212 | armnn::TensorInfo(armnn::TensorShape({1,1,1,1}), armnn::DataType::Float32)); |
| 213 | } |
James Conroy | ee18dc8 | 2019-07-17 11:27:46 +0100 | [diff] [blame] | 214 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 215 | ~DummyConvolutionLayer() |
| 216 | { |
| 217 | dummyGraph.EraseLayer(m_Layer); |
| 218 | } |
James Conroy | ee18dc8 | 2019-07-17 11:27:46 +0100 | [diff] [blame] | 219 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 220 | ConvolutionLayerType* m_Layer; |
| 221 | }; |
| 222 | |
| 223 | template<> |
| 224 | struct DummyLayer<armnn::Convolution2dLayer> |
| 225 | : public DummyConvolutionLayer<armnn::Convolution2dLayer> |
| 226 | { |
| 227 | }; |
| 228 | |
| 229 | template<> |
| 230 | struct DummyLayer<armnn::DepthwiseConvolution2dLayer> |
| 231 | : public DummyConvolutionLayer<armnn::DepthwiseConvolution2dLayer> |
| 232 | { |
| 233 | }; |
| 234 | |
Aron Virginas-Tar | 639fb04 | 2019-06-20 14:28:19 +0100 | [diff] [blame] | 235 | template<> |
| 236 | struct DummyLayer<armnn::TransposeConvolution2dLayer> |
| 237 | : public DummyConvolutionLayer<armnn::TransposeConvolution2dLayer> |
| 238 | { |
| 239 | }; |
| 240 | |
Derek Lamberti | 6a5e5e8 | 2019-12-05 14:41:20 +0000 | [diff] [blame] | 241 | template<> |
| 242 | struct DummyLayer<armnn::DetectionPostProcessLayer> |
| 243 | { |
| 244 | DummyLayer() |
| 245 | { |
| 246 | m_Layer = dummyGraph.AddLayer<armnn::DetectionPostProcessLayer>(armnn::DetectionPostProcessDescriptor(), ""); |
| 247 | m_Layer->m_Anchors = std::make_unique<armnn::ScopedCpuTensorHandle>( |
| 248 | armnn::TensorInfo(armnn::TensorShape({1,1,1,1}), armnn::DataType::Float32)); |
| 249 | } |
| 250 | |
| 251 | ~DummyLayer() |
| 252 | { |
| 253 | dummyGraph.EraseLayer(m_Layer); |
| 254 | } |
| 255 | |
| 256 | armnn::DetectionPostProcessLayer* m_Layer; |
| 257 | }; |
| 258 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 259 | template <typename LstmLayerType> |
| 260 | struct DummyLstmLayer |
| 261 | { |
| 262 | DummyLstmLayer() |
| 263 | { |
| 264 | typename LstmLayerType::DescriptorType desc; |
| 265 | desc.m_CifgEnabled = false; |
| 266 | |
| 267 | m_Layer = dummyGraph.AddLayer<LstmLayerType>(armnn::LstmDescriptor(), ""); |
| 268 | m_Layer->m_BasicParameters.m_InputToForgetWeights = std::make_unique<armnn::ScopedCpuTensorHandle>( |
| 269 | armnn::TensorInfo(armnn::TensorShape({1,1,1,1}), armnn::DataType::Float32)); |
| 270 | m_Layer->m_BasicParameters.m_InputToCellWeights = std::make_unique<armnn::ScopedCpuTensorHandle>( |
| 271 | armnn::TensorInfo(armnn::TensorShape({1,1,1,1}), armnn::DataType::Float32)); |
| 272 | m_Layer->m_BasicParameters.m_InputToOutputWeights = std::make_unique<armnn::ScopedCpuTensorHandle>( |
| 273 | armnn::TensorInfo(armnn::TensorShape({1,1,1,1}), armnn::DataType::Float32)); |
| 274 | m_Layer->m_BasicParameters.m_RecurrentToForgetWeights = std::make_unique<armnn::ScopedCpuTensorHandle>( |
| 275 | armnn::TensorInfo(armnn::TensorShape({1,1,1,1}), armnn::DataType::Float32)); |
| 276 | m_Layer->m_BasicParameters.m_RecurrentToCellWeights = std::make_unique<armnn::ScopedCpuTensorHandle>( |
| 277 | armnn::TensorInfo(armnn::TensorShape({1,1,1,1}), armnn::DataType::Float32)); |
| 278 | m_Layer->m_BasicParameters.m_RecurrentToOutputWeights = std::make_unique<armnn::ScopedCpuTensorHandle>( |
| 279 | armnn::TensorInfo(armnn::TensorShape({1,1,1,1}), armnn::DataType::Float32)); |
| 280 | m_Layer->m_BasicParameters.m_ForgetGateBias = std::make_unique<armnn::ScopedCpuTensorHandle>( |
| 281 | armnn::TensorInfo(armnn::TensorShape({1,1,1,1}), armnn::DataType::Float32)); |
| 282 | m_Layer->m_BasicParameters.m_CellBias = std::make_unique<armnn::ScopedCpuTensorHandle>( |
| 283 | armnn::TensorInfo(armnn::TensorShape({1,1,1,1}), armnn::DataType::Float32)); |
| 284 | m_Layer->m_BasicParameters.m_OutputGateBias = std::make_unique<armnn::ScopedCpuTensorHandle>( |
| 285 | armnn::TensorInfo(armnn::TensorShape({1,1,1,1}), armnn::DataType::Float32)); |
| 286 | |
| 287 | m_Layer->m_CifgParameters.m_InputToInputWeights = std::make_unique<armnn::ScopedCpuTensorHandle>( |
| 288 | armnn::TensorInfo(armnn::TensorShape({1,1,1,1}), armnn::DataType::Float32)); |
| 289 | m_Layer->m_CifgParameters.m_RecurrentToInputWeights = std::make_unique<armnn::ScopedCpuTensorHandle>( |
| 290 | armnn::TensorInfo(armnn::TensorShape({1,1,1,1}), armnn::DataType::Float32)); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 291 | m_Layer->m_CifgParameters.m_InputGateBias = std::make_unique<armnn::ScopedCpuTensorHandle>( |
| 292 | armnn::TensorInfo(armnn::TensorShape({1,1,1,1}), armnn::DataType::Float32)); |
| 293 | } |
James Conroy | ee18dc8 | 2019-07-17 11:27:46 +0100 | [diff] [blame] | 294 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 295 | ~DummyLstmLayer() |
| 296 | { |
| 297 | dummyGraph.EraseLayer(m_Layer); |
| 298 | } |
James Conroy | ee18dc8 | 2019-07-17 11:27:46 +0100 | [diff] [blame] | 299 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 300 | armnn::LstmLayer* m_Layer; |
| 301 | }; |
| 302 | |
| 303 | template<> |
| 304 | struct DummyLayer<armnn::LstmLayer> |
| 305 | : public DummyLstmLayer<armnn::LstmLayer> |
| 306 | { |
| 307 | }; |
| 308 | |
James Conroy | 586a9aa | 2020-03-20 08:49:33 +0000 | [diff] [blame] | 309 | template <typename QLstmLayerType> |
| 310 | struct DummyQLstmLayer |
| 311 | { |
| 312 | DummyQLstmLayer() |
| 313 | { |
| 314 | typename QLstmLayerType::DescriptorType desc; |
| 315 | desc.m_CifgEnabled = false; |
| 316 | desc.m_PeepholeEnabled = true; |
| 317 | desc.m_ProjectionEnabled = true; |
| 318 | desc.m_LayerNormEnabled = true; |
| 319 | |
| 320 | m_Layer = dummyGraph.AddLayer<QLstmLayerType>(armnn::QLstmDescriptor(), "qLstm"); |
| 321 | |
| 322 | // Basic params |
| 323 | m_Layer->m_BasicParameters.m_InputToForgetWeights = std::make_unique<armnn::ScopedCpuTensorHandle>( |
| 324 | armnn::TensorInfo(armnn::TensorShape({1,1,1,1}), armnn::DataType::QSymmS8)); |
| 325 | m_Layer->m_BasicParameters.m_InputToCellWeights = std::make_unique<armnn::ScopedCpuTensorHandle>( |
| 326 | armnn::TensorInfo(armnn::TensorShape({1,1,1,1}), armnn::DataType::QSymmS8)); |
| 327 | m_Layer->m_BasicParameters.m_InputToOutputWeights = std::make_unique<armnn::ScopedCpuTensorHandle>( |
| 328 | armnn::TensorInfo(armnn::TensorShape({1,1,1,1}), armnn::DataType::QSymmS8)); |
| 329 | |
| 330 | m_Layer->m_BasicParameters.m_RecurrentToForgetWeights = std::make_unique<armnn::ScopedCpuTensorHandle>( |
| 331 | armnn::TensorInfo(armnn::TensorShape({1,1,1,1}), armnn::DataType::QSymmS8)); |
| 332 | m_Layer->m_BasicParameters.m_RecurrentToCellWeights = std::make_unique<armnn::ScopedCpuTensorHandle>( |
| 333 | armnn::TensorInfo(armnn::TensorShape({1,1,1,1}), armnn::DataType::QSymmS8)); |
| 334 | m_Layer->m_BasicParameters.m_RecurrentToOutputWeights = std::make_unique<armnn::ScopedCpuTensorHandle>( |
| 335 | armnn::TensorInfo(armnn::TensorShape({1,1,1,1}), armnn::DataType::QSymmS8)); |
| 336 | |
| 337 | m_Layer->m_BasicParameters.m_ForgetGateBias = std::make_unique<armnn::ScopedCpuTensorHandle>( |
| 338 | armnn::TensorInfo(armnn::TensorShape({1,1,1,1}), armnn::DataType::Signed32)); |
| 339 | m_Layer->m_BasicParameters.m_CellBias = std::make_unique<armnn::ScopedCpuTensorHandle>( |
| 340 | armnn::TensorInfo(armnn::TensorShape({1,1,1,1}), armnn::DataType::Signed32)); |
| 341 | m_Layer->m_BasicParameters.m_OutputGateBias = std::make_unique<armnn::ScopedCpuTensorHandle>( |
| 342 | armnn::TensorInfo(armnn::TensorShape({1,1,1,1}), armnn::DataType::Signed32)); |
| 343 | |
| 344 | // CIFG optional params |
| 345 | m_Layer->m_CifgParameters.m_InputToInputWeights = std::make_unique<armnn::ScopedCpuTensorHandle>( |
| 346 | armnn::TensorInfo(armnn::TensorShape({1,1,1,1}), armnn::DataType::QSymmS8)); |
| 347 | m_Layer->m_CifgParameters.m_RecurrentToInputWeights = std::make_unique<armnn::ScopedCpuTensorHandle>( |
| 348 | armnn::TensorInfo(armnn::TensorShape({1,1,1,1}), armnn::DataType::QSymmS8)); |
| 349 | m_Layer->m_CifgParameters.m_InputGateBias = std::make_unique<armnn::ScopedCpuTensorHandle>( |
| 350 | armnn::TensorInfo(armnn::TensorShape({1,1,1,1}), armnn::DataType::Signed32)); |
| 351 | |
| 352 | // Projection optional params |
| 353 | m_Layer->m_ProjectionParameters.m_ProjectionWeights = std::make_unique<armnn::ScopedCpuTensorHandle>( |
| 354 | armnn::TensorInfo(armnn::TensorShape({1,1,1,1}), armnn::DataType::QSymmS8)); |
| 355 | m_Layer->m_ProjectionParameters.m_ProjectionBias = std::make_unique<armnn::ScopedCpuTensorHandle>( |
| 356 | armnn::TensorInfo(armnn::TensorShape({1,1,1,1}), armnn::DataType::Signed32)); |
| 357 | |
| 358 | // Peephole optional params |
| 359 | m_Layer->m_PeepholeParameters.m_CellToInputWeights = std::make_unique<armnn::ScopedCpuTensorHandle>( |
| 360 | armnn::TensorInfo(armnn::TensorShape({1,1,1,1}), armnn::DataType::QSymmS16)); |
| 361 | m_Layer->m_PeepholeParameters.m_CellToForgetWeights = std::make_unique<armnn::ScopedCpuTensorHandle>( |
| 362 | armnn::TensorInfo(armnn::TensorShape({1,1,1,1}), armnn::DataType::QSymmS16)); |
| 363 | m_Layer->m_PeepholeParameters.m_CellToOutputWeights = std::make_unique<armnn::ScopedCpuTensorHandle>( |
| 364 | armnn::TensorInfo(armnn::TensorShape({1,1,1,1}), armnn::DataType::QSymmS16)); |
| 365 | |
| 366 | // Layer normalization optional params |
| 367 | m_Layer->m_LayerNormParameters.m_InputLayerNormWeights = std::make_unique<armnn::ScopedCpuTensorHandle>( |
| 368 | armnn::TensorInfo(armnn::TensorShape({1,1,1,1}), armnn::DataType::QSymmS16)); |
| 369 | m_Layer->m_LayerNormParameters.m_ForgetLayerNormWeights = std::make_unique<armnn::ScopedCpuTensorHandle>( |
| 370 | armnn::TensorInfo(armnn::TensorShape({1,1,1,1}), armnn::DataType::QSymmS16)); |
| 371 | m_Layer->m_LayerNormParameters.m_CellLayerNormWeights = std::make_unique<armnn::ScopedCpuTensorHandle>( |
| 372 | armnn::TensorInfo(armnn::TensorShape({1,1,1,1}), armnn::DataType::QSymmS16)); |
| 373 | m_Layer->m_LayerNormParameters.m_OutputLayerNormWeights = std::make_unique<armnn::ScopedCpuTensorHandle>( |
| 374 | armnn::TensorInfo(armnn::TensorShape({1,1,1,1}), armnn::DataType::QSymmS16)); |
| 375 | } |
| 376 | |
| 377 | ~DummyQLstmLayer() |
| 378 | { |
| 379 | dummyGraph.EraseLayer(m_Layer); |
| 380 | } |
| 381 | |
| 382 | armnn::QLstmLayer* m_Layer; |
| 383 | }; |
| 384 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 385 | template<> |
James Conroy | ee18dc8 | 2019-07-17 11:27:46 +0100 | [diff] [blame] | 386 | struct DummyLayer<armnn::QuantizedLstmLayer, void> |
| 387 | { |
| 388 | DummyLayer() |
| 389 | { |
| 390 | m_Layer = dummyGraph.AddLayer<armnn::QuantizedLstmLayer>(""); |
| 391 | |
| 392 | m_Layer->m_QuantizedLstmParameters.m_InputToInputWeights = std::make_unique<armnn::ScopedCpuTensorHandle>( |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 393 | armnn::TensorInfo(armnn::TensorShape({1,1,1,1}), armnn::DataType::QAsymmU8)); |
James Conroy | ee18dc8 | 2019-07-17 11:27:46 +0100 | [diff] [blame] | 394 | m_Layer->m_QuantizedLstmParameters.m_InputToForgetWeights = std::make_unique<armnn::ScopedCpuTensorHandle>( |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 395 | armnn::TensorInfo(armnn::TensorShape({1,1,1,1}), armnn::DataType::QAsymmU8)); |
James Conroy | ee18dc8 | 2019-07-17 11:27:46 +0100 | [diff] [blame] | 396 | m_Layer->m_QuantizedLstmParameters.m_InputToCellWeights = std::make_unique<armnn::ScopedCpuTensorHandle>( |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 397 | armnn::TensorInfo(armnn::TensorShape({1,1,1,1}), armnn::DataType::QAsymmU8)); |
James Conroy | ee18dc8 | 2019-07-17 11:27:46 +0100 | [diff] [blame] | 398 | m_Layer->m_QuantizedLstmParameters.m_InputToOutputWeights = std::make_unique<armnn::ScopedCpuTensorHandle>( |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 399 | armnn::TensorInfo(armnn::TensorShape({1,1,1,1}), armnn::DataType::QAsymmU8)); |
James Conroy | ee18dc8 | 2019-07-17 11:27:46 +0100 | [diff] [blame] | 400 | |
| 401 | m_Layer->m_QuantizedLstmParameters.m_RecurrentToInputWeights = std::make_unique<armnn::ScopedCpuTensorHandle>( |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 402 | armnn::TensorInfo(armnn::TensorShape({1,1,1,1}), armnn::DataType::QAsymmU8)); |
James Conroy | ee18dc8 | 2019-07-17 11:27:46 +0100 | [diff] [blame] | 403 | m_Layer->m_QuantizedLstmParameters.m_RecurrentToForgetWeights = std::make_unique<armnn::ScopedCpuTensorHandle>( |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 404 | armnn::TensorInfo(armnn::TensorShape({1,1,1,1}), armnn::DataType::QAsymmU8)); |
James Conroy | ee18dc8 | 2019-07-17 11:27:46 +0100 | [diff] [blame] | 405 | m_Layer->m_QuantizedLstmParameters.m_RecurrentToCellWeights = std::make_unique<armnn::ScopedCpuTensorHandle>( |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 406 | armnn::TensorInfo(armnn::TensorShape({1,1,1,1}), armnn::DataType::QAsymmU8)); |
James Conroy | ee18dc8 | 2019-07-17 11:27:46 +0100 | [diff] [blame] | 407 | m_Layer->m_QuantizedLstmParameters.m_RecurrentToOutputWeights = std::make_unique<armnn::ScopedCpuTensorHandle>( |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 408 | armnn::TensorInfo(armnn::TensorShape({1,1,1,1}), armnn::DataType::QAsymmU8)); |
James Conroy | ee18dc8 | 2019-07-17 11:27:46 +0100 | [diff] [blame] | 409 | |
| 410 | m_Layer->m_QuantizedLstmParameters.m_InputGateBias = std::make_unique<armnn::ScopedCpuTensorHandle>( |
| 411 | armnn::TensorInfo(armnn::TensorShape({1,1,1,1}), armnn::DataType::Signed32)); |
| 412 | m_Layer->m_QuantizedLstmParameters.m_ForgetGateBias = std::make_unique<armnn::ScopedCpuTensorHandle>( |
| 413 | armnn::TensorInfo(armnn::TensorShape({1,1,1,1}), armnn::DataType::Signed32)); |
| 414 | m_Layer->m_QuantizedLstmParameters.m_CellBias = std::make_unique<armnn::ScopedCpuTensorHandle>( |
| 415 | armnn::TensorInfo(armnn::TensorShape({1,1,1,1}), armnn::DataType::Signed32)); |
| 416 | m_Layer->m_QuantizedLstmParameters.m_OutputGateBias = std::make_unique<armnn::ScopedCpuTensorHandle>( |
| 417 | armnn::TensorInfo(armnn::TensorShape({1,1,1,1}), armnn::DataType::Signed32)); |
| 418 | } |
| 419 | |
| 420 | ~DummyLayer() |
| 421 | { |
| 422 | dummyGraph.EraseLayer(m_Layer); |
| 423 | } |
| 424 | |
| 425 | armnn::QuantizedLstmLayer* m_Layer; |
| 426 | }; |
| 427 | |
| 428 | template<> |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 429 | struct DummyLayer<armnn::FullyConnectedLayer> |
| 430 | { |
| 431 | DummyLayer() |
| 432 | { |
| 433 | armnn::FullyConnectedLayer::DescriptorType desc; |
| 434 | m_Layer = dummyGraph.AddLayer<armnn::FullyConnectedLayer>(desc, ""); |
| 435 | m_Layer->m_Weight = std::make_unique<armnn::ScopedCpuTensorHandle>( |
| 436 | armnn::TensorInfo(armnn::TensorShape({1,1,1,1}), armnn::DataType::Float32)); |
| 437 | } |
James Conroy | ee18dc8 | 2019-07-17 11:27:46 +0100 | [diff] [blame] | 438 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 439 | ~DummyLayer() |
| 440 | { |
| 441 | dummyGraph.EraseLayer(m_Layer); |
| 442 | } |
James Conroy | ee18dc8 | 2019-07-17 11:27:46 +0100 | [diff] [blame] | 443 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 444 | armnn::FullyConnectedLayer* m_Layer; |
| 445 | }; |
| 446 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 447 | // Tag for giving LayerType entries a unique strong type each. |
| 448 | template<armnn::LayerType> |
| 449 | struct Tag{}; |
| 450 | |
| 451 | #define DECLARE_LAYER_POLICY_CUSTOM_PARAM(name, descType) \ |
| 452 | template<armnn::DataType DataType> \ |
| 453 | struct LayerTypePolicy<armnn::LayerType::name, DataType> \ |
| 454 | { \ |
| 455 | using Type = armnn::name##Layer; \ |
| 456 | using Desc = descType; \ |
| 457 | using QueueDesc = armnn::name##QueueDescriptor; \ |
| 458 | constexpr static const char* NameStr = #name; \ |
Derek Lamberti | e606b7c | 2019-10-21 16:51:11 +0100 | [diff] [blame] | 459 | constexpr static const bool IsException = false; \ |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 460 | \ |
| 461 | static std::unique_ptr<armnn::IWorkload> MakeDummyWorkload(armnn::IWorkloadFactory *factory, \ |
| 462 | unsigned int nIn, unsigned int nOut) \ |
| 463 | { \ |
| 464 | QueueDesc desc; \ |
| 465 | armnn::WorkloadInfo info = MakeDummyWorkloadInfo<DataType>(nIn, nOut); \ |
| 466 | return factory->Create##name(desc, info); \ |
| 467 | } \ |
| 468 | }; |
| 469 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 470 | // Define a layer policy specialization for use with the IsLayerSupported tests. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 471 | // Use this version for layers whose constructor takes 1 parameter(name). |
| 472 | #define DECLARE_LAYER_POLICY_1_PARAM(name) DECLARE_LAYER_POLICY_CUSTOM_PARAM(name, void) |
| 473 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 474 | // Define a layer policy specialization for use with the IsLayerSupported tests. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 475 | // Use this version for layers whose constructor takes 2 parameters(descriptor and name). |
| 476 | #define DECLARE_LAYER_POLICY_2_PARAM(name) DECLARE_LAYER_POLICY_CUSTOM_PARAM(name, armnn::name##Descriptor) |
| 477 | |
Derek Lamberti | 013c390 | 2019-10-21 10:46:16 +0100 | [diff] [blame] | 478 | |
| 479 | #define DECLARE_LAYER_POLICY_EXCEPTION(name, descType) \ |
| 480 | template<armnn::DataType DataType> \ |
| 481 | struct LayerTypePolicy<armnn::LayerType::name, DataType> \ |
| 482 | { \ |
| 483 | using Type = armnn::name##Layer; \ |
| 484 | using Desc = descType; \ |
| 485 | constexpr static const char* NameStr = #name; \ |
Derek Lamberti | b99ef39 | 2019-10-21 14:10:38 +0100 | [diff] [blame] | 486 | constexpr static const bool IsException = true; \ |
Derek Lamberti | 013c390 | 2019-10-21 10:46:16 +0100 | [diff] [blame] | 487 | \ |
| 488 | static std::unique_ptr<armnn::IWorkload> MakeDummyWorkload(armnn::IWorkloadFactory *factory, \ |
| 489 | unsigned int nIn, unsigned int nOut) \ |
| 490 | { \ |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 491 | IgnoreUnused(factory, nIn, nOut); \ |
Derek Lamberti | 013c390 | 2019-10-21 10:46:16 +0100 | [diff] [blame] | 492 | return std::unique_ptr<armnn::IWorkload>(); \ |
| 493 | } \ |
| 494 | }; |
| 495 | |
| 496 | #define DECLARE_LAYER_POLICY_EXCEPTION_1_PARAM(name) DECLARE_LAYER_POLICY_EXCEPTION(name, void) |
| 497 | #define DECLARE_LAYER_POLICY_EXCEPTION_2_PARAM(name) DECLARE_LAYER_POLICY_EXCEPTION(name, armnn::name##Descriptor) |
| 498 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 499 | // Layer policy template. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 500 | template<armnn::LayerType Type, armnn::DataType DataType> |
| 501 | struct LayerTypePolicy; |
| 502 | |
| 503 | // Every entry in the armnn::LayerType enum must be accounted for below. |
| 504 | DECLARE_LAYER_POLICY_2_PARAM(Activation) |
| 505 | |
| 506 | DECLARE_LAYER_POLICY_1_PARAM(Addition) |
| 507 | |
Nikhil Raj | ee391d5 | 2019-09-05 17:50:44 +0100 | [diff] [blame] | 508 | DECLARE_LAYER_POLICY_2_PARAM(ArgMinMax) |
| 509 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 510 | DECLARE_LAYER_POLICY_2_PARAM(BatchNormalization) |
| 511 | |
Éanna Ó Catháin | 4e1e136 | 2018-11-12 11:36:34 +0000 | [diff] [blame] | 512 | DECLARE_LAYER_POLICY_2_PARAM(BatchToSpaceNd) |
| 513 | |
Aron Virginas-Tar | 77bfb5e | 2019-10-16 17:45:38 +0100 | [diff] [blame] | 514 | DECLARE_LAYER_POLICY_2_PARAM(Comparison) |
| 515 | |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 516 | DECLARE_LAYER_POLICY_2_PARAM(Concat) |
| 517 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 518 | DECLARE_LAYER_POLICY_1_PARAM(Constant) |
| 519 | |
Narumol Prangnawarat | 7ddbbae | 2020-03-13 10:26:05 +0000 | [diff] [blame] | 520 | DECLARE_LAYER_POLICY_1_PARAM(ConvertBf16ToFp32) |
| 521 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 522 | DECLARE_LAYER_POLICY_1_PARAM(ConvertFp16ToFp32) |
| 523 | |
Narumol Prangnawarat | ea54a01 | 2020-03-16 16:36:10 +0000 | [diff] [blame] | 524 | DECLARE_LAYER_POLICY_1_PARAM(ConvertFp32ToBf16) |
| 525 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 526 | DECLARE_LAYER_POLICY_1_PARAM(ConvertFp32ToFp16) |
| 527 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 528 | DECLARE_LAYER_POLICY_2_PARAM(Convolution2d) |
| 529 | |
| 530 | DECLARE_LAYER_POLICY_1_PARAM(MemCopy) |
| 531 | |
Derek Lamberti | f674aa0 | 2019-08-01 15:56:25 +0100 | [diff] [blame] | 532 | DECLARE_LAYER_POLICY_1_PARAM(MemImport) |
| 533 | |
Nattapat Chaimanowong | 964e955 | 2019-03-26 11:03:26 +0000 | [diff] [blame] | 534 | DECLARE_LAYER_POLICY_1_PARAM(Debug) |
Nattapat Chaimanowong | a9a1cf1 | 2018-12-03 16:06:49 +0000 | [diff] [blame] | 535 | |
Aron Virginas-Tar | dd6247f | 2019-09-19 14:31:17 +0100 | [diff] [blame] | 536 | DECLARE_LAYER_POLICY_2_PARAM(DepthToSpace) |
| 537 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 538 | DECLARE_LAYER_POLICY_2_PARAM(DepthwiseConvolution2d) |
| 539 | |
Nattapat Chaimanowong | e4294fd | 2019-03-28 09:56:53 +0000 | [diff] [blame] | 540 | DECLARE_LAYER_POLICY_1_PARAM(Dequantize) |
| 541 | |
Narumol Prangnawarat | 94dd5d8 | 2019-01-23 18:06:26 +0000 | [diff] [blame] | 542 | DECLARE_LAYER_POLICY_2_PARAM(DetectionPostProcess) |
| 543 | |
josh minor | 4a3c610 | 2020-01-06 16:40:46 -0600 | [diff] [blame] | 544 | DECLARE_LAYER_POLICY_2_PARAM(ElementwiseUnary) |
| 545 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 546 | DECLARE_LAYER_POLICY_2_PARAM(FakeQuantization) |
| 547 | |
| 548 | DECLARE_LAYER_POLICY_1_PARAM(Floor) |
| 549 | |
| 550 | DECLARE_LAYER_POLICY_2_PARAM(FullyConnected) |
| 551 | |
narpra01 | b89b05f | 2019-01-16 09:53:09 +0000 | [diff] [blame] | 552 | DECLARE_LAYER_POLICY_1_PARAM(Gather) |
| 553 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 554 | DECLARE_LAYER_POLICY_CUSTOM_PARAM(Input, armnn::LayerBindingId) |
| 555 | |
Kevin May | ce5045a | 2019-10-02 14:07:47 +0100 | [diff] [blame] | 556 | DECLARE_LAYER_POLICY_2_PARAM(InstanceNormalization) |
| 557 | |
Matteo Martincigh | bcd3c85 | 2018-09-28 14:14:12 +0100 | [diff] [blame] | 558 | DECLARE_LAYER_POLICY_2_PARAM(L2Normalization) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 559 | |
Aron Virginas-Tar | f982dea | 2019-10-11 14:07:53 +0100 | [diff] [blame] | 560 | DECLARE_LAYER_POLICY_2_PARAM(LogSoftmax) |
| 561 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 562 | DECLARE_LAYER_POLICY_2_PARAM(Lstm) |
| 563 | |
Nattapat Chaimanowong | 5a4304a | 2018-11-28 10:44:37 +0000 | [diff] [blame] | 564 | DECLARE_LAYER_POLICY_1_PARAM(Maximum) |
| 565 | |
narpra01 | 32b9046 | 2018-09-13 11:07:48 +0100 | [diff] [blame] | 566 | DECLARE_LAYER_POLICY_2_PARAM(Mean) |
| 567 | |
Nattapat Chaimanowong | 1f88630 | 2019-04-05 13:37:19 +0100 | [diff] [blame] | 568 | DECLARE_LAYER_POLICY_1_PARAM(Merge) |
| 569 | |
kevmay01 | 9053969 | 2018-11-29 08:40:19 +0000 | [diff] [blame] | 570 | DECLARE_LAYER_POLICY_1_PARAM(Minimum) |
| 571 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 572 | DECLARE_LAYER_POLICY_1_PARAM(Multiplication) |
| 573 | |
| 574 | DECLARE_LAYER_POLICY_2_PARAM(Normalization) |
| 575 | |
| 576 | DECLARE_LAYER_POLICY_CUSTOM_PARAM(Output, armnn::LayerBindingId) |
| 577 | |
Mohamed Nour Abouelseoud | 5662c20 | 2018-09-24 13:30:09 +0100 | [diff] [blame] | 578 | DECLARE_LAYER_POLICY_2_PARAM(Pad) |
| 579 | |
Derek Lamberti | a9cca6a | 2019-03-25 15:41:58 +0000 | [diff] [blame] | 580 | DECLARE_LAYER_POLICY_1_PARAM(Quantize) |
| 581 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 582 | DECLARE_LAYER_POLICY_2_PARAM(Permute) |
| 583 | |
| 584 | DECLARE_LAYER_POLICY_2_PARAM(Pooling2d) |
| 585 | |
Matteo Martincigh | 4912402 | 2019-01-11 13:25:59 +0000 | [diff] [blame] | 586 | DECLARE_LAYER_POLICY_2_PARAM(PreCompiled) |
| 587 | |
Matteo Martincigh | 0e406ee | 2019-06-12 15:42:18 +0100 | [diff] [blame] | 588 | DECLARE_LAYER_POLICY_1_PARAM(Prelu) |
| 589 | |
James Conroy | 586a9aa | 2020-03-20 08:49:33 +0000 | [diff] [blame] | 590 | DECLARE_LAYER_POLICY_2_PARAM(QLstm) |
| 591 | |
James Conroy | ee18dc8 | 2019-07-17 11:27:46 +0100 | [diff] [blame] | 592 | DECLARE_LAYER_POLICY_1_PARAM(QuantizedLstm) |
| 593 | |
Francis Murtagh | e7a86a4 | 2018-08-29 12:42:10 +0100 | [diff] [blame] | 594 | DECLARE_LAYER_POLICY_1_PARAM(Division) |
| 595 | |
Teresa Charlin | a9075df | 2019-06-27 15:41:57 +0100 | [diff] [blame] | 596 | DECLARE_LAYER_POLICY_2_PARAM(Resize) |
| 597 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 598 | DECLARE_LAYER_POLICY_2_PARAM(Reshape) |
| 599 | |
Aron Virginas-Tar | 636ab40 | 2019-09-16 14:27:45 +0100 | [diff] [blame] | 600 | DECLARE_LAYER_POLICY_2_PARAM(Slice) |
| 601 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 602 | DECLARE_LAYER_POLICY_2_PARAM(Softmax) |
| 603 | |
Nattapat Chaimanowong | 207ef9a | 2018-11-02 10:57:25 +0000 | [diff] [blame] | 604 | DECLARE_LAYER_POLICY_2_PARAM(SpaceToBatchNd) |
| 605 | |
Aron Virginas-Tar | 972af15 | 2019-06-11 14:14:03 +0100 | [diff] [blame] | 606 | DECLARE_LAYER_POLICY_2_PARAM(SpaceToDepth) |
| 607 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 608 | DECLARE_LAYER_POLICY_2_PARAM(Splitter) |
| 609 | |
Matthew Jackson | 2b8c1da | 2019-07-04 14:59:16 +0100 | [diff] [blame] | 610 | DECLARE_LAYER_POLICY_2_PARAM(Stack) |
| 611 | |
Derek Lamberti | 013c390 | 2019-10-21 10:46:16 +0100 | [diff] [blame] | 612 | DECLARE_LAYER_POLICY_EXCEPTION_2_PARAM(StandIn) |
| 613 | |
Conor Kennedy | 430b5d8 | 2018-11-14 15:28:28 +0000 | [diff] [blame] | 614 | DECLARE_LAYER_POLICY_2_PARAM(StridedSlice) |
| 615 | |
David Beck | c2044fe | 2018-09-05 15:00:38 +0100 | [diff] [blame] | 616 | DECLARE_LAYER_POLICY_1_PARAM(Subtraction) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 617 | |
Sadik Armagan | eff363d | 2019-04-05 15:25:46 +0100 | [diff] [blame] | 618 | DECLARE_LAYER_POLICY_1_PARAM(Switch) |
| 619 | |
Mike Kelly | c9ea45a | 2020-02-28 18:11:58 +0000 | [diff] [blame] | 620 | DECLARE_LAYER_POLICY_2_PARAM(Transpose) |
| 621 | |
Aron Virginas-Tar | 639fb04 | 2019-06-20 14:28:19 +0100 | [diff] [blame] | 622 | DECLARE_LAYER_POLICY_2_PARAM(TransposeConvolution2d) |
| 623 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 624 | |
| 625 | // Generic implementation to get the number of input slots for a given layer type; |
| 626 | template<armnn::LayerType Type> |
| 627 | unsigned int GetNumInputs(const armnn::Layer& layer) |
| 628 | { |
| 629 | return layer.GetNumInputSlots(); |
| 630 | } |
| 631 | |
| 632 | // Generic implementation to get the number of output slots for a given layer type; |
| 633 | template<armnn::LayerType Type> |
| 634 | unsigned int GetNumOutputs(const armnn::Layer& layer) |
| 635 | { |
| 636 | return layer.GetNumOutputSlots(); |
| 637 | } |
| 638 | |
| 639 | template<> |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 640 | unsigned int GetNumInputs<armnn::LayerType::Concat>(const armnn::Layer& layer) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 641 | { |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 642 | IgnoreUnused(layer); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 643 | return 2; |
| 644 | } |
| 645 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 646 | // Tests that the IsLayerSupported() function returns the correct value. |
| 647 | // We determined the correct value by *trying* to create the relevant workload and seeing if it matches what we expect. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 648 | // Returns true if expectations are met, otherwise returns false. |
| 649 | template<typename FactoryType, armnn::DataType DataType, armnn::LayerType Type> |
| 650 | bool IsLayerSupportedTest(FactoryType *factory, Tag<Type>) |
| 651 | { |
| 652 | using LayerPolicy = LayerTypePolicy<Type, DataType>; |
| 653 | using LayerType = typename LayerPolicy::Type; |
| 654 | using LayerDesc = typename LayerPolicy::Desc; |
| 655 | DummyLayer<LayerType, LayerDesc> layer; |
| 656 | |
Derek Lamberti | b99ef39 | 2019-10-21 14:10:38 +0100 | [diff] [blame] | 657 | if (LayerPolicy::IsException) //Don't test exceptions to the rule. |
| 658 | { |
| 659 | return true; |
| 660 | } |
| 661 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 662 | unsigned int numIn = GetNumInputs<Type>(*layer.m_Layer); |
| 663 | unsigned int numOut = GetNumOutputs<Type>(*layer.m_Layer); |
| 664 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 665 | // Make another dummy layer just to make IsLayerSupported have valid inputs. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 666 | DummyLayer<armnn::ConstantLayer, void> previousLayer; |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 667 | // Set output of the previous layer to a dummy tensor. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 668 | armnn::TensorInfo output = MakeDummyTensorInfo<DataType>(); |
| 669 | previousLayer.m_Layer->GetOutputSlot(0).SetTensorInfo(output); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 670 | // Connect all outputs of the previous layer to inputs of tested layer. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 671 | for (unsigned int i = 0; i < numIn; i++) |
| 672 | { |
| 673 | armnn::IOutputSlot& previousLayerOutputSlot = previousLayer.m_Layer->GetOutputSlot(0); |
| 674 | armnn::IInputSlot& layerInputSlot = layer.m_Layer->GetInputSlot(i); |
| 675 | previousLayerOutputSlot.Connect(layerInputSlot); |
| 676 | } |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 677 | // Set outputs of tested layer to a dummy tensor. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 678 | for (unsigned int i = 0; i < numOut; i++) |
| 679 | { |
| 680 | layer.m_Layer->GetOutputSlot(0).SetTensorInfo(output); |
| 681 | } |
| 682 | |
| 683 | std::string layerName = LayerPolicy::NameStr; |
| 684 | std::string reasonIfUnsupported; |
| 685 | if (FactoryType::IsLayerSupported(*layer.m_Layer, DataType, reasonIfUnsupported)) |
| 686 | { |
| 687 | std::string errorMsg = " layer expected support but found none."; |
| 688 | try |
| 689 | { |
| 690 | bool retVal = LayerPolicy::MakeDummyWorkload(factory, numIn, numOut).get() != nullptr; |
Matteo Martincigh | fbebcbd | 2018-10-16 09:45:08 +0100 | [diff] [blame] | 691 | BOOST_CHECK_MESSAGE(retVal, layerName << errorMsg); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 692 | return retVal; |
| 693 | } |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 694 | catch(const armnn::InvalidArgumentException& e) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 695 | { |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 696 | IgnoreUnused(e); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 697 | // This is ok since we throw InvalidArgumentException when creating the dummy workload. |
| 698 | return true; |
| 699 | } |
| 700 | catch(const std::exception& e) |
| 701 | { |
| 702 | errorMsg = e.what(); |
| 703 | BOOST_TEST_ERROR(layerName << ": " << errorMsg); |
| 704 | return false; |
| 705 | } |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 706 | catch(...) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 707 | { |
| 708 | errorMsg = "Unexpected error while testing support for "; |
| 709 | BOOST_TEST_ERROR(errorMsg << layerName); |
| 710 | return false; |
| 711 | } |
| 712 | } |
| 713 | else |
| 714 | { |
| 715 | std::string errorMsg = "layer expected no support (giving reason: " + reasonIfUnsupported + ") but found some."; |
| 716 | try |
| 717 | { |
| 718 | bool retVal = LayerPolicy::MakeDummyWorkload(factory, numIn, numOut).get() == nullptr; |
| 719 | BOOST_CHECK_MESSAGE(retVal, layerName << errorMsg); |
| 720 | return retVal; |
| 721 | } |
| 722 | // These two exceptions are ok: For workloads that are partially supported, attempting to instantiate them |
| 723 | // using parameters that make IsLayerSupported() return false should throw an |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 724 | // InvalidArgumentException or UnimplementedException. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 725 | catch(const armnn::InvalidArgumentException& e) |
| 726 | { |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 727 | IgnoreUnused(e); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 728 | return true; |
| 729 | } |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 730 | catch(const armnn::UnimplementedException& e) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 731 | { |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 732 | IgnoreUnused(e); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 733 | return true; |
| 734 | } |
| 735 | catch(const std::exception& e) |
| 736 | { |
| 737 | errorMsg = e.what(); |
| 738 | BOOST_TEST_ERROR(layerName << ": " << errorMsg); |
| 739 | return false; |
| 740 | } |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 741 | catch(...) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 742 | { |
| 743 | errorMsg = "Unexpected error while testing support for "; |
| 744 | BOOST_TEST_ERROR(errorMsg << layerName); |
| 745 | return false; |
| 746 | } |
| 747 | } |
| 748 | } |
| 749 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 750 | // Helper function to compute the next type in the LayerType enum. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 751 | constexpr armnn::LayerType NextType(armnn::LayerType type) |
| 752 | { |
| 753 | return static_cast<armnn::LayerType>(static_cast<int>(type)+1); |
| 754 | } |
| 755 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 756 | // Termination function for determining the end of the LayerType enumeration. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 757 | template<typename FactoryType, armnn::DataType DataType, armnn::LayerType Type> |
| 758 | bool IsLayerSupportedTestsImpl(FactoryType *factory, Tag<armnn::LayerType::LastLayer>) |
| 759 | { |
| 760 | return IsLayerSupportedTest<FactoryType, DataType, Type>(factory, Tag<Type>()); |
Matteo Martincigh | 59a950c | 2018-12-13 12:48:25 +0000 | [diff] [blame] | 761 | } |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 762 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 763 | // Recursive function to test and enter in the LayerType enum and then iterate on the next entry. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 764 | template<typename FactoryType, armnn::DataType DataType, armnn::LayerType Type> |
| 765 | bool IsLayerSupportedTestsImpl(FactoryType *factory, Tag<Type>) |
| 766 | { |
| 767 | bool v = IsLayerSupportedTest<FactoryType, DataType, Type>(factory, Tag<Type>()); |
| 768 | |
| 769 | return v && |
| 770 | IsLayerSupportedTestsImpl<FactoryType, DataType, NextType(Type)> |
| 771 | (factory, Tag<NextType(Type)>()); |
Matteo Martincigh | 59a950c | 2018-12-13 12:48:25 +0000 | [diff] [blame] | 772 | } |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 773 | |
| 774 | // Helper function to pass through to the test framework. |
| 775 | template<typename FactoryType, armnn::DataType DataType> |
| 776 | bool IsLayerSupportedTests(FactoryType *factory) |
| 777 | { |
| 778 | return IsLayerSupportedTestsImpl<FactoryType, DataType>(factory, Tag<armnn::LayerType::FirstLayer>()); |
Matteo Martincigh | 59a950c | 2018-12-13 12:48:25 +0000 | [diff] [blame] | 779 | } |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 780 | |
| 781 | template<armnn::LayerType Type> |
| 782 | bool TestLayerTypeMatches() |
| 783 | { |
| 784 | using LayerPolicy = LayerTypePolicy<Type, armnn::DataType::Float32>; |
| 785 | using LayerType = typename LayerPolicy::Type; |
| 786 | using LayerDesc = typename LayerPolicy::Desc; |
| 787 | DummyLayer<LayerType, LayerDesc> layer; |
| 788 | |
| 789 | std::stringstream ss; |
| 790 | ss << LayerPolicy::NameStr << " layer type mismatches expected layer type value."; |
| 791 | bool v = Type == layer.m_Layer->GetType(); |
| 792 | BOOST_CHECK_MESSAGE(v, ss.str()); |
| 793 | return v; |
Matteo Martincigh | 59a950c | 2018-12-13 12:48:25 +0000 | [diff] [blame] | 794 | } |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 795 | |
| 796 | template<armnn::LayerType Type> |
| 797 | bool LayerTypeMatchesTestImpl(Tag<armnn::LayerType::LastLayer>) |
| 798 | { |
| 799 | return TestLayerTypeMatches<Type>(); |
Matteo Martincigh | 59a950c | 2018-12-13 12:48:25 +0000 | [diff] [blame] | 800 | } |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 801 | |
| 802 | template<armnn::LayerType Type> |
| 803 | bool LayerTypeMatchesTestImpl(Tag<Type>) |
| 804 | { |
| 805 | return TestLayerTypeMatches<Type>() && |
| 806 | LayerTypeMatchesTestImpl<NextType(Type)>(Tag<NextType(Type)>()); |
Matteo Martincigh | 59a950c | 2018-12-13 12:48:25 +0000 | [diff] [blame] | 807 | } |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 808 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 809 | template<typename FactoryType, typename LayerType, armnn::DataType InputDataType , armnn::DataType OutputDataType> |
| 810 | bool IsConvertLayerSupportedTests(std::string& reasonIfUnsupported) |
| 811 | { |
| 812 | armnn::Graph graph; |
| 813 | LayerType* const layer = graph.AddLayer<LayerType>("LayerName"); |
| 814 | |
| 815 | armnn::Layer* const input = graph.AddLayer<armnn::InputLayer>(0, "input"); |
| 816 | armnn::Layer* const output = graph.AddLayer<armnn::OutputLayer>(0, "output"); |
| 817 | |
| 818 | armnn::TensorInfo inputTensorInfo({1, 3, 2, 3}, InputDataType); |
| 819 | armnn::TensorInfo outputTensorInfo({1, 3, 2, 3}, OutputDataType); |
| 820 | |
| 821 | input->GetOutputSlot(0).Connect(layer->GetInputSlot(0)); |
| 822 | input->GetOutputHandler(0).SetTensorInfo(inputTensorInfo); |
| 823 | layer->GetOutputSlot(0).Connect(output->GetInputSlot(0)); |
| 824 | layer->GetOutputHandler(0).SetTensorInfo(outputTensorInfo); |
| 825 | |
| 826 | bool result = FactoryType::IsLayerSupported(*layer, InputDataType, reasonIfUnsupported); |
| 827 | |
| 828 | return result; |
Matteo Martincigh | 59a950c | 2018-12-13 12:48:25 +0000 | [diff] [blame] | 829 | } |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 830 | |
Matthew Bentham | 1f0ff35 | 2019-01-02 13:26:31 +0000 | [diff] [blame] | 831 | template<typename FactoryType, armnn::DataType InputDataType , armnn::DataType OutputDataType> |
| 832 | bool IsMeanLayerSupportedTests(std::string& reasonIfUnsupported) |
| 833 | { |
| 834 | armnn::Graph graph; |
| 835 | static const std::vector<unsigned> axes = {1, 0}; |
| 836 | armnn::MeanDescriptor desc(axes, false); |
| 837 | |
| 838 | armnn::Layer* const layer = graph.AddLayer<armnn::MeanLayer>(desc, "LayerName"); |
| 839 | |
| 840 | armnn::Layer* const input = graph.AddLayer<armnn::InputLayer>(0, "input"); |
| 841 | armnn::Layer* const output = graph.AddLayer<armnn::OutputLayer>(0, "output"); |
| 842 | |
| 843 | armnn::TensorInfo inputTensorInfo({4, 3, 2}, InputDataType); |
| 844 | armnn::TensorInfo outputTensorInfo({2}, OutputDataType); |
| 845 | |
| 846 | input->GetOutputSlot(0).Connect(layer->GetInputSlot(0)); |
| 847 | input->GetOutputHandler(0).SetTensorInfo(inputTensorInfo); |
| 848 | layer->GetOutputSlot(0).Connect(output->GetInputSlot(0)); |
| 849 | layer->GetOutputHandler(0).SetTensorInfo(outputTensorInfo); |
| 850 | |
| 851 | bool result = FactoryType::IsLayerSupported(*layer, InputDataType, reasonIfUnsupported); |
| 852 | |
| 853 | return result; |
| 854 | } |
| 855 | |
James Conroy | 4d1ff58 | 2019-06-10 17:06:39 +0100 | [diff] [blame] | 856 | // Tests that IsMeanSupported fails when input tensor dimensions |
| 857 | // do not match output tensor dimensions when keepDims == true |
| 858 | template<typename FactoryType, armnn::DataType InputDataType , armnn::DataType OutputDataType> |
| 859 | bool IsMeanLayerNotSupportedTests(std::string& reasonIfUnsupported) |
| 860 | { |
| 861 | armnn::Graph graph; |
| 862 | static const std::vector<unsigned> axes = {}; |
| 863 | // Set keepDims == true |
| 864 | armnn::MeanDescriptor desc(axes, true); |
| 865 | |
| 866 | armnn::Layer* const layer = graph.AddLayer<armnn::MeanLayer>(desc, "LayerName"); |
| 867 | |
| 868 | armnn::Layer* const input = graph.AddLayer<armnn::InputLayer>(0, "input"); |
| 869 | armnn::Layer* const output = graph.AddLayer<armnn::OutputLayer>(0, "output"); |
| 870 | |
| 871 | // Mismatching number of tensor dimensions |
| 872 | armnn::TensorInfo inputTensorInfo({1, 1, 1, 1}, InputDataType); |
| 873 | armnn::TensorInfo outputTensorInfo({1, 1}, OutputDataType); |
| 874 | |
| 875 | input->GetOutputSlot(0).Connect(layer->GetInputSlot(0)); |
| 876 | input->GetOutputHandler(0).SetTensorInfo(inputTensorInfo); |
| 877 | layer->GetOutputSlot(0).Connect(output->GetInputSlot(0)); |
| 878 | layer->GetOutputHandler(0).SetTensorInfo(outputTensorInfo); |
| 879 | |
| 880 | bool result = FactoryType::IsLayerSupported(*layer, InputDataType, reasonIfUnsupported); |
| 881 | |
| 882 | return result; |
| 883 | } |
| 884 | |
Mike Kelly | 0886ac4 | 2020-04-27 09:55:40 +0100 | [diff] [blame] | 885 | template<typename FactoryType, armnn::DataType OutputDataType> |
| 886 | bool IsConstantLayerSupportedTests(std::string& reasonIfUnsupported) |
| 887 | { |
| 888 | armnn::Graph graph; |
| 889 | |
| 890 | armnn::Layer* const layer = graph.AddLayer<armnn::ConstantLayer>("ConstantLayerName"); |
| 891 | armnn::Layer* const output = graph.AddLayer<armnn::OutputLayer>(0, "OutputLayerName"); |
| 892 | |
| 893 | armnn::TensorInfo outputTensorInfo({1, 1}, OutputDataType); |
| 894 | |
| 895 | layer->GetOutputSlot(0).Connect(output->GetInputSlot(0)); |
| 896 | layer->GetOutputHandler(0).SetTensorInfo(outputTensorInfo); |
| 897 | |
| 898 | bool result = FactoryType::IsLayerSupported(*layer, OutputDataType, reasonIfUnsupported); |
| 899 | |
| 900 | return result; |
| 901 | } |
Matthew Bentham | 1f0ff35 | 2019-01-02 13:26:31 +0000 | [diff] [blame] | 902 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 903 | } //namespace |