blob: fb88d559bbaf6d466915ef100b8e52928de6df48 [file] [log] [blame]
Derek Lamberti27d83072019-02-05 16:00:08 +00001//
Teresa Charlin52664732020-06-29 16:27:03 +01002// Copyright © 2017 Arm Ltd and Contributors. All rights reserved.
Derek Lamberti27d83072019-02-05 16:00:08 +00003// SPDX-License-Identifier: MIT
4//
5
6#pragma once
7
8#include <armnn/ILayerVisitor.hpp>
9
10namespace armnn
11{
12
Derek Lamberti7205fed2019-02-06 16:20:46 +000013struct VisitorThrowingPolicy
14{
Les Belle0ca8612019-05-17 16:17:12 +010015 static void Apply(const std::string& errorMessage = "") { throw UnimplementedException(errorMessage); }
Derek Lamberti7205fed2019-02-06 16:20:46 +000016};
17
18struct VisitorNoThrowPolicy
19{
Matteo Martincigh0b679f02019-06-17 13:25:18 +010020 static void Apply(const std::string&) {}
Derek Lamberti7205fed2019-02-06 16:20:46 +000021};
22
Ryan OShea2bbfaa72020-02-12 16:15:27 +000023/// Visitor base class with empty implementations.
Derek Lamberti7205fed2019-02-06 16:20:46 +000024template<typename DefaultPolicy>
Derek Lamberti27d83072019-02-05 16:00:08 +000025class LayerVisitorBase : public ILayerVisitor
26{
27protected:
28 LayerVisitorBase() {}
29 virtual ~LayerVisitorBase() {}
30
31public:
Kevin May868eb142019-09-04 17:29:31 +010032 void VisitAbsLayer(const IConnectableLayer*,
33 const char*) override { DefaultPolicy::Apply(__func__); }
Derek Lamberti27d83072019-02-05 16:00:08 +000034
Aron Virginas-Tar00859782019-02-11 12:21:27 +000035 void VisitActivationLayer(const IConnectableLayer*,
36 const ActivationDescriptor&,
Les Belle0ca8612019-05-17 16:17:12 +010037 const char*) override { DefaultPolicy::Apply(__func__); }
Derek Lamberti27d83072019-02-05 16:00:08 +000038
Aron Virginas-Tar00859782019-02-11 12:21:27 +000039 void VisitAdditionLayer(const IConnectableLayer*,
Les Belle0ca8612019-05-17 16:17:12 +010040 const char*) override { DefaultPolicy::Apply(__func__); }
Derek Lamberti27d83072019-02-05 16:00:08 +000041
Nikhil Rajee391d52019-09-05 17:50:44 +010042 void VisitArgMinMaxLayer(const IConnectableLayer*,
43 const ArgMinMaxDescriptor&,
44 const char*) override { DefaultPolicy::Apply(__func__); }
45
Aron Virginas-Tar00859782019-02-11 12:21:27 +000046 void VisitBatchNormalizationLayer(const IConnectableLayer*,
47 const BatchNormalizationDescriptor&,
48 const ConstTensor&,
49 const ConstTensor&,
50 const ConstTensor&,
51 const ConstTensor&,
Les Belle0ca8612019-05-17 16:17:12 +010052 const char*) override { DefaultPolicy::Apply(__func__); }
Derek Lamberti27d83072019-02-05 16:00:08 +000053
Les Belle0ca8612019-05-17 16:17:12 +010054 void VisitBatchToSpaceNdLayer(const IConnectableLayer*,
55 const BatchToSpaceNdDescriptor&,
56 const char*) override { DefaultPolicy::Apply(__func__); }
Derek Lamberti27d83072019-02-05 16:00:08 +000057
Aron Virginas-Tar77bfb5e2019-10-16 17:45:38 +010058 void VisitComparisonLayer(const IConnectableLayer*,
59 const ComparisonDescriptor&,
60 const char*) override { DefaultPolicy::Apply(__func__); }
61
Les Belle0ca8612019-05-17 16:17:12 +010062 void VisitConcatLayer(const IConnectableLayer*,
Jim Flynne242f2d2019-05-22 14:24:13 +010063 const ConcatDescriptor&,
Les Belle0ca8612019-05-17 16:17:12 +010064 const char*) override { DefaultPolicy::Apply(__func__); }
Derek Lamberti27d83072019-02-05 16:00:08 +000065
Aron Virginas-Tar00859782019-02-11 12:21:27 +000066 void VisitConstantLayer(const IConnectableLayer*,
67 const ConstTensor&,
Les Belle0ca8612019-05-17 16:17:12 +010068 const char*) override { DefaultPolicy::Apply(__func__); }
Derek Lamberti27d83072019-02-05 16:00:08 +000069
Les Belle0ca8612019-05-17 16:17:12 +010070 void VisitConvolution2dLayer(const IConnectableLayer*,
71 const Convolution2dDescriptor&,
72 const ConstTensor&,
73 const Optional<ConstTensor>&,
74 const char*) override { DefaultPolicy::Apply(__func__); }
Derek Lamberti27d83072019-02-05 16:00:08 +000075
Aron Virginas-Tardd6247f2019-09-19 14:31:17 +010076 void VisitDepthToSpaceLayer(const IConnectableLayer*,
77 const DepthToSpaceDescriptor&,
78 const char*) override { DefaultPolicy::Apply(__func__); }
79
Les Belle0ca8612019-05-17 16:17:12 +010080 void VisitDepthwiseConvolution2dLayer(const IConnectableLayer*,
81 const DepthwiseConvolution2dDescriptor&,
82 const ConstTensor&,
83 const Optional<ConstTensor>&,
84 const char*) override { DefaultPolicy::Apply(__func__); }
85
86 void VisitDequantizeLayer(const IConnectableLayer*,
87 const char*) override { DefaultPolicy::Apply(__func__); }
88
89 void VisitDetectionPostProcessLayer(const IConnectableLayer*,
90 const DetectionPostProcessDescriptor&,
91 const ConstTensor&,
92 const char*) override { DefaultPolicy::Apply(__func__); }
93
94 void VisitDivisionLayer(const IConnectableLayer*,
95 const char*) override { DefaultPolicy::Apply(__func__); }
96
josh minor4a3c6102020-01-06 16:40:46 -060097 void VisitElementwiseUnaryLayer(const IConnectableLayer*,
98 const ElementwiseUnaryDescriptor&,
99 const char*) override { DefaultPolicy::Apply(__func__); }
100
Les Belle0ca8612019-05-17 16:17:12 +0100101 void VisitEqualLayer(const IConnectableLayer*,
102 const char*) override { DefaultPolicy::Apply(__func__); }
Derek Lamberti27d83072019-02-05 16:00:08 +0000103
Ryan OSheaec6c6802020-06-05 17:17:06 +0100104 void VisitFillLayer(const IConnectableLayer*,
105 const FillDescriptor&,
106 const char*) override { DefaultPolicy::Apply(__func__); }
107
Aron Virginas-Tar00859782019-02-11 12:21:27 +0000108 void VisitFloorLayer(const IConnectableLayer*,
Les Belle0ca8612019-05-17 16:17:12 +0100109 const char*) override { DefaultPolicy::Apply(__func__); }
Derek Lamberti7205fed2019-02-06 16:20:46 +0000110
Les Belle0ca8612019-05-17 16:17:12 +0100111 void VisitFullyConnectedLayer(const IConnectableLayer*,
112 const FullyConnectedDescriptor&,
113 const ConstTensor&,
114 const Optional<ConstTensor>&,
115 const char*) override { DefaultPolicy::Apply(__func__); }
116
Teresa Charlin52664732020-06-29 16:27:03 +0100117 ARMNN_DEPRECATED_MSG("Use VisitGatherLayer with descriptor instead")
Les Belle0ca8612019-05-17 16:17:12 +0100118 void VisitGatherLayer(const IConnectableLayer*,
119 const char*) override { DefaultPolicy::Apply(__func__); }
120
Teresa Charlin52664732020-06-29 16:27:03 +0100121 void VisitGatherLayer(const IConnectableLayer*,
122 const GatherDescriptor&,
123 const char*) override { DefaultPolicy::Apply(__func__); }
124
Les Belle0ca8612019-05-17 16:17:12 +0100125 void VisitGreaterLayer(const IConnectableLayer*,
126 const char*) override { DefaultPolicy::Apply(__func__); }
127
128 void VisitInputLayer(const IConnectableLayer*,
129 LayerBindingId,
130 const char*) override { DefaultPolicy::Apply(__func__); }
131
Kevin Mayce5045a2019-10-02 14:07:47 +0100132 void VisitInstanceNormalizationLayer(const IConnectableLayer*,
133 const InstanceNormalizationDescriptor&,
134 const char*) override { DefaultPolicy::Apply(__func__); }
135
Les Belle0ca8612019-05-17 16:17:12 +0100136 void VisitL2NormalizationLayer(const IConnectableLayer*,
137 const L2NormalizationDescriptor&,
138 const char*) override { DefaultPolicy::Apply(__func__); }
Derek Lamberti7205fed2019-02-06 16:20:46 +0000139
Aron Virginas-Tarf982dea2019-10-11 14:07:53 +0100140 void VisitLogSoftmaxLayer(const IConnectableLayer*,
141 const LogSoftmaxDescriptor&,
142 const char*) override { DefaultPolicy::Apply(__func__); }
143
James Conroyaba90cd2020-11-06 16:28:18 +0000144 void VisitLogicalBinaryLayer(const IConnectableLayer*,
145 const LogicalBinaryDescriptor&,
146 const char*) override {DefaultPolicy::Apply(__func__); }
147
Aron Virginas-Tar00859782019-02-11 12:21:27 +0000148 void VisitLstmLayer(const IConnectableLayer*,
149 const LstmDescriptor&,
150 const LstmInputParams&,
Les Belle0ca8612019-05-17 16:17:12 +0100151 const char*) override { DefaultPolicy::Apply(__func__); }
Derek Lamberti7205fed2019-02-06 16:20:46 +0000152
Aron Virginas-Tar00859782019-02-11 12:21:27 +0000153 void VisitMaximumLayer(const IConnectableLayer*,
Les Belle0ca8612019-05-17 16:17:12 +0100154 const char*) override { DefaultPolicy::Apply(__func__); }
Derek Lamberti7205fed2019-02-06 16:20:46 +0000155
Aron Virginas-Tar00859782019-02-11 12:21:27 +0000156 void VisitMeanLayer(const IConnectableLayer*,
157 const MeanDescriptor&,
Les Belle0ca8612019-05-17 16:17:12 +0100158 const char*) override { DefaultPolicy::Apply(__func__); }
159
160 void VisitMergeLayer(const IConnectableLayer*,
161 const char*) override { DefaultPolicy::Apply(__func__); }
162
163 void VisitMergerLayer(const IConnectableLayer*,
Jim Flynne242f2d2019-05-22 14:24:13 +0100164 const MergerDescriptor&,
Les Belle0ca8612019-05-17 16:17:12 +0100165 const char*) override { DefaultPolicy::Apply(__func__); }
166
167 void VisitMinimumLayer(const IConnectableLayer*,
168 const char*) override { DefaultPolicy::Apply(__func__); }
169
170 void VisitMultiplicationLayer(const IConnectableLayer*,
171 const char*) override { DefaultPolicy::Apply(__func__); }
172
173 void VisitNormalizationLayer(const IConnectableLayer*,
174 const NormalizationDescriptor&,
175 const char*) override { DefaultPolicy::Apply(__func__); }
176
177 void VisitOutputLayer(const IConnectableLayer*,
Matteo Martincigh0b679f02019-06-17 13:25:18 +0100178 LayerBindingId,
Les Belle0ca8612019-05-17 16:17:12 +0100179 const char*) override { DefaultPolicy::Apply(__func__); }
Derek Lamberti7205fed2019-02-06 16:20:46 +0000180
Aron Virginas-Tar00859782019-02-11 12:21:27 +0000181 void VisitPadLayer(const IConnectableLayer*,
182 const PadDescriptor&,
Les Belle0ca8612019-05-17 16:17:12 +0100183 const char*) override { DefaultPolicy::Apply(__func__); }
184
185 void VisitPermuteLayer(const IConnectableLayer*,
186 const PermuteDescriptor&,
187 const char*) override { DefaultPolicy::Apply(__func__); }
188
189 void VisitPooling2dLayer(const IConnectableLayer*,
190 const Pooling2dDescriptor&,
191 const char*) override { DefaultPolicy::Apply(__func__); }
Derek Lamberti7205fed2019-02-06 16:20:46 +0000192
Matteo Martincigh0e406ee2019-06-12 15:42:18 +0100193 void VisitPreluLayer(const IConnectableLayer*,
194 const char*) override { DefaultPolicy::Apply(__func__); }
195
Derek Lambertia9cca6a2019-03-25 15:41:58 +0000196 void VisitQuantizeLayer(const IConnectableLayer*,
Les Belle0ca8612019-05-17 16:17:12 +0100197 const char*) override { DefaultPolicy::Apply(__func__); }
198
James Conroy586a9aa2020-03-20 08:49:33 +0000199 void VisitQLstmLayer(const IConnectableLayer*,
200 const QLstmDescriptor&,
201 const LstmInputParams&,
202 const char*) override { DefaultPolicy::Apply(__func__); }
203
James Conroyee18dc82019-07-17 11:27:46 +0100204 void VisitQuantizedLstmLayer(const IConnectableLayer*,
205 const QuantizedLstmInputParams&,
206 const char*) override { DefaultPolicy::Apply(__func__); }
207
Finn Williams2605b232020-06-10 15:53:46 +0100208 void VisitRankLayer(const IConnectableLayer*,
209 const char*) override { DefaultPolicy::Apply(__func__); }
210
Sadik Armagan0c3ea5b2021-02-03 09:29:30 +0000211 void VisitReduceLayer(const IConnectableLayer*,
212 const ReduceDescriptor&,
213 const char*) override { DefaultPolicy::Apply(__func__); }
214
Les Belle0ca8612019-05-17 16:17:12 +0100215 void VisitReshapeLayer(const IConnectableLayer*,
216 const ReshapeDescriptor&,
217 const char*) override { DefaultPolicy::Apply(__func__); }
218
219 void VisitResizeBilinearLayer(const IConnectableLayer*,
220 const ResizeBilinearDescriptor&,
221 const char*) override { DefaultPolicy::Apply(__func__); }
222
Teresa Charlina9075df2019-06-27 15:41:57 +0100223 void VisitResizeLayer(const IConnectableLayer*,
224 const ResizeDescriptor&,
225 const char*) override { DefaultPolicy::Apply(__func__); }
226
Les Belle0ca8612019-05-17 16:17:12 +0100227 void VisitRsqrtLayer(const IConnectableLayer*,
228 const char*) override { DefaultPolicy::Apply(__func__); }
229
Aron Virginas-Tar636ab402019-09-16 14:27:45 +0100230 void VisitSliceLayer(const IConnectableLayer*,
231 const SliceDescriptor&,
232 const char*) override { DefaultPolicy::Apply(__func__); }
233
Les Belle0ca8612019-05-17 16:17:12 +0100234 void VisitSoftmaxLayer(const IConnectableLayer*,
235 const SoftmaxDescriptor&,
236 const char*) override { DefaultPolicy::Apply(__func__); }
237
238 void VisitSpaceToBatchNdLayer(const IConnectableLayer*,
239 const SpaceToBatchNdDescriptor&,
240 const char*) override { DefaultPolicy::Apply(__func__); }
241
Aron Virginas-Tar972af152019-06-11 14:14:03 +0100242 void VisitSpaceToDepthLayer(const IConnectableLayer*,
243 const SpaceToDepthDescriptor&,
244 const char*) override { DefaultPolicy::Apply(__func__); }
245
Les Belle0ca8612019-05-17 16:17:12 +0100246 void VisitSplitterLayer(const IConnectableLayer*,
247 const ViewsDescriptor&,
248 const char*) override { DefaultPolicy::Apply(__func__); }
Derek Lambertia9cca6a2019-03-25 15:41:58 +0000249
Matthew Jackson2b8c1da2019-07-04 14:59:16 +0100250 void VisitStackLayer(const IConnectableLayer*,
251 const StackDescriptor&,
252 const char*) override { DefaultPolicy::Apply(__func__); }
253
Derek Lamberti013c3902019-10-21 10:46:16 +0100254 void VisitStandInLayer(const IConnectableLayer*,
255 const StandInDescriptor&,
256 const char*) override { DefaultPolicy::Apply(__func__); }
257
Aron Virginas-Tar00859782019-02-11 12:21:27 +0000258 void VisitStridedSliceLayer(const IConnectableLayer*,
259 const StridedSliceDescriptor&,
Les Belle0ca8612019-05-17 16:17:12 +0100260 const char*) override { DefaultPolicy::Apply(__func__); }
Derek Lamberti7205fed2019-02-06 16:20:46 +0000261
Les Belle0ca8612019-05-17 16:17:12 +0100262 void VisitSubtractionLayer(const IConnectableLayer*,
263 const char*) override { DefaultPolicy::Apply(__func__); }
Sadik Armaganeff363d2019-04-05 15:25:46 +0100264
265 void VisitSwitchLayer(const IConnectableLayer*,
Les Belle0ca8612019-05-17 16:17:12 +0100266 const char*) override { DefaultPolicy::Apply(__func__); }
Aron Virginas-Tar639fb042019-06-20 14:28:19 +0100267
268 void VisitTransposeConvolution2dLayer(const IConnectableLayer*,
269 const TransposeConvolution2dDescriptor&,
270 const ConstTensor&,
271 const Optional<ConstTensor>&,
272 const char*) override { DefaultPolicy::Apply(__func__); }
273
Mike Kellyc9ea45a2020-02-28 18:11:58 +0000274 void VisitTransposeLayer(const IConnectableLayer*,
275 const TransposeDescriptor&,
276 const char*) override { DefaultPolicy::Apply(__func__); }
277
Derek Lamberti27d83072019-02-05 16:00:08 +0000278};
279
Aron Virginas-Tar639fb042019-06-20 14:28:19 +0100280} // namespace armnn