jimfly01 | 5f4e41f | 2019-01-23 16:10:17 +0000 | [diff] [blame] | 1 | // |
| 2 | // Copyright © 2017 Arm Ltd. All rights reserved. |
| 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | #pragma once |
| 6 | |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 7 | #include <armnn/Deprecated.hpp> |
jimfly01 | 5f4e41f | 2019-01-23 16:10:17 +0000 | [diff] [blame] | 8 | #include <armnn/DescriptorsFwd.hpp> |
Matthew Bentham | 313e1c8 | 2019-03-25 17:37:47 +0000 | [diff] [blame] | 9 | #include <armnn/NetworkFwd.hpp> |
Aron Virginas-Tar | 0085978 | 2019-02-11 12:21:27 +0000 | [diff] [blame] | 10 | #include <armnn/Optional.hpp> |
jimfly01 | 5f4e41f | 2019-01-23 16:10:17 +0000 | [diff] [blame] | 11 | #include <armnn/TensorFwd.hpp> |
| 12 | #include <armnn/Types.hpp> |
| 13 | |
| 14 | namespace armnn |
| 15 | { |
| 16 | class ILayerVisitor |
| 17 | { |
jimfly01 | e9e7bfd | 2019-01-24 22:29:33 +0000 | [diff] [blame] | 18 | protected: |
| 19 | ILayerVisitor() {} |
| 20 | virtual ~ILayerVisitor() {} |
| 21 | |
jimfly01 | 5f4e41f | 2019-01-23 16:10:17 +0000 | [diff] [blame] | 22 | public: |
Kevin May | 868eb14 | 2019-09-04 17:29:31 +0100 | [diff] [blame] | 23 | /// Function an absolute layer should call back to when its Accept(ILayerVisitor&) |
| 24 | /// function is invoked. |
| 25 | /// @param layer - pointer to the layer which is calling back to this visit function. |
| 26 | /// @param name - Optional name for the layer. |
| 27 | virtual void VisitAbsLayer(const IConnectableLayer* layer, |
| 28 | const char* name = nullptr) = 0; |
| 29 | |
Derek Lamberti | 61f5463 | 2019-03-25 16:28:44 +0000 | [diff] [blame] | 30 | /// Function that an activation layer should call back to when its Accept(ILayerVisitor&) function is invoked. |
jimfly01 | 5f4e41f | 2019-01-23 16:10:17 +0000 | [diff] [blame] | 31 | /// @param layer - pointer to the layer which is calling back to this visit function. |
Derek Lamberti | 61f5463 | 2019-03-25 16:28:44 +0000 | [diff] [blame] | 32 | /// @param activationDescriptor - ActivationDescriptor to configure the activation. |
jimfly01 | 5f4e41f | 2019-01-23 16:10:17 +0000 | [diff] [blame] | 33 | /// @param name - Optional name for the layer. |
Derek Lamberti | 61f5463 | 2019-03-25 16:28:44 +0000 | [diff] [blame] | 34 | virtual void VisitActivationLayer(const IConnectableLayer* layer, |
| 35 | const ActivationDescriptor& activationDescriptor, |
| 36 | const char* name = nullptr) = 0; |
| 37 | |
| 38 | /// Function that an addition layer should call back to when its Accept(ILayerVisitor&) function is invoked. |
| 39 | /// @param layer - pointer to the layer which is calling back to this visit function. |
| 40 | /// @param name - Optional name for the layer. |
| 41 | virtual void VisitAdditionLayer(const IConnectableLayer* layer, |
| 42 | const char* name = nullptr) = 0; |
| 43 | |
Nikhil Raj | ee391d5 | 2019-09-05 17:50:44 +0100 | [diff] [blame] | 44 | /// Function that an arg min max layer should call back to when its Accept(ILayerVisitor&) function is invoked. |
| 45 | /// @param layer - pointer to the layer which is calling back to this visit function. |
| 46 | /// @param argMinMaxDescriptor - ArgMinMaxDescriptor to configure the activation. |
| 47 | /// @param name - Optional name for the layer. |
| 48 | virtual void VisitArgMinMaxLayer(const IConnectableLayer* layer, |
| 49 | const ArgMinMaxDescriptor& argMinMaxDescriptor, |
| 50 | const char* name = nullptr) = 0; |
| 51 | |
Derek Lamberti | 61f5463 | 2019-03-25 16:28:44 +0000 | [diff] [blame] | 52 | /// Function that a batch normalization layer should call back to when its Accept(ILayerVisitor&) |
| 53 | /// function is invoked. |
| 54 | /// @param layer - pointer to the layer which is calling back to this visit function. |
| 55 | /// @param mean - Pre-calculated mean for each channel. |
| 56 | /// @param variance - Pre-calculated variance for each channel. |
| 57 | /// @param beta - Per-channel additive factor. |
| 58 | /// @param gamma - Per-channel multiplicative factor. |
| 59 | /// @param name - Optional name for the layer. |
| 60 | virtual void VisitBatchNormalizationLayer(const IConnectableLayer* layer, |
| 61 | const BatchNormalizationDescriptor& desc, |
| 62 | const ConstTensor& mean, |
| 63 | const ConstTensor& variance, |
| 64 | const ConstTensor& beta, |
| 65 | const ConstTensor& gamma, |
| 66 | const char* name = nullptr) = 0; |
| 67 | |
| 68 | /// Function that a batch to space ND layer should call back to when its Accept(ILayerVisitor&) |
| 69 | /// function is invoked. |
| 70 | /// @param layer - pointer to the layer which is calling back to this visit function. |
| 71 | /// @param batchToSpaceNdDescriptor - Description of the layer. |
| 72 | /// @param name - Optional name for the layer. |
| 73 | virtual void VisitBatchToSpaceNdLayer(const IConnectableLayer* layer, |
| 74 | const BatchToSpaceNdDescriptor& batchToSpaceNdDescriptor, |
| 75 | const char* name = nullptr) = 0; |
| 76 | |
Jim Flynn | 906f946 | 2019-05-10 13:55:21 +0100 | [diff] [blame] | 77 | /// Function that a concat layer should call back to when its Accept(ILayerVisitor&) function is invoked. |
| 78 | /// @param layer - pointer to the layer which is calling back to this visit function. |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 79 | /// @param concatDescriptor - ConcatDescriptor (synonym for OriginsDescriptor) to configure the concatenation |
| 80 | /// process. Number of Views must be equal to the number of inputs, and their order |
| 81 | /// must match - e.g. first view corresponds to the first input, second view to the |
| 82 | /// second input, etc.... |
Jim Flynn | 906f946 | 2019-05-10 13:55:21 +0100 | [diff] [blame] | 83 | /// @param name - Optional name for the layer. |
| 84 | virtual void VisitConcatLayer(const IConnectableLayer* layer, |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 85 | const OriginsDescriptor& concatDescriptor, |
Jim Flynn | 906f946 | 2019-05-10 13:55:21 +0100 | [diff] [blame] | 86 | const char* name = nullptr) |
| 87 | { |
| 88 | // default implementation to ease transition while MergerLayer is being deprecated |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 89 | ARMNN_NO_DEPRECATE_WARN_BEGIN |
| 90 | VisitMergerLayer(layer, concatDescriptor, name); |
| 91 | ARMNN_NO_DEPRECATE_WARN_END |
Jim Flynn | 906f946 | 2019-05-10 13:55:21 +0100 | [diff] [blame] | 92 | } |
| 93 | |
Derek Lamberti | 61f5463 | 2019-03-25 16:28:44 +0000 | [diff] [blame] | 94 | /// Function a layer with no inputs and a single output, which always corresponds to |
| 95 | /// the passed in constant tensor should call back to when its Accept(ILayerVisitor&) function is invoked. |
| 96 | /// @param layer - pointer to the layer which is calling back to this visit function. |
| 97 | /// @param input - Tensor to be provided as the only output of the layer. The layer will maintain |
| 98 | /// its own copy of the tensor data, meaning the memory referenced by @a input can |
| 99 | /// be freed or reused after this function is called. |
| 100 | /// @param name - Optional name for the layer. |
| 101 | virtual void VisitConstantLayer(const IConnectableLayer* layer, |
| 102 | const ConstTensor& input, |
| 103 | const char* name = nullptr) = 0; |
jimfly01 | 5f4e41f | 2019-01-23 16:10:17 +0000 | [diff] [blame] | 104 | |
Aron Virginas-Tar | 0085978 | 2019-02-11 12:21:27 +0000 | [diff] [blame] | 105 | /// Function that a 2D convolution layer should call back to when its Accept(ILayerVisitor&) |
jimfly01 | 5f4e41f | 2019-01-23 16:10:17 +0000 | [diff] [blame] | 106 | /// function is invoked. |
| 107 | /// @param layer - pointer to the layer which is calling back to this visit function. |
| 108 | /// @param convolution2dDescriptor - Description of the 2D convolution layer. |
| 109 | /// @param weights - Tensor for the weights data. |
Aron Virginas-Tar | 0085978 | 2019-02-11 12:21:27 +0000 | [diff] [blame] | 110 | /// @param biases - Optional tensor for the bias data. If specified, must match the output tensor shape. |
jimfly01 | 5f4e41f | 2019-01-23 16:10:17 +0000 | [diff] [blame] | 111 | /// @param name - Optional name for the layer. |
| 112 | virtual void VisitConvolution2dLayer(const IConnectableLayer* layer, |
| 113 | const Convolution2dDescriptor& convolution2dDescriptor, |
| 114 | const ConstTensor& weights, |
Aron Virginas-Tar | 0085978 | 2019-02-11 12:21:27 +0000 | [diff] [blame] | 115 | const Optional<ConstTensor>& biases, |
jimfly01 | 5f4e41f | 2019-01-23 16:10:17 +0000 | [diff] [blame] | 116 | const char* name = nullptr) = 0; |
| 117 | |
jimfly01 | 5f4e41f | 2019-01-23 16:10:17 +0000 | [diff] [blame] | 118 | /// Function that a 2D depthwise convolution layer with biases should call back to when its |
| 119 | /// Accept(ILayerVisitor&) function is invoked. |
| 120 | /// @param layer - pointer to the layer which is calling back to this visit function. |
| 121 | /// @param convolution2dDescriptor - Description of the 2D depthwise convolution layer. |
| 122 | /// @param weights - Tensor for the weights. Expected format: [channelMultiplier, inputChannels, height, width]. |
Aron Virginas-Tar | 0085978 | 2019-02-11 12:21:27 +0000 | [diff] [blame] | 123 | /// @param biases - Optional tensor for the bias data. If specified, must match the output tensor shape. |
jimfly01 | 5f4e41f | 2019-01-23 16:10:17 +0000 | [diff] [blame] | 124 | /// @param name - Optional name for the layer. |
| 125 | virtual void VisitDepthwiseConvolution2dLayer(const IConnectableLayer* layer, |
| 126 | const DepthwiseConvolution2dDescriptor& convolution2dDescriptor, |
| 127 | const ConstTensor& weights, |
Aron Virginas-Tar | 0085978 | 2019-02-11 12:21:27 +0000 | [diff] [blame] | 128 | const Optional<ConstTensor>& biases, |
jimfly01 | 5f4e41f | 2019-01-23 16:10:17 +0000 | [diff] [blame] | 129 | const char* name = nullptr) = 0; |
| 130 | |
Nattapat Chaimanowong | e4294fd | 2019-03-28 09:56:53 +0000 | [diff] [blame] | 131 | /// Function that a Dequantize layer should call back to when its |
| 132 | /// Accept(ILayerVisitor&) function is invoked. |
| 133 | /// @param layer - pointer to the layer which is calling back to this visit function. |
| 134 | /// @param name - Optional name for the layer. |
| 135 | virtual void VisitDequantizeLayer(const IConnectableLayer* layer, |
| 136 | const char* name = nullptr) = 0; |
| 137 | |
jimfly01 | d161ba0 | 2019-01-28 12:51:53 +0000 | [diff] [blame] | 138 | /// Function that a Detection PostProcess layer should call back to when its |
| 139 | /// Accept(ILayerVisitor&) function is invoked. |
| 140 | /// @param layer - pointer to the layer which is calling back to this visit function. |
| 141 | /// @param descriptor - Description of the Detection PostProcess layer. |
Narumol Prangnawarat | 6d302bf | 2019-02-04 11:46:26 +0000 | [diff] [blame] | 142 | /// @param anchors - Tensor for the anchors. |
jimfly01 | d161ba0 | 2019-01-28 12:51:53 +0000 | [diff] [blame] | 143 | /// @param name - Optional name for the layer. |
| 144 | virtual void VisitDetectionPostProcessLayer(const IConnectableLayer* layer, |
| 145 | const DetectionPostProcessDescriptor& descriptor, |
Narumol Prangnawarat | 6d302bf | 2019-02-04 11:46:26 +0000 | [diff] [blame] | 146 | const ConstTensor& anchors, |
jimfly01 | d161ba0 | 2019-01-28 12:51:53 +0000 | [diff] [blame] | 147 | const char* name = nullptr) = 0; |
| 148 | |
Derek Lamberti | 61f5463 | 2019-03-25 16:28:44 +0000 | [diff] [blame] | 149 | /// Function a division layer should call back to when its Accept(ILayerVisitor&) function is invoked. |
| 150 | /// @param layer - pointer to the layer which is calling back to this visit function. |
| 151 | /// @param name - Optional name for the layer. |
| 152 | virtual void VisitDivisionLayer(const IConnectableLayer* layer, |
| 153 | const char* name = nullptr) = 0; |
| 154 | |
| 155 | /// Function an Equal layer should call back to when its Accept(ILayerVisitor&) function is invoked. |
| 156 | /// @param layer - pointer to the layer which is calling back to this visit function. |
| 157 | /// @param name - Optional name for the layer. |
| 158 | virtual void VisitEqualLayer(const IConnectableLayer* layer, |
| 159 | const char* name = nullptr) = 0; |
| 160 | |
| 161 | /// Function a floor layer should call back to when its Accept(ILayerVisitor&) function is invoked. |
| 162 | /// @param layer - pointer to the layer which is calling back to this visit function. |
| 163 | /// @param name - Optional name for the layer. |
| 164 | virtual void VisitFloorLayer(const IConnectableLayer* layer, |
| 165 | const char* name = nullptr) = 0; |
| 166 | |
Aron Virginas-Tar | 0085978 | 2019-02-11 12:21:27 +0000 | [diff] [blame] | 167 | /// Function that a fully connected layer should call back to when its Accept(ILayerVisitor&) |
jimfly01 | 5f4e41f | 2019-01-23 16:10:17 +0000 | [diff] [blame] | 168 | /// function is invoked. |
| 169 | /// @param layer - pointer to the layer which is calling back to this visit function. |
| 170 | /// @param fullyConnectedDescriptor - Description of the fully connected layer. |
| 171 | /// @param weights - Tensor for the weights data. |
Aron Virginas-Tar | 0085978 | 2019-02-11 12:21:27 +0000 | [diff] [blame] | 172 | /// @param biases - Optional tensor for the bias data. |
jimfly01 | 5f4e41f | 2019-01-23 16:10:17 +0000 | [diff] [blame] | 173 | /// @param name - Optional name for the layer. |
| 174 | virtual void VisitFullyConnectedLayer(const IConnectableLayer* layer, |
| 175 | const FullyConnectedDescriptor& fullyConnectedDescriptor, |
| 176 | const ConstTensor& weights, |
Aron Virginas-Tar | 0085978 | 2019-02-11 12:21:27 +0000 | [diff] [blame] | 177 | const Optional<ConstTensor>& biases, |
jimfly01 | 5f4e41f | 2019-01-23 16:10:17 +0000 | [diff] [blame] | 178 | const char* name = nullptr) = 0; |
| 179 | |
Derek Lamberti | 61f5463 | 2019-03-25 16:28:44 +0000 | [diff] [blame] | 180 | /// Function a Gather layer should call back to when its Accept(ILayerVisitor&) function is invoked. |
jimfly01 | 5f4e41f | 2019-01-23 16:10:17 +0000 | [diff] [blame] | 181 | /// @param layer - pointer to the layer which is calling back to this visit function. |
jimfly01 | 5f4e41f | 2019-01-23 16:10:17 +0000 | [diff] [blame] | 182 | /// @param name - Optional name for the layer. |
Derek Lamberti | 61f5463 | 2019-03-25 16:28:44 +0000 | [diff] [blame] | 183 | virtual void VisitGatherLayer(const IConnectableLayer* layer, |
jimfly01 | 5f4e41f | 2019-01-23 16:10:17 +0000 | [diff] [blame] | 184 | const char* name = nullptr) = 0; |
| 185 | |
Derek Lamberti | 61f5463 | 2019-03-25 16:28:44 +0000 | [diff] [blame] | 186 | /// Function a Greater layer should call back to when its Accept(ILayerVisitor&) function is invoked. |
jimfly01 | 5f4e41f | 2019-01-23 16:10:17 +0000 | [diff] [blame] | 187 | /// @param layer - pointer to the layer which is calling back to this visit function. |
| 188 | /// @param name - Optional name for the layer. |
Derek Lamberti | 61f5463 | 2019-03-25 16:28:44 +0000 | [diff] [blame] | 189 | virtual void VisitGreaterLayer(const IConnectableLayer* layer, |
| 190 | const char* name = nullptr) = 0; |
jimfly01 | 5f4e41f | 2019-01-23 16:10:17 +0000 | [diff] [blame] | 191 | |
Derek Lamberti | 61f5463 | 2019-03-25 16:28:44 +0000 | [diff] [blame] | 192 | /// Function that an InputLayer should call back to when its Accept(ILayerVisitor&) function is invoked. |
jimfly01 | 5f4e41f | 2019-01-23 16:10:17 +0000 | [diff] [blame] | 193 | /// @param layer - pointer to the layer which is calling back to this visit function. |
Derek Lamberti | 61f5463 | 2019-03-25 16:28:44 +0000 | [diff] [blame] | 194 | /// @param id - User generated id to uniquely identify a particular input. The same id needs to be specified |
| 195 | /// when passing the inputs to the IRuntime::EnqueueWorkload() function. |
jimfly01 | 5f4e41f | 2019-01-23 16:10:17 +0000 | [diff] [blame] | 196 | /// @param name - Optional name for the layer. |
Derek Lamberti | 61f5463 | 2019-03-25 16:28:44 +0000 | [diff] [blame] | 197 | virtual void VisitInputLayer(const IConnectableLayer* layer, |
| 198 | LayerBindingId id, |
| 199 | const char* name = nullptr) = 0; |
jimfly01 | 5f4e41f | 2019-01-23 16:10:17 +0000 | [diff] [blame] | 200 | |
jimfly01 | 5f4e41f | 2019-01-23 16:10:17 +0000 | [diff] [blame] | 201 | |
| 202 | /// Function that an L2 normalization layer should call back to when its Accept(ILayerVisitor&) |
| 203 | /// function is invoked. Normalization is performed along dimension 1, but requires a 4d input. |
| 204 | /// @param layer - pointer to the layer which is calling back to this visit function. |
| 205 | /// @param desc - Parameters for the L2 normalization operation. |
| 206 | /// @param name - Optional name for the layer. |
| 207 | virtual void VisitL2NormalizationLayer(const IConnectableLayer* layer, |
| 208 | const L2NormalizationDescriptor& desc, |
| 209 | const char* name = nullptr) = 0; |
| 210 | |
jimfly01 | 5f4e41f | 2019-01-23 16:10:17 +0000 | [diff] [blame] | 211 | /// Function an Lstm layer should call back to when its Accept(ILayerVisitor&) function is invoked. |
| 212 | /// @param layer - pointer to the layer which is calling back to this visit function. |
| 213 | /// @param descriptor - Parameters controlling the operation of the Lstm operation. |
| 214 | /// @param params - The weights and biases for the LSTM cell. |
| 215 | /// @param name - Optional name for the layer. |
| 216 | virtual void VisitLstmLayer(const IConnectableLayer* layer, |
| 217 | const LstmDescriptor& descriptor, |
| 218 | const LstmInputParams& params, |
| 219 | const char* name = nullptr) = 0; |
| 220 | |
jimfly01 | 5f4e41f | 2019-01-23 16:10:17 +0000 | [diff] [blame] | 221 | /// Function a Maximum layer should call back to when its Accept(ILayerVisitor&) function is invoked. |
| 222 | /// @param layer - pointer to the layer which is calling back to this visit function. |
| 223 | /// @param name - Optional name for the layer. |
| 224 | virtual void VisitMaximumLayer(const IConnectableLayer* layer, |
| 225 | const char* name = nullptr) = 0; |
| 226 | |
| 227 | /// Function a Mean layer should call back to when its Accept(ILayerVisitor&) function is invoked. |
| 228 | /// @param layer - pointer to the layer which is calling back to this visit function. |
| 229 | /// @param meanDescriptor - Parameters for the mean operation. |
| 230 | /// @param name - Optional name for the layer. |
| 231 | virtual void VisitMeanLayer(const IConnectableLayer* layer, |
| 232 | const MeanDescriptor& meanDescriptor, |
| 233 | const char* name = nullptr) = 0; |
| 234 | |
Nattapat Chaimanowong | 1f88630 | 2019-04-05 13:37:19 +0100 | [diff] [blame] | 235 | /// Function that a merge layer should call back to when its Accept(ILayerVisitor&) function is invoked. |
| 236 | /// @param layer - pointer to the layer which is calling back to this visit function. |
| 237 | /// @param name - Optional name for the layer. |
| 238 | virtual void VisitMergeLayer(const IConnectableLayer* layer, |
| 239 | const char* name = nullptr) = 0; |
| 240 | |
Derek Lamberti | 61f5463 | 2019-03-25 16:28:44 +0000 | [diff] [blame] | 241 | /// Function that a merger layer should call back to when its Accept(ILayerVisitor&) function is invoked. |
| 242 | /// @param layer - pointer to the layer which is calling back to this visit function. |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 243 | /// @param mergerDescriptor - MergerDescriptor (synonym for OriginsDescriptor) to configure the concatenation |
| 244 | /// process. Number of Views must be equal to the number of inputs, and their order |
| 245 | /// must match - e.g. first view corresponds to the first input, second view to the |
| 246 | /// second input, etc.... |
Derek Lamberti | 61f5463 | 2019-03-25 16:28:44 +0000 | [diff] [blame] | 247 | /// @param name - Optional name for the layer. |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 248 | ARMNN_DEPRECATED_MSG("Use VisitConcatLayer instead") |
Derek Lamberti | 61f5463 | 2019-03-25 16:28:44 +0000 | [diff] [blame] | 249 | virtual void VisitMergerLayer(const IConnectableLayer* layer, |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 250 | const MergerDescriptor& mergerDescriptor, |
Derek Lamberti | 61f5463 | 2019-03-25 16:28:44 +0000 | [diff] [blame] | 251 | const char* name = nullptr) = 0; |
| 252 | |
| 253 | /// Function a Minimum layer should call back to when its Accept(ILayerVisitor&) function is invoked. |
| 254 | /// @param layer - pointer to the layer which is calling back to this visit function. |
| 255 | /// @param name - Optional name for the layer. |
| 256 | virtual void VisitMinimumLayer(const IConnectableLayer* layer, |
| 257 | const char* name = nullptr) = 0; |
| 258 | |
| 259 | /// Function that a multiplication layer should call back to when its Accept(ILayerVisitor&) function is invoked. |
| 260 | /// @param layer - pointer to the layer which is calling back to this visit function. |
| 261 | /// @param name - Optional name for the layer. |
| 262 | virtual void VisitMultiplicationLayer(const IConnectableLayer* layer, |
| 263 | const char* name = nullptr) = 0; |
| 264 | |
| 265 | /// Function that a normalization layer should call back to when its Accept(ILayerVisitor&) function is invoked. |
| 266 | /// @param layer - pointer to the layer which is calling back to this visit function. |
| 267 | /// @param normalizationDescriptor - NormalizationDescriptor to configure the normalization. |
| 268 | /// @param name - Optional name for the layer. |
| 269 | virtual void VisitNormalizationLayer(const IConnectableLayer* layer, |
| 270 | const NormalizationDescriptor& normalizationDescriptor, |
| 271 | const char* name = nullptr) = 0; |
| 272 | |
| 273 | /// Function an output layer should call back to when its Accept(ILayerVisitor&) function is invoked. |
| 274 | /// @param layer - pointer to the layer which is calling back to this visit function. |
| 275 | /// @param id - User generated id to uniquely identify a particular output. The same id needs to be specified |
| 276 | /// when passing the outputs to the IRuntime::EnqueueWorkload() function. |
| 277 | /// @param name - Optional name for the layer. |
| 278 | virtual void VisitOutputLayer(const IConnectableLayer* layer, |
| 279 | LayerBindingId id, |
| 280 | const char* name = nullptr) = 0; |
| 281 | |
jimfly01 | 5f4e41f | 2019-01-23 16:10:17 +0000 | [diff] [blame] | 282 | /// Function a pad layer should call back to when its Accept(ILayerVisitor&) function is invoked. |
| 283 | /// @param layer - pointer to the layer which is calling back to this visit function. |
| 284 | /// @param paddings - n by 2 tensor, where n is the rank of the input tensor, |
| 285 | /// such that paddings[i,0] indicates the amount of padding to add in front of dimension i, and |
| 286 | /// paddings[i,1] indicates the amount of padding to add after the end of dimension i |
| 287 | /// @param name - Optional name for the layer. |
| 288 | virtual void VisitPadLayer(const IConnectableLayer* layer, |
| 289 | const PadDescriptor& padDescriptor, |
| 290 | const char* name = nullptr) = 0; |
| 291 | |
Derek Lamberti | 61f5463 | 2019-03-25 16:28:44 +0000 | [diff] [blame] | 292 | /// Function that a permute layer should call back to when its Accept(ILayerVisitor&) function is invoked. |
| 293 | /// @param layer - pointer to the layer which is calling back to this visit function. |
| 294 | /// @param permuteDescriptor - PermuteDescriptor to configure the permute. |
| 295 | /// @param name - Optional name for the layer. |
| 296 | virtual void VisitPermuteLayer(const IConnectableLayer* layer, |
| 297 | const PermuteDescriptor& permuteDescriptor, |
| 298 | const char* name = nullptr) = 0; |
| 299 | |
| 300 | /// Function that a pooling layer should call back to when its Accept(ILayerVisitor&) function is invoked. |
| 301 | /// @param layer - pointer to the layer which is calling back to this visit function. |
| 302 | /// @param pooling2dDescriptor - Pooling2dDescriptor to configure the pooling. |
| 303 | /// @param name - Optional name for the layer. |
| 304 | virtual void VisitPooling2dLayer(const IConnectableLayer* layer, |
| 305 | const Pooling2dDescriptor& pooling2dDescriptor, |
| 306 | const char* name = nullptr) = 0; |
| 307 | |
Matteo Martincigh | 0e406ee | 2019-06-12 15:42:18 +0100 | [diff] [blame] | 308 | /// Function that a PReLU activation layer should call back to when its Accept(ILayerVisitor&) function is invoked. |
| 309 | /// @param layer - pointer to the layer which is calling back to this visit function. |
| 310 | /// @param name - Optional name for the layer. |
| 311 | virtual void VisitPreluLayer(const IConnectableLayer* layer, |
| 312 | const char* name = nullptr) = 0; |
| 313 | |
Derek Lamberti | a9cca6a | 2019-03-25 15:41:58 +0000 | [diff] [blame] | 314 | /// Function a quantize layer should call back to when its Accept(ILayerVisitor&) function is invoked. |
| 315 | /// @param layer - pointer to the layer which is calling back to this visit function. |
| 316 | /// @param name - Optional name for the layer. |
| 317 | virtual void VisitQuantizeLayer(const IConnectableLayer* layer, |
| 318 | const char* name = nullptr) = 0; |
| 319 | |
James Conroy | ee18dc8 | 2019-07-17 11:27:46 +0100 | [diff] [blame] | 320 | /// Function a QuantizedLstm layer should call back to when its Accept(ILayerVisitor&) function is invoked. |
| 321 | /// @param layer - pointer to the layer which is calling back to this visit function. |
| 322 | /// @param params - The weights and biases for the Quantized LSTM cell |
| 323 | /// @param name - Optional name for the layer. |
| 324 | virtual void VisitQuantizedLstmLayer(const IConnectableLayer* layer, |
| 325 | const QuantizedLstmInputParams& params, |
| 326 | const char* name = nullptr) = 0; |
| 327 | |
Derek Lamberti | 61f5463 | 2019-03-25 16:28:44 +0000 | [diff] [blame] | 328 | /// Function a reshape layer should call back to when its Accept(ILayerVisitor&) function is invoked. |
| 329 | /// @param layer - pointer to the layer which is calling back to this visit function. |
| 330 | /// @param reshapeDescriptor - Parameters for the reshape operation. |
| 331 | /// @param name - Optional name for the layer. |
| 332 | virtual void VisitReshapeLayer(const IConnectableLayer* layer, |
| 333 | const ReshapeDescriptor& reshapeDescriptor, |
| 334 | const char* name = nullptr) = 0; |
| 335 | |
| 336 | /// Function that a resize bilinear layer should call back to when its Accept(ILayerVisitor&) function is invoked. |
| 337 | /// @param layer - pointer to the layer which is calling back to this visit function. |
| 338 | /// @param resizeDesc - Parameters for the resize operation. |
| 339 | /// @param name - Optional name for the layer. |
Aron Virginas-Tar | 169d2f1 | 2019-07-01 19:01:44 +0100 | [diff] [blame] | 340 | ARMNN_DEPRECATED_MSG("Use VisitResizeLayer instead") |
Derek Lamberti | 61f5463 | 2019-03-25 16:28:44 +0000 | [diff] [blame] | 341 | virtual void VisitResizeBilinearLayer(const IConnectableLayer* layer, |
| 342 | const ResizeBilinearDescriptor& resizeDesc, |
| 343 | const char* name = nullptr) = 0; |
| 344 | |
Teresa Charlin | a9075df | 2019-06-27 15:41:57 +0100 | [diff] [blame] | 345 | /// Function that a resize layer should call back to when its Accept(ILayerVisitor&) function is invoked. |
| 346 | /// @param layer - pointer to the layer which is calling back to this visit function. |
| 347 | /// @param resizeDescriptor - Parameters for the resize operation. |
| 348 | /// @param name - Optional name for the layer. |
| 349 | virtual void VisitResizeLayer(const IConnectableLayer* layer, |
| 350 | const ResizeDescriptor& resizeDescriptor, |
| 351 | const char* name = nullptr) = 0; |
| 352 | |
Derek Lamberti | 61f5463 | 2019-03-25 16:28:44 +0000 | [diff] [blame] | 353 | /// Function a Reciprocal of square root layer should call back to when its Accept(ILayerVisitor&) |
| 354 | /// function is invoked. |
| 355 | /// @param layer - pointer to the layer which is calling back to this visit function. |
| 356 | /// @param name - Optional name for the layer. |
| 357 | virtual void VisitRsqrtLayer(const IConnectableLayer* layer, |
| 358 | const char* name = nullptr) = 0; |
| 359 | |
Aron Virginas-Tar | 636ab40 | 2019-09-16 14:27:45 +0100 | [diff] [blame^] | 360 | /// Function that a slice layer should call back to when its Accept(ILayerVisitor&) function is invoked. |
| 361 | /// @param layer - pointer to the layer which is calling back to this visit function. |
| 362 | /// @param sliceDescriptor - SliceDescriptor to configure the slice operation. |
| 363 | /// @param name - Optional name for the layer. |
| 364 | virtual void VisitSliceLayer(const IConnectableLayer* layer, |
| 365 | const SliceDescriptor& sliceDescriptor, |
| 366 | const char* name = nullptr) = 0; |
| 367 | |
Derek Lamberti | 61f5463 | 2019-03-25 16:28:44 +0000 | [diff] [blame] | 368 | |
| 369 | /// Function that a softmax layer should call back to when its Accept(ILayerVisitor&) function is invoked. |
| 370 | /// @param layer - pointer to the layer which is calling back to this visit function. |
| 371 | /// @param softmaxDescriptor - SoftmaxDescriptor to configure the softmax. |
| 372 | /// @param name - Optional name for the layer. |
| 373 | virtual void VisitSoftmaxLayer(const IConnectableLayer* layer, |
| 374 | const SoftmaxDescriptor& softmaxDescriptor, |
| 375 | const char* name = nullptr) = 0; |
| 376 | |
| 377 | /// Function a space to batch layer should call back to when its Accept(ILayerVisitor&) function is invoked. |
| 378 | /// @param layer - pointer to the layer which is calling back to this visit function. |
| 379 | /// @param spaceToBatchNdDescriptor - Parameters for the space to batch operation. |
| 380 | /// @param name - Optional name for the layer. |
| 381 | virtual void VisitSpaceToBatchNdLayer(const IConnectableLayer* layer, |
| 382 | const SpaceToBatchNdDescriptor& spaceToBatchNdDescriptor, |
| 383 | const char* name = nullptr) = 0; |
| 384 | |
Aron Virginas-Tar | 972af15 | 2019-06-11 14:14:03 +0100 | [diff] [blame] | 385 | /// Function a space to depth layer should call back to when its Accept(ILayerVisitor&) function is invoked. |
| 386 | /// @param layer - pointer to the layer which is calling back to this visit function. |
| 387 | /// @param spaceToDepthDescriptor - Parameters for the space to depth operation. |
| 388 | /// @param name - Optional name for the layer. |
| 389 | virtual void VisitSpaceToDepthLayer(const IConnectableLayer* layer, |
| 390 | const SpaceToDepthDescriptor& spaceToDepthDescriptor, |
| 391 | const char* name = nullptr) = 0; |
| 392 | |
Derek Lamberti | 61f5463 | 2019-03-25 16:28:44 +0000 | [diff] [blame] | 393 | /// Function that a splitter layer should call back to when its Accept(ILayerVisitor&) function is invoked. |
| 394 | /// @param layer - pointer to the layer which is calling back to this visit function. |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 395 | /// @param splitterDescriptor - ViewsDescriptor to configure the splitting process. |
Derek Lamberti | 61f5463 | 2019-03-25 16:28:44 +0000 | [diff] [blame] | 396 | /// Number of Views must be equal to the number of outputs, |
| 397 | /// and their order must match - e.g. first view corresponds to |
| 398 | /// the first output, second view to the second output, etc.... |
| 399 | /// @param name - Optional name for the layer. |
| 400 | virtual void VisitSplitterLayer(const IConnectableLayer* layer, |
| 401 | const ViewsDescriptor& splitterDescriptor, |
| 402 | const char* name = nullptr) = 0; |
| 403 | |
Matthew Jackson | 2b8c1da | 2019-07-04 14:59:16 +0100 | [diff] [blame] | 404 | /// Function a stack layer should call back to when its Accept(ILayerVisitor&) function is invoked. |
| 405 | /// @param layer - pointer to the layer which is calling back to this visit function. |
| 406 | /// @param stackDescriptor - Parameters for the stack operation. |
| 407 | /// @param name - Optional name for the layer. |
| 408 | virtual void VisitStackLayer(const IConnectableLayer* layer, |
| 409 | const StackDescriptor& stackDescriptor, |
| 410 | const char* name = nullptr) = 0; |
| 411 | |
jimfly01 | 5f4e41f | 2019-01-23 16:10:17 +0000 | [diff] [blame] | 412 | /// Function a strided slice layer should call back to when its Accept(ILayerVisitor&) function is invoked. |
| 413 | /// @param layer - pointer to the layer which is calling back to this visit function. |
Aron Virginas-Tar | 639fb04 | 2019-06-20 14:28:19 +0100 | [diff] [blame] | 414 | /// @param stridedSliceDescriptor - Parameters for the strided slice operation. |
jimfly01 | 5f4e41f | 2019-01-23 16:10:17 +0000 | [diff] [blame] | 415 | /// @param name - Optional name for the layer. |
| 416 | virtual void VisitStridedSliceLayer(const IConnectableLayer* layer, |
| 417 | const StridedSliceDescriptor& stridedSliceDescriptor, |
| 418 | const char* name = nullptr) = 0; |
| 419 | |
Derek Lamberti | 61f5463 | 2019-03-25 16:28:44 +0000 | [diff] [blame] | 420 | /// Function a subtraction layer should call back to when its Accept(ILayerVisitor&) function is invoked. |
jimfly01 | 5f4e41f | 2019-01-23 16:10:17 +0000 | [diff] [blame] | 421 | /// @param layer - pointer to the layer which is calling back to this visit function. |
| 422 | /// @param name - Optional name for the layer. |
Derek Lamberti | 61f5463 | 2019-03-25 16:28:44 +0000 | [diff] [blame] | 423 | virtual void VisitSubtractionLayer(const IConnectableLayer* layer, |
| 424 | const char* name = nullptr) = 0; |
jimfly01 | 5f4e41f | 2019-01-23 16:10:17 +0000 | [diff] [blame] | 425 | |
Sadik Armagan | eff363d | 2019-04-05 15:25:46 +0100 | [diff] [blame] | 426 | /// Function a switch layer should call back to when its Accept(ILayerVisitor&) function is invoked. |
| 427 | /// @param layer - pointer to the layer which is calling back to this visit function. |
| 428 | /// @param name - Optional name for the layer. |
| 429 | virtual void VisitSwitchLayer(const IConnectableLayer* layer, |
| 430 | const char* name = nullptr) = 0; |
| 431 | |
Aron Virginas-Tar | 639fb04 | 2019-06-20 14:28:19 +0100 | [diff] [blame] | 432 | /// Function that a 2D transpose convolution layer should call back to when its Accept(ILayerVisitor&) |
| 433 | /// function is invoked. |
| 434 | /// @param layer - pointer to the layer which is calling back to this visit function. |
| 435 | /// @param descriptor - Description of the 2D transpose convolution layer. |
| 436 | /// @param weights - Tensor for the weights data. |
| 437 | /// @param biases - Optional tensor for the bias data. |
| 438 | /// @param name - Optional name for the layer. |
| 439 | virtual void VisitTransposeConvolution2dLayer(const IConnectableLayer* layer, |
| 440 | const TransposeConvolution2dDescriptor& descriptor, |
| 441 | const ConstTensor& weights, |
| 442 | const Optional<ConstTensor>& biases, |
| 443 | const char* name = nullptr) = 0; |
| 444 | |
Jim Flynn | f92dfce | 2019-05-02 11:33:25 +0100 | [diff] [blame] | 445 | virtual void StartVisit() {} |
| 446 | virtual void FinishVisit() {} |
jimfly01 | 5f4e41f | 2019-01-23 16:10:17 +0000 | [diff] [blame] | 447 | |
| 448 | }; |
Nattapat Chaimanowong | 1f88630 | 2019-04-05 13:37:19 +0100 | [diff] [blame] | 449 | } // namespace armnn |