Georgios Pinitas | 2870516 | 2018-03-21 20:10:53 +0000 | [diff] [blame] | 1 | /* |
Michele Di Giorgio | d9eaf61 | 2020-07-08 11:12:57 +0100 | [diff] [blame] | 2 | * Copyright (c) 2018-2020 Arm Limited. |
Georgios Pinitas | 2870516 | 2018-03-21 20:10:53 +0000 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: MIT |
| 5 | * |
| 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 7 | * of this software and associated documentation files (the "Software"), to |
| 8 | * deal in the Software without restriction, including without limitation the |
| 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or |
| 10 | * sell copies of the Software, and to permit persons to whom the Software is |
| 11 | * furnished to do so, subject to the following conditions: |
| 12 | * |
| 13 | * The above copyright notice and this permission notice shall be included in all |
| 14 | * copies or substantial portions of the Software. |
| 15 | * |
| 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 22 | * SOFTWARE. |
| 23 | */ |
Michalis Spyrou | f464337 | 2019-11-29 16:17:13 +0000 | [diff] [blame] | 24 | #ifndef ARM_COMPUTE_GRAPH_BACKENDS_DETAIL_VALIDATE_HELPERS_H |
| 25 | #define ARM_COMPUTE_GRAPH_BACKENDS_DETAIL_VALIDATE_HELPERS_H |
Georgios Pinitas | 2870516 | 2018-03-21 20:10:53 +0000 | [diff] [blame] | 26 | |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 27 | #include "arm_compute/graph/Logger.h" |
| 28 | #include "arm_compute/graph/Tensor.h" |
| 29 | #include "arm_compute/graph/Types.h" |
| 30 | #include "arm_compute/graph/nodes/Nodes.h" |
Georgios Pinitas | 2870516 | 2018-03-21 20:10:53 +0000 | [diff] [blame] | 31 | |
| 32 | #include "arm_compute/core/Error.h" |
Georgios Pinitas | cac13b1 | 2018-04-27 19:07:19 +0100 | [diff] [blame] | 33 | #include "arm_compute/core/Helpers.h" |
Georgios Pinitas | 2870516 | 2018-03-21 20:10:53 +0000 | [diff] [blame] | 34 | #include "arm_compute/core/ITensorInfo.h" |
| 35 | |
| 36 | namespace arm_compute |
| 37 | { |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 38 | namespace graph |
Georgios Pinitas | 2870516 | 2018-03-21 20:10:53 +0000 | [diff] [blame] | 39 | { |
| 40 | namespace backends |
| 41 | { |
| 42 | namespace detail |
| 43 | { |
| 44 | /** Returns backing tensor info of a given tensor |
| 45 | * |
| 46 | * @param[in] tensor Tensor to extract the backing tensor from |
| 47 | * |
| 48 | * @return Backing tensor tensor info if present else nullptr |
| 49 | */ |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 50 | inline arm_compute::ITensorInfo *get_backing_tensor_info(arm_compute::graph::Tensor *tensor) |
Georgios Pinitas | 2870516 | 2018-03-21 20:10:53 +0000 | [diff] [blame] | 51 | { |
| 52 | return ((tensor == nullptr) || (tensor->handle() == nullptr)) ? nullptr : tensor->handle()->tensor().info(); |
| 53 | } |
| 54 | |
thecha01 | e8f05da | 2020-08-24 17:21:41 +0100 | [diff] [blame] | 55 | /** Validates a ArgMinMax layer node |
| 56 | * |
| 57 | * @tparam ArgMinMax layer function type |
| 58 | * |
| 59 | * @param[in] node Node to validate |
| 60 | * |
| 61 | * @return Status |
| 62 | */ |
| 63 | template <typename ArgMinMaxLayer> |
| 64 | Status validate_arg_min_max_layer(ArgMinMaxLayerNode &node) |
| 65 | { |
| 66 | ARM_COMPUTE_LOG_GRAPH_VERBOSE("Validating ArgMinMaxLayer node with ID : " << node.id() << " and Name: " << node.name() << std::endl); |
| 67 | ARM_COMPUTE_RETURN_ERROR_ON(node.num_inputs() != 1); |
| 68 | ARM_COMPUTE_RETURN_ERROR_ON(node.num_outputs() != 1); |
| 69 | |
| 70 | // Extract IO and info |
| 71 | arm_compute::ITensorInfo *input = detail::get_backing_tensor_info(node.input(0)); |
| 72 | arm_compute::ITensorInfo *output = get_backing_tensor_info(node.output(0)); |
| 73 | |
| 74 | // Validate function |
| 75 | return ArgMinMaxLayer::validate(input, node.axis(), output, node.reduction_operation()); |
| 76 | } |
| 77 | |
Manuel Bottini | d2048ce | 2018-10-23 17:00:42 +0100 | [diff] [blame] | 78 | /** Validates a Bounding Box Transform layer node |
| 79 | * |
| 80 | * @tparam BoundingBoxTransformLayer Bounding Box Transform layer function type |
| 81 | * |
| 82 | * @param[in] node Node to validate |
| 83 | * |
| 84 | * @return Status |
| 85 | */ |
| 86 | template <typename BoundingBoxTransformLayer> |
| 87 | Status validate_bounding_box_transform_layer(BoundingBoxTransformLayerNode &node) |
| 88 | { |
| 89 | ARM_COMPUTE_LOG_GRAPH_VERBOSE("Validating BoundingBoxTransformLayer node with ID : " << node.id() << " and Name: " << node.name() << std::endl); |
| 90 | ARM_COMPUTE_RETURN_ERROR_ON(node.num_inputs() != 2); |
| 91 | ARM_COMPUTE_RETURN_ERROR_ON(node.num_outputs() != 1); |
| 92 | |
| 93 | // Extract IO and info |
| 94 | arm_compute::ITensorInfo *input = get_backing_tensor_info(node.input(0)); |
| 95 | arm_compute::ITensorInfo *deltas = get_backing_tensor_info(node.input(1)); |
| 96 | arm_compute::ITensorInfo *output = get_backing_tensor_info(node.output(0)); |
| 97 | const BoundingBoxTransformInfo bbox_info = node.info(); |
| 98 | |
| 99 | return BoundingBoxTransformLayer::validate(input, output, deltas, bbox_info); |
| 100 | } |
| 101 | |
Georgios Pinitas | 087eaf6 | 2018-05-16 15:52:35 +0100 | [diff] [blame] | 102 | /** Validates a Channel Shuffle layer node |
| 103 | * |
| 104 | * @tparam ChannelShuffleLayer Channel Shuffle layer function type |
| 105 | * |
| 106 | * @param[in] node Node to validate |
| 107 | * |
| 108 | * @return Status |
| 109 | */ |
| 110 | template <typename ChannelShuffleLayer> |
| 111 | Status validate_channel_shuffle_layer(ChannelShuffleLayerNode &node) |
| 112 | { |
| 113 | ARM_COMPUTE_LOG_GRAPH_VERBOSE("Validating ChannelShuffle node with ID : " << node.id() << " and Name: " << node.name() << std::endl); |
| 114 | ARM_COMPUTE_RETURN_ERROR_ON(node.num_inputs() != 1); |
| 115 | ARM_COMPUTE_RETURN_ERROR_ON(node.num_outputs() != 1); |
| 116 | |
| 117 | // Extract IO and info |
| 118 | arm_compute::ITensorInfo *input = get_backing_tensor_info(node.input(0)); |
| 119 | arm_compute::ITensorInfo *output = get_backing_tensor_info(node.output(0)); |
| 120 | const unsigned int num_groups = node.num_groups(); |
| 121 | |
| 122 | return ChannelShuffleLayer::validate(input, output, num_groups); |
| 123 | } |
| 124 | |
Georgios Pinitas | 2870516 | 2018-03-21 20:10:53 +0000 | [diff] [blame] | 125 | /** Validates a Convolution layer node |
| 126 | * |
| 127 | * @tparam ConvolutionLayer Default Convolution layer function type |
| 128 | * @tparam DirectConvolutionLayer Direct Convolution layer function type |
| 129 | * @tparam GEMMConvolutionLayer GEMM Convolution layer function type |
| 130 | * @tparam WinogradConvolutionLayer Winograd Convolution layer function type |
| 131 | * |
| 132 | * @param[in] node Node to validate |
| 133 | * |
| 134 | * @return Status |
| 135 | */ |
| 136 | template <typename ConvolutionLayer, typename DirectConvolutionLayer, typename GEMMConvolutionLayer, typename WinogradConvolutionLayer> |
| 137 | Status validate_convolution_layer(ConvolutionLayerNode &node) |
| 138 | { |
| 139 | ARM_COMPUTE_LOG_GRAPH_VERBOSE("Validating ConvolutionLayer node with ID : " << node.id() << " and Name: " << node.name() << std::endl); |
| 140 | ARM_COMPUTE_RETURN_ERROR_ON(node.num_inputs() != 3); |
| 141 | ARM_COMPUTE_RETURN_ERROR_ON(node.num_outputs() != 1); |
| 142 | |
| 143 | // Extract IO and info |
Giorgio Arena | bb54e4e | 2018-04-05 17:20:34 +0100 | [diff] [blame] | 144 | arm_compute::ITensorInfo *input = get_backing_tensor_info(node.input(0)); |
| 145 | arm_compute::ITensorInfo *weights = get_backing_tensor_info(node.input(1)); |
| 146 | arm_compute::ITensorInfo *biases = get_backing_tensor_info(node.input(2)); |
| 147 | arm_compute::ITensorInfo *output = get_backing_tensor_info(node.output(0)); |
| 148 | |
| 149 | if(is_data_type_quantized_asymmetric(input->data_type())) |
| 150 | { |
| 151 | biases->set_data_type(DataType::S32); |
| 152 | } |
| 153 | |
| 154 | const PadStrideInfo conv_info = node.convolution_info(); |
| 155 | const ConvolutionMethod conv_algorithm = node.convolution_method(); |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 156 | const bool fast_math = node.fast_math_hint() == FastMathHint::Enabled; |
Georgios Pinitas | 2a2db59 | 2018-08-15 12:14:46 +0100 | [diff] [blame] | 157 | const unsigned int num_groups = node.num_groups(); |
Georgios Pinitas | 2870516 | 2018-03-21 20:10:53 +0000 | [diff] [blame] | 158 | |
| 159 | // Validate function |
| 160 | Status status{}; |
| 161 | switch(conv_algorithm) |
| 162 | { |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 163 | case ConvolutionMethod::Direct: |
Georgios Pinitas | 2a2db59 | 2018-08-15 12:14:46 +0100 | [diff] [blame] | 164 | ARM_COMPUTE_RETURN_ERROR_ON_MSG(num_groups != 1, "DirectConvolutionLayer does not support grouping!"); |
Georgios Pinitas | 2870516 | 2018-03-21 20:10:53 +0000 | [diff] [blame] | 165 | status = DirectConvolutionLayer::validate(input, weights, biases, output, conv_info); |
| 166 | break; |
| 167 | case ConvolutionMethod::GEMM: |
Georgios Pinitas | 2a2db59 | 2018-08-15 12:14:46 +0100 | [diff] [blame] | 168 | status = GEMMConvolutionLayer::validate(input, weights, biases, output, conv_info, |
| 169 | WeightsInfo(), Size2D(1, 1), ActivationLayerInfo(), num_groups); |
Georgios Pinitas | 2870516 | 2018-03-21 20:10:53 +0000 | [diff] [blame] | 170 | break; |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 171 | case ConvolutionMethod::Winograd: |
Georgios Pinitas | 2a2db59 | 2018-08-15 12:14:46 +0100 | [diff] [blame] | 172 | ARM_COMPUTE_RETURN_ERROR_ON_MSG(num_groups != 1, "WinogradConvolutionLayer does not support grouping!"); |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 173 | status = WinogradConvolutionLayer::validate(input, weights, biases, output, conv_info, ActivationLayerInfo(), fast_math); |
Georgios Pinitas | 2870516 | 2018-03-21 20:10:53 +0000 | [diff] [blame] | 174 | break; |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 175 | case ConvolutionMethod::Default: |
Georgios Pinitas | 2a2db59 | 2018-08-15 12:14:46 +0100 | [diff] [blame] | 176 | status = ConvolutionLayer::validate(input, weights, biases, output, conv_info, |
| 177 | WeightsInfo(), Size2D(1, 1), ActivationLayerInfo(), fast_math, num_groups); |
Georgios Pinitas | 54d6fae | 2018-05-10 15:50:14 +0100 | [diff] [blame] | 178 | break; |
Georgios Pinitas | 2870516 | 2018-03-21 20:10:53 +0000 | [diff] [blame] | 179 | default: |
Georgios Pinitas | 2a2db59 | 2018-08-15 12:14:46 +0100 | [diff] [blame] | 180 | ARM_COMPUTE_RETURN_ERROR_MSG("Unsupported convolution method"); |
Georgios Pinitas | 2870516 | 2018-03-21 20:10:53 +0000 | [diff] [blame] | 181 | } |
| 182 | |
| 183 | return status; |
| 184 | } |
| 185 | |
| 186 | /** Validates a Depthwise Convolution layer node |
| 187 | * |
| 188 | * @tparam DepthwiseConvolutionLayer Default Depthwise Convolution layer type |
Georgios Pinitas | 2870516 | 2018-03-21 20:10:53 +0000 | [diff] [blame] | 189 | * |
| 190 | * @param[in] node Node to validate |
| 191 | * |
| 192 | * @return Status |
| 193 | */ |
Manuel Bottini | 05069f0 | 2019-09-26 17:18:26 +0100 | [diff] [blame] | 194 | template <typename DepthwiseConvolutionLayer> |
Georgios Pinitas | 2870516 | 2018-03-21 20:10:53 +0000 | [diff] [blame] | 195 | Status validate_depthwise_convolution_layer(DepthwiseConvolutionLayerNode &node) |
| 196 | { |
| 197 | ARM_COMPUTE_LOG_GRAPH_VERBOSE("Validating DepthwiseConvolutionLayer node with ID : " << node.id() << " and Name: " << node.name() << std::endl); |
| 198 | ARM_COMPUTE_RETURN_ERROR_ON(node.num_inputs() != 3); |
| 199 | ARM_COMPUTE_RETURN_ERROR_ON(node.num_outputs() != 1); |
| 200 | |
| 201 | // Extract IO and info |
Georgios Pinitas | 2a2db59 | 2018-08-15 12:14:46 +0100 | [diff] [blame] | 202 | arm_compute::ITensorInfo *input = detail::get_backing_tensor_info(node.input(0)); |
| 203 | arm_compute::ITensorInfo *weights = detail::get_backing_tensor_info(node.input(1)); |
| 204 | arm_compute::ITensorInfo *biases = get_backing_tensor_info(node.input(2)); |
| 205 | arm_compute::ITensorInfo *output = get_backing_tensor_info(node.output(0)); |
Georgios Pinitas | 2870516 | 2018-03-21 20:10:53 +0000 | [diff] [blame] | 206 | |
Georgios Pinitas | 05045c1 | 2018-12-07 18:31:47 +0000 | [diff] [blame] | 207 | const PadStrideInfo conv_info = node.convolution_info(); |
| 208 | const DepthwiseConvolutionMethod dwc_algorithm = node.depthwise_convolution_method(); |
| 209 | const int depth_multiplier = node.depth_multiplier(); |
Georgios Pinitas | 2a2db59 | 2018-08-15 12:14:46 +0100 | [diff] [blame] | 210 | |
Georgios Pinitas | 2870516 | 2018-03-21 20:10:53 +0000 | [diff] [blame] | 211 | // Validate function |
Georgios Pinitas | 2a2db59 | 2018-08-15 12:14:46 +0100 | [diff] [blame] | 212 | Status status{}; |
| 213 | switch(dwc_algorithm) |
Georgios Pinitas | 2870516 | 2018-03-21 20:10:53 +0000 | [diff] [blame] | 214 | { |
Georgios Pinitas | 2a2db59 | 2018-08-15 12:14:46 +0100 | [diff] [blame] | 215 | case DepthwiseConvolutionMethod::Default: |
Georgios Pinitas | 2a2db59 | 2018-08-15 12:14:46 +0100 | [diff] [blame] | 216 | case DepthwiseConvolutionMethod::Optimized3x3: |
Manuel Bottini | 05069f0 | 2019-09-26 17:18:26 +0100 | [diff] [blame] | 217 | status = DepthwiseConvolutionLayer::validate(input, weights, biases, output, conv_info, depth_multiplier); |
Georgios Pinitas | 2a2db59 | 2018-08-15 12:14:46 +0100 | [diff] [blame] | 218 | break; |
| 219 | default: |
| 220 | ARM_COMPUTE_RETURN_ERROR_MSG("Unsupported depthwise convolution method"); |
Georgios Pinitas | 2870516 | 2018-03-21 20:10:53 +0000 | [diff] [blame] | 221 | } |
| 222 | |
Georgios Pinitas | 2a2db59 | 2018-08-15 12:14:46 +0100 | [diff] [blame] | 223 | return status; |
Georgios Pinitas | 2870516 | 2018-03-21 20:10:53 +0000 | [diff] [blame] | 224 | } |
thecha01 | 0a05e6a | 2020-08-28 18:40:38 +0100 | [diff] [blame] | 225 | /** Validates a depth to space layer node |
| 226 | * |
| 227 | * @tparam DequantizationLayer Dequantize layer type |
| 228 | * |
| 229 | * @param[in] node Node to validate |
| 230 | * |
| 231 | * @return Status |
| 232 | */ |
| 233 | template <typename DepthToSpaceLayer> |
| 234 | Status validate_depth_to_space_layer(DepthToSpaceLayerNode &node) |
| 235 | { |
| 236 | ARM_COMPUTE_LOG_GRAPH_VERBOSE("Validating DetectionOutputLayer node with ID : " << node.id() << " and Name: " << node.name() << std::endl); |
| 237 | ARM_COMPUTE_RETURN_ERROR_ON(node.num_inputs() != 1); |
| 238 | ARM_COMPUTE_RETURN_ERROR_ON(node.num_outputs() != 1); |
| 239 | |
| 240 | // Extract IO and info |
| 241 | arm_compute::ITensorInfo *input = get_backing_tensor_info(node.input(0)); |
| 242 | arm_compute::ITensorInfo *output = get_backing_tensor_info(node.output(0)); |
| 243 | |
| 244 | return DepthToSpaceLayer::validate(input, output, node.block_shape()); |
| 245 | } |
Isabella Gottardi | cd4e9ab | 2019-11-05 17:50:27 +0000 | [diff] [blame] | 246 | /** Validates a dequantize layer node |
| 247 | * |
| 248 | * @tparam DequantizationLayer Dequantize layer type |
| 249 | * |
| 250 | * @param[in] node Node to validate |
| 251 | * |
| 252 | * @return Status |
| 253 | */ |
| 254 | template <typename DequantizationLayer> |
| 255 | Status validate_dequantization_layer(DequantizationLayerNode &node) |
| 256 | { |
| 257 | ARM_COMPUTE_LOG_GRAPH_VERBOSE("Validating DetectionOutputLayer node with ID : " << node.id() << " and Name: " << node.name() << std::endl); |
| 258 | ARM_COMPUTE_RETURN_ERROR_ON(node.num_inputs() != 1); |
| 259 | ARM_COMPUTE_RETURN_ERROR_ON(node.num_outputs() != 1); |
Isabella Gottardi | 0ae5de9 | 2019-03-14 10:32:11 +0000 | [diff] [blame] | 260 | |
Isabella Gottardi | cd4e9ab | 2019-11-05 17:50:27 +0000 | [diff] [blame] | 261 | // Extract IO and info |
| 262 | arm_compute::ITensorInfo *input = get_backing_tensor_info(node.input(0)); |
| 263 | arm_compute::ITensorInfo *output = get_backing_tensor_info(node.output(0)); |
| 264 | |
| 265 | return DequantizationLayer::validate(input, output); |
| 266 | } |
Isabella Gottardi | 7234ed8 | 2018-11-27 08:51:10 +0000 | [diff] [blame] | 267 | /** Validates a detection output layer node |
| 268 | * |
| 269 | * @tparam DetectionOutputLayer DetectionOutput layer type |
| 270 | * |
| 271 | * @param[in] node Node to validate |
| 272 | * |
| 273 | * @return Status |
| 274 | */ |
| 275 | template <typename DetectionOutputLayer> |
| 276 | Status validate_detection_output_layer(DetectionOutputLayerNode &node) |
| 277 | { |
| 278 | ARM_COMPUTE_LOG_GRAPH_VERBOSE("Validating DetectionOutputLayer node with ID : " << node.id() << " and Name: " << node.name() << std::endl); |
| 279 | ARM_COMPUTE_RETURN_ERROR_ON(node.num_inputs() != 3); |
| 280 | ARM_COMPUTE_RETURN_ERROR_ON(node.num_outputs() != 1); |
| 281 | |
| 282 | // Extract IO and info |
| 283 | arm_compute::ITensorInfo *input0 = get_backing_tensor_info(node.input(0)); |
| 284 | arm_compute::ITensorInfo *input1 = get_backing_tensor_info(node.input(1)); |
| 285 | arm_compute::ITensorInfo *input2 = get_backing_tensor_info(node.input(2)); |
| 286 | arm_compute::ITensorInfo *output = get_backing_tensor_info(node.output(0)); |
| 287 | const DetectionOutputLayerInfo detect_info = node.detection_output_info(); |
| 288 | |
| 289 | return DetectionOutputLayer::validate(input0, input1, input2, output, detect_info); |
| 290 | } |
Isabella Gottardi | a7acb3c | 2019-01-08 13:48:44 +0000 | [diff] [blame] | 291 | /** Validates a detection post process layer node |
| 292 | * |
| 293 | * @tparam DetectionPostProcessLayer DetectionOutput layer type |
| 294 | * |
| 295 | * @param[in] node Node to validate |
| 296 | * |
| 297 | * @return Status |
| 298 | */ |
| 299 | template <typename DetectionPostProcessLayer> |
| 300 | Status validate_detection_post_process_layer(DetectionPostProcessLayerNode &node) |
| 301 | { |
| 302 | ARM_COMPUTE_LOG_GRAPH_VERBOSE("Validating DetectionPostProcessLayer node with ID : " << node.id() << " and Name: " << node.name() << std::endl); |
| 303 | ARM_COMPUTE_RETURN_ERROR_ON(node.num_inputs() != 3); |
| 304 | ARM_COMPUTE_RETURN_ERROR_ON(node.num_outputs() != 4); |
| 305 | |
| 306 | // Extract IO and info |
| 307 | arm_compute::ITensorInfo *input0 = get_backing_tensor_info(node.input(0)); |
| 308 | arm_compute::ITensorInfo *input1 = get_backing_tensor_info(node.input(1)); |
| 309 | arm_compute::ITensorInfo *input2 = get_backing_tensor_info(node.input(2)); |
| 310 | arm_compute::ITensorInfo *output0 = get_backing_tensor_info(node.output(0)); |
| 311 | arm_compute::ITensorInfo *output1 = get_backing_tensor_info(node.output(1)); |
| 312 | arm_compute::ITensorInfo *output2 = get_backing_tensor_info(node.output(2)); |
| 313 | arm_compute::ITensorInfo *output3 = get_backing_tensor_info(node.output(3)); |
| 314 | const DetectionPostProcessLayerInfo detect_info = node.detection_post_process_info(); |
| 315 | |
| 316 | return DetectionPostProcessLayer::validate(input0, input1, input2, output0, output1, output2, output3, detect_info); |
| 317 | } |
Georgios Pinitas | 57c4824 | 2018-08-02 13:41:49 +0100 | [diff] [blame] | 318 | |
Manuel Bottini | 5209be5 | 2019-02-13 16:34:56 +0000 | [diff] [blame] | 319 | /** Validates a Generate Proposals layer node |
| 320 | * |
| 321 | * @tparam GenerateProposalsLayer Generate Proposals layer type |
| 322 | * |
| 323 | * @param[in] node Node to validate |
| 324 | * |
| 325 | * @return Status |
| 326 | */ |
| 327 | template <typename GenerateProposalsLayer> |
| 328 | Status validate_generate_proposals_layer(GenerateProposalsLayerNode &node) |
| 329 | { |
| 330 | ARM_COMPUTE_LOG_GRAPH_VERBOSE("Validating GenerateProposalsLayer node with ID : " << node.id() << " and Name: " << node.name() << std::endl); |
| 331 | ARM_COMPUTE_RETURN_ERROR_ON(node.num_inputs() != 3); |
| 332 | ARM_COMPUTE_RETURN_ERROR_ON(node.num_outputs() != 3); |
| 333 | |
| 334 | // Extract IO and info |
| 335 | arm_compute::ITensorInfo *scores = detail::get_backing_tensor_info(node.input(0)); |
| 336 | arm_compute::ITensorInfo *deltas = detail::get_backing_tensor_info(node.input(1)); |
| 337 | arm_compute::ITensorInfo *anchors = detail::get_backing_tensor_info(node.input(2)); |
| 338 | arm_compute::ITensorInfo *proposals = get_backing_tensor_info(node.output(0)); |
| 339 | arm_compute::ITensorInfo *scores_out = get_backing_tensor_info(node.output(1)); |
| 340 | arm_compute::ITensorInfo *num_valid_proposals = get_backing_tensor_info(node.output(2)); |
| 341 | const GenerateProposalsInfo info = node.info(); |
| 342 | |
| 343 | return GenerateProposalsLayer::validate(scores, deltas, anchors, proposals, scores_out, num_valid_proposals, info); |
| 344 | } |
| 345 | |
thecha01 | 3603aff | 2020-09-01 14:52:38 +0100 | [diff] [blame^] | 346 | /** Validates a L2Normalization layer node |
| 347 | * |
| 348 | * @tparam L2Normalization layer type |
| 349 | * |
| 350 | * @param[in] node Node to validate |
| 351 | * |
| 352 | * @return Status |
| 353 | */ |
| 354 | template <typename L2NormalizeLayer> |
| 355 | Status validate_l2_normalize_layer(L2NormalizeLayerNode &node) |
| 356 | { |
| 357 | ARM_COMPUTE_LOG_GRAPH_VERBOSE("Validating L2NormalizeLayerNode node with ID : " << node.id() << " and Name: " << node.name() << std::endl); |
| 358 | ARM_COMPUTE_RETURN_ERROR_ON(node.num_inputs() != 1); |
| 359 | ARM_COMPUTE_RETURN_ERROR_ON(node.num_outputs() != 1); |
| 360 | |
| 361 | // Extract IO and info |
| 362 | arm_compute::ITensorInfo *input = detail::get_backing_tensor_info(node.input(0)); |
| 363 | arm_compute::ITensorInfo *output = get_backing_tensor_info(node.output(0)); |
| 364 | int axis = node.axis(); |
| 365 | float epsilon = node.epsilon(); |
| 366 | |
| 367 | // Validate function |
| 368 | return L2NormalizeLayer::validate(input, output, axis, epsilon); |
| 369 | } |
| 370 | |
Michele Di Giorgio | 555d110 | 2018-09-12 13:51:59 +0100 | [diff] [blame] | 371 | /** Validates a NormalizePlanarYUV layer node |
| 372 | * |
| 373 | * @tparam NormalizePlanarYUVLayer layer type |
| 374 | * |
| 375 | * @param[in] node Node to validate |
| 376 | * |
| 377 | * @return Status |
| 378 | */ |
| 379 | template <typename NormalizePlanarYUVLayer> |
| 380 | Status validate_normalize_planar_yuv_layer(NormalizePlanarYUVLayerNode &node) |
| 381 | { |
| 382 | ARM_COMPUTE_LOG_GRAPH_VERBOSE("Validating NormalizePlanarYUVLayer node with ID : " << node.id() << " and Name: " << node.name() << std::endl); |
| 383 | ARM_COMPUTE_RETURN_ERROR_ON(node.num_inputs() != 3); |
| 384 | ARM_COMPUTE_RETURN_ERROR_ON(node.num_outputs() != 1); |
| 385 | |
| 386 | // Extract IO and info |
| 387 | arm_compute::ITensorInfo *input = detail::get_backing_tensor_info(node.input(0)); |
| 388 | arm_compute::ITensorInfo *mean = detail::get_backing_tensor_info(node.input(1)); |
| 389 | arm_compute::ITensorInfo *std = detail::get_backing_tensor_info(node.input(2)); |
| 390 | arm_compute::ITensorInfo *output = get_backing_tensor_info(node.output(0)); |
| 391 | |
| 392 | // Validate function |
| 393 | return NormalizePlanarYUVLayer::validate(input, output, mean, std); |
| 394 | } |
Michele Di Giorgio | 4bb1733 | 2018-09-26 13:56:51 +0100 | [diff] [blame] | 395 | |
| 396 | /** Validates a pad layer node |
| 397 | * |
| 398 | * @tparam PadLayer Pad layer type |
| 399 | * |
| 400 | * @param[in] node Node to validate |
| 401 | * |
| 402 | * @return Status |
| 403 | */ |
| 404 | template <typename PadLayer> |
| 405 | Status validate_pad_layer(PadLayerNode &node) |
| 406 | { |
| 407 | ARM_COMPUTE_LOG_GRAPH_VERBOSE("Validating PadLayer node with ID : " << node.id() << " and Name: " << node.name() << std::endl); |
| 408 | ARM_COMPUTE_RETURN_ERROR_ON(node.num_inputs() != 1); |
| 409 | ARM_COMPUTE_RETURN_ERROR_ON(node.num_outputs() != 1); |
| 410 | |
| 411 | // Extract IO and info |
| 412 | arm_compute::ITensorInfo *input = get_backing_tensor_info(node.input(0)); |
| 413 | arm_compute::ITensorInfo *output = get_backing_tensor_info(node.output(0)); |
| 414 | const PaddingList &padding = node.padding(); |
| 415 | |
| 416 | return PadLayer::validate(input, output, padding); |
| 417 | } |
| 418 | |
Georgios Pinitas | 57c4824 | 2018-08-02 13:41:49 +0100 | [diff] [blame] | 419 | /** Validates a permute layer node |
| 420 | * |
| 421 | * @tparam PermuteLayer Permute layer type |
| 422 | * |
| 423 | * @param[in] node Node to validate |
| 424 | * |
| 425 | * @return Status |
| 426 | */ |
| 427 | template <typename PermuteLayer> |
| 428 | Status validate_permute_layer(PermuteLayerNode &node) |
| 429 | { |
| 430 | ARM_COMPUTE_LOG_GRAPH_VERBOSE("Validating PermuteLayer node with ID : " << node.id() << " and Name: " << node.name() << std::endl); |
| 431 | ARM_COMPUTE_RETURN_ERROR_ON(node.num_inputs() != 1); |
| 432 | ARM_COMPUTE_RETURN_ERROR_ON(node.num_outputs() != 1); |
| 433 | |
| 434 | // Extract IO and info |
| 435 | arm_compute::ITensorInfo *input = get_backing_tensor_info(node.input(0)); |
| 436 | arm_compute::ITensorInfo *output = get_backing_tensor_info(node.output(0)); |
| 437 | const PermutationVector &perm = node.permutation_vector(); |
| 438 | |
| 439 | return PermuteLayer::validate(input, output, perm); |
| 440 | } |
Georgios Pinitas | f8c4749 | 2020-02-04 17:39:59 +0000 | [diff] [blame] | 441 | |
| 442 | /** Validates a PRelu layer node |
| 443 | * |
| 444 | * @tparam PReluLayer PRelu layer type |
| 445 | * |
| 446 | * @param[in] node Node to validate |
| 447 | * |
| 448 | * @return Status |
| 449 | */ |
| 450 | template <typename PReluLayer> |
| 451 | Status validate_prelu_layer(PReluLayerNode &node) |
| 452 | { |
| 453 | ARM_COMPUTE_LOG_GRAPH_VERBOSE("Validating PRelu node with ID : " << node.id() << " and Name: " << node.name() << std::endl); |
| 454 | ARM_COMPUTE_RETURN_ERROR_ON(node.num_inputs() != 2); |
| 455 | ARM_COMPUTE_RETURN_ERROR_ON(node.num_outputs() != 1); |
| 456 | |
| 457 | // Extract IO and info |
| 458 | arm_compute::ITensorInfo *input = get_backing_tensor_info(node.input(0)); |
| 459 | arm_compute::ITensorInfo *alpha = get_backing_tensor_info(node.input(1)); |
| 460 | arm_compute::ITensorInfo *output = get_backing_tensor_info(node.output(0)); |
| 461 | |
| 462 | return PReluLayer::validate(input, alpha, output); |
| 463 | } |
| 464 | |
Pablo Tello | 3252143 | 2018-11-15 14:43:10 +0000 | [diff] [blame] | 465 | /** Validates a priorbox layer node |
| 466 | * |
| 467 | * @tparam PriorBoxLayer PriorBox layer type |
| 468 | * |
| 469 | * @param[in] node Node to validate |
| 470 | * |
| 471 | * @return Status |
| 472 | */ |
| 473 | template <typename PriorBoxLayer> |
| 474 | Status validate_priorbox_layer(PriorBoxLayerNode &node) |
| 475 | { |
| 476 | ARM_COMPUTE_LOG_GRAPH_VERBOSE("Validating PriorBoxLayer node with ID : " << node.id() << " and Name: " << node.name() << std::endl); |
| 477 | ARM_COMPUTE_RETURN_ERROR_ON(node.num_inputs() != 2); |
| 478 | ARM_COMPUTE_RETURN_ERROR_ON(node.num_outputs() != 1); |
| 479 | |
| 480 | // Extract IO and info |
| 481 | arm_compute::ITensorInfo *input0 = get_backing_tensor_info(node.input(0)); |
| 482 | arm_compute::ITensorInfo *input1 = get_backing_tensor_info(node.input(1)); |
| 483 | arm_compute::ITensorInfo *output = get_backing_tensor_info(node.output(0)); |
| 484 | const PriorBoxLayerInfo prior_info = node.priorbox_info(); |
| 485 | |
| 486 | return PriorBoxLayer::validate(input0, input1, output, prior_info); |
| 487 | } |
Gian Marco Iodice | 23e2479 | 2018-09-07 15:32:14 +0100 | [diff] [blame] | 488 | |
Isabella Gottardi | 3db1ba9 | 2019-05-17 12:35:20 +0100 | [diff] [blame] | 489 | /** Validates a Quantization layer node |
| 490 | * |
| 491 | * @tparam QuantizationLayer Quantization layer type |
| 492 | * |
| 493 | * @param[in] node Node to validate |
| 494 | * |
| 495 | * @return Status |
| 496 | */ |
| 497 | template <typename QuantizationLayer> |
| 498 | Status validate_quantization_layer(QuantizationLayerNode &node) |
| 499 | { |
| 500 | ARM_COMPUTE_LOG_GRAPH_VERBOSE("Validating QuantizationLayer node with ID : " << node.id() << " and Name: " << node.name() << std::endl); |
| 501 | ARM_COMPUTE_RETURN_ERROR_ON(node.num_inputs() != 1); |
| 502 | ARM_COMPUTE_RETURN_ERROR_ON(node.num_outputs() != 1); |
| 503 | |
| 504 | // Extract input and output |
| 505 | arm_compute::ITensorInfo *input = detail::get_backing_tensor_info(node.input(0)); |
| 506 | arm_compute::ITensorInfo *output = get_backing_tensor_info(node.output(0)); |
| 507 | |
| 508 | // Validate function |
| 509 | return QuantizationLayer::validate(input, output); |
| 510 | } |
| 511 | |
Gian Marco Iodice | 23e2479 | 2018-09-07 15:32:14 +0100 | [diff] [blame] | 512 | /** Validates a Reorg layer node |
| 513 | * |
| 514 | * @tparam ReorgLayer Reorg layer type |
| 515 | * |
| 516 | * @param[in] node Node to validate |
| 517 | * |
| 518 | * @return Status |
| 519 | */ |
| 520 | template <typename ReorgLayer> |
| 521 | Status validate_reorg_layer(ReorgLayerNode &node) |
| 522 | { |
| 523 | ARM_COMPUTE_LOG_GRAPH_VERBOSE("Validating ReorgLayer node with ID : " << node.id() << " and Name: " << node.name() << std::endl); |
| 524 | ARM_COMPUTE_RETURN_ERROR_ON(node.num_inputs() != 1); |
| 525 | ARM_COMPUTE_RETURN_ERROR_ON(node.num_outputs() != 1); |
| 526 | |
| 527 | // Extract input and output |
| 528 | arm_compute::ITensorInfo *input = detail::get_backing_tensor_info(node.input(0)); |
| 529 | arm_compute::ITensorInfo *output = get_backing_tensor_info(node.output(0)); |
| 530 | |
| 531 | // Validate function |
| 532 | return ReorgLayer::validate(input, output, node.stride()); |
| 533 | } |
Michalis Spyrou | 96f6769 | 2018-09-13 11:39:28 +0100 | [diff] [blame] | 534 | |
Isabella Gottardi | 0ae5de9 | 2019-03-14 10:32:11 +0000 | [diff] [blame] | 535 | /** Validates a Reshape layer node |
| 536 | * |
| 537 | * @tparam ReshapeLayer Reshape layer type |
| 538 | * |
| 539 | * @param[in] node Node to validate |
| 540 | * |
| 541 | * @return Status |
| 542 | */ |
| 543 | template <typename ReshapeLayer> |
| 544 | Status validate_reshape_layer(ReshapeLayerNode &node) |
| 545 | { |
| 546 | ARM_COMPUTE_LOG_GRAPH_VERBOSE("Validating ReshapeLayer node with ID : " << node.id() << " and Name: " << node.name() << std::endl); |
| 547 | ARM_COMPUTE_RETURN_ERROR_ON(node.num_inputs() != 1); |
| 548 | ARM_COMPUTE_RETURN_ERROR_ON(node.num_outputs() != 1); |
| 549 | |
| 550 | // Extract input and output |
| 551 | arm_compute::ITensorInfo *input = detail::get_backing_tensor_info(node.input(0)); |
| 552 | arm_compute::ITensorInfo *output = detail::get_backing_tensor_info(node.output(0)); |
| 553 | |
| 554 | // Validate function |
| 555 | return ReshapeLayer::validate(input, output); |
| 556 | } |
| 557 | |
Manuel Bottini | 3f9d4d7 | 2018-10-19 14:04:42 +0100 | [diff] [blame] | 558 | /** Validates a ROI Align layer node |
| 559 | * |
| 560 | * @tparam ROIAlignLayer ROIAlign layer type |
| 561 | * |
| 562 | * @param[in] node Node to validate |
| 563 | * |
| 564 | * @return Status |
| 565 | */ |
| 566 | template <typename ROIAlignLayer> |
| 567 | Status validate_roi_align_layer(ROIAlignLayerNode &node) |
| 568 | { |
| 569 | ARM_COMPUTE_LOG_GRAPH_VERBOSE("Validating ROIAlignLayer node with ID : " << node.id() << " and Name: " << node.name() << std::endl); |
| 570 | ARM_COMPUTE_RETURN_ERROR_ON(node.num_inputs() != 2); |
| 571 | ARM_COMPUTE_RETURN_ERROR_ON(node.num_outputs() != 1); |
| 572 | |
| 573 | // Extract input and output |
| 574 | arm_compute::ITensorInfo *input = detail::get_backing_tensor_info(node.input(0)); |
| 575 | arm_compute::ITensorInfo *rois = detail::get_backing_tensor_info(node.input(1)); |
| 576 | arm_compute::ITensorInfo *output = detail::get_backing_tensor_info(node.output(0)); |
| 577 | const ROIPoolingLayerInfo &pool_info = node.pooling_info(); |
| 578 | |
| 579 | // Validate function |
| 580 | return ROIAlignLayer::validate(input, rois, output, pool_info); |
| 581 | } |
| 582 | |
Michele Di Giorgio | c30b668 | 2018-09-12 17:44:08 +0100 | [diff] [blame] | 583 | /** Validates a Slice layer node |
| 584 | * |
| 585 | * @tparam SliceLayer Slice layer function type |
| 586 | * |
| 587 | * @param[in] node Node to validate |
| 588 | * |
| 589 | * @return Status |
| 590 | */ |
| 591 | template <typename SliceLayer> |
| 592 | Status validate_slice_layer(SliceLayerNode &node) |
| 593 | { |
| 594 | ARM_COMPUTE_LOG_GRAPH_VERBOSE("Validating Slice node with ID : " << node.id() << " and Name: " << node.name() << std::endl); |
| 595 | ARM_COMPUTE_RETURN_ERROR_ON(node.num_inputs() != 1); |
| 596 | ARM_COMPUTE_RETURN_ERROR_ON(node.num_outputs() != 1); |
| 597 | |
| 598 | // Extract IO and info |
| 599 | arm_compute::ITensorInfo *input = get_backing_tensor_info(node.input(0)); |
| 600 | arm_compute::ITensorInfo *output = get_backing_tensor_info(node.output(0)); |
| 601 | const Coordinates starts = node.starts(); |
| 602 | const Coordinates ends = node.ends(); |
| 603 | |
| 604 | return SliceLayer::validate(input, output, starts, ends); |
| 605 | } |
| 606 | |
thecha01 | 2bfadd9 | 2020-08-12 17:25:51 +0100 | [diff] [blame] | 607 | /** Validates a Strided Slice layer node |
| 608 | * |
| 609 | * @tparam StridedSliceLayer Strided Slice layer function type |
| 610 | * |
| 611 | * @param[in] node Node to validate |
| 612 | * |
| 613 | * @return Status |
| 614 | */ |
| 615 | template <typename StridedSliceLayer> |
| 616 | Status validate_strided_slice_layer(StridedSliceLayerNode &node) |
| 617 | { |
| 618 | ARM_COMPUTE_LOG_GRAPH_VERBOSE("Validating StridedSlice node with ID : " << node.id() << " and Name: " << node.name() << std::endl); |
| 619 | ARM_COMPUTE_RETURN_ERROR_ON(node.num_inputs() != 1); |
| 620 | ARM_COMPUTE_RETURN_ERROR_ON(node.num_outputs() != 1); |
| 621 | |
| 622 | // Extract IO and info |
| 623 | arm_compute::ITensorInfo *input = get_backing_tensor_info(node.input(0)); |
| 624 | arm_compute::ITensorInfo *output = get_backing_tensor_info(node.output(0)); |
| 625 | const Coordinates starts = node.starts(); |
| 626 | const Coordinates ends = node.ends(); |
| 627 | const BiStrides strides = node.strides(); |
| 628 | const StridedSliceLayerInfo info = node.strided_slice_info(); |
| 629 | |
| 630 | return StridedSliceLayer::validate(input, output, starts, ends, strides, info.begin_mask(), info.end_mask(), info.shrink_axis_mask()); |
| 631 | } |
| 632 | |
Michalis Spyrou | 4e1c3f3 | 2018-09-20 17:14:03 +0100 | [diff] [blame] | 633 | /** Validates a Upsample layer node |
| 634 | * |
| 635 | * @tparam UpsampleLayer Upsample layer type |
| 636 | * |
| 637 | * @param[in] node Node to validate |
| 638 | * |
| 639 | * @return Status |
| 640 | */ |
| 641 | template <typename UpsampleLayer> |
| 642 | Status validate_upsample_layer(UpsampleLayerNode &node) |
| 643 | { |
| 644 | ARM_COMPUTE_LOG_GRAPH_VERBOSE("Validating UpsampleLayer node with ID : " << node.id() << " and Name: " << node.name() << std::endl); |
| 645 | ARM_COMPUTE_RETURN_ERROR_ON(node.num_inputs() != 1); |
| 646 | ARM_COMPUTE_RETURN_ERROR_ON(node.num_outputs() != 1); |
| 647 | |
| 648 | // Extract input and output |
| 649 | arm_compute::ITensorInfo *input = detail::get_backing_tensor_info(node.input(0)); |
| 650 | arm_compute::ITensorInfo *output = get_backing_tensor_info(node.output(0)); |
| 651 | |
| 652 | // Validate function |
| 653 | return UpsampleLayer::validate(input, output, node.info(), node.upsampling_policy()); |
| 654 | } |
Michalis Spyrou | 96f6769 | 2018-09-13 11:39:28 +0100 | [diff] [blame] | 655 | /** Validates a YOLO layer node |
| 656 | * |
| 657 | * @tparam YOLOLayer YOLO layer type |
| 658 | * |
| 659 | * @param[in] node Node to validate |
| 660 | * |
| 661 | * @return Status |
| 662 | */ |
| 663 | template <typename YOLOLayer> |
| 664 | Status validate_yolo_layer(YOLOLayerNode &node) |
| 665 | { |
| 666 | ARM_COMPUTE_LOG_GRAPH_VERBOSE("Validating YOLOLayer node with ID : " << node.id() << " and Name: " << node.name() << std::endl); |
| 667 | ARM_COMPUTE_RETURN_ERROR_ON(node.num_inputs() != 1); |
| 668 | ARM_COMPUTE_RETURN_ERROR_ON(node.num_outputs() != 1); |
| 669 | |
| 670 | // Extract input and output |
| 671 | arm_compute::ITensorInfo *input = detail::get_backing_tensor_info(node.input(0)); |
| 672 | arm_compute::ITensorInfo *output = get_backing_tensor_info(node.output(0)); |
| 673 | |
| 674 | // Validate function |
| 675 | return YOLOLayer::validate(input, output, node.activation_info(), node.num_classes()); |
| 676 | } |
Sheri Zhang | 16dddd2 | 2020-05-27 15:03:48 +0100 | [diff] [blame] | 677 | /** Validates a element-wise layer node |
| 678 | * |
| 679 | * @param[in] node Node to validate |
| 680 | * |
| 681 | * @return Status |
| 682 | */ |
| 683 | template <typename EltwiseLayerFunctions> |
| 684 | Status validate_eltwise_Layer(EltwiseLayerNode &node) |
| 685 | { |
| 686 | ARM_COMPUTE_LOG_GRAPH_VERBOSE("Validating EltwiseLayer node with ID : " << node.id() << " and Name: " << node.name() << std::endl); |
| 687 | ARM_COMPUTE_RETURN_ERROR_ON(node.num_inputs() != 2); |
| 688 | ARM_COMPUTE_RETURN_ERROR_ON(node.num_outputs() != 1); |
| 689 | |
| 690 | // Extract input and output |
| 691 | const arm_compute::ITensorInfo *input1 = detail::get_backing_tensor_info(node.input(0)); |
| 692 | const arm_compute::ITensorInfo *input2 = detail::get_backing_tensor_info(node.input(1)); |
| 693 | const arm_compute::ITensorInfo *output = get_backing_tensor_info(node.output(0)); |
| 694 | const EltwiseOperation eltwise_op = node.eltwise_operation(); |
| 695 | const ConvertPolicy convert_policy = node.convert_policy(); |
| 696 | const RoundingPolicy round_policy = node.rounding_policy(); |
| 697 | const ActivationLayerInfo act_info = node.fused_activation(); |
| 698 | const QuantizationInfo quant_info = node.output_quant_info(); |
Sheri Zhang | 16dddd2 | 2020-05-27 15:03:48 +0100 | [diff] [blame] | 699 | |
| 700 | // Validate function |
| 701 | if(eltwise_op == EltwiseOperation::Add) |
| 702 | { |
| 703 | return EltwiseLayerFunctions::ArithmeticAddition::validate(input1, input2, output, convert_policy, act_info); |
| 704 | } |
| 705 | else if(eltwise_op == EltwiseOperation::Sub) |
| 706 | { |
| 707 | return EltwiseLayerFunctions::ArithmeticSubtraction::validate(input1, input2, output, convert_policy, act_info); |
| 708 | } |
| 709 | else if(eltwise_op == EltwiseOperation::Mul) |
| 710 | { |
Manuel Bottini | 7e725cf | 2020-08-12 16:05:16 +0100 | [diff] [blame] | 711 | return EltwiseLayerFunctions::PixelWiseMultiplication::validate(input1, input2, output, 1.0f, convert_policy, round_policy, act_info); |
Sheri Zhang | 16dddd2 | 2020-05-27 15:03:48 +0100 | [diff] [blame] | 712 | } |
thecha01 | f8e3584 | 2020-07-28 17:28:17 +0100 | [diff] [blame] | 713 | else if(eltwise_op == EltwiseOperation::Max) |
| 714 | { |
| 715 | return EltwiseLayerFunctions::ElementwiseMax::validate(input1, input2, output, act_info); |
| 716 | } |
Sheri Zhang | 16dddd2 | 2020-05-27 15:03:48 +0100 | [diff] [blame] | 717 | else |
| 718 | { |
| 719 | ARM_COMPUTE_ERROR("Unsupported element-wise operation!"); |
| 720 | } |
| 721 | return Status{}; |
| 722 | } |
| 723 | /** Validates a unary element-wise layer node |
| 724 | * |
| 725 | * @param[in] node Node to validate |
| 726 | * |
| 727 | * @return Status |
| 728 | */ |
| 729 | template <typename UnaryEltwiseLayerFunctions> |
| 730 | Status validate_unary_eltwise_layer(UnaryEltwiseLayerNode &node) |
| 731 | { |
| 732 | ARM_COMPUTE_LOG_GRAPH_VERBOSE("Validating EltwiseLayer node with ID : " << node.id() << " and Name: " << node.name() << std::endl); |
| 733 | ARM_COMPUTE_RETURN_ERROR_ON(node.num_inputs() != 1); |
| 734 | ARM_COMPUTE_RETURN_ERROR_ON(node.num_outputs() != 1); |
| 735 | |
| 736 | // Extract input and output |
| 737 | arm_compute::ITensorInfo *input = detail::get_backing_tensor_info(node.input(0)); |
| 738 | arm_compute::ITensorInfo *output = get_backing_tensor_info(node.output(0)); |
| 739 | const UnaryEltwiseOperation eltwise_op = node.eltwise_descriptor().op; |
| 740 | |
| 741 | // Validate function |
| 742 | if(eltwise_op == UnaryEltwiseOperation::Exp) |
| 743 | { |
| 744 | return UnaryEltwiseLayerFunctions::ExpLayer::validate(input, output); |
| 745 | } |
| 746 | else |
| 747 | { |
| 748 | ARM_COMPUTE_ERROR("Unsupported unary element-wise operation!"); |
| 749 | } |
| 750 | |
| 751 | return Status{}; |
| 752 | } |
Georgios Pinitas | 2870516 | 2018-03-21 20:10:53 +0000 | [diff] [blame] | 753 | } // namespace detail |
| 754 | } // namespace backends |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 755 | } // namespace graph |
Georgios Pinitas | 2870516 | 2018-03-21 20:10:53 +0000 | [diff] [blame] | 756 | } // namespace arm_compute |
| 757 | |
Michalis Spyrou | f464337 | 2019-11-29 16:17:13 +0000 | [diff] [blame] | 758 | #endif /* ARM_COMPUTE_GRAPH_BACKENDS_DETAIL_VALIDATE_HELPERS_H */ |