Georgios Pinitas | 2870516 | 2018-03-21 20:10:53 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2018 ARM Limited. |
| 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 | */ |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [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 | |
Manuel Bottini | d2048ce | 2018-10-23 17:00:42 +0100 | [diff] [blame] | 55 | /** Validates a Bounding Box Transform layer node |
| 56 | * |
| 57 | * @tparam BoundingBoxTransformLayer Bounding Box Transform layer function type |
| 58 | * |
| 59 | * @param[in] node Node to validate |
| 60 | * |
| 61 | * @return Status |
| 62 | */ |
| 63 | template <typename BoundingBoxTransformLayer> |
| 64 | Status validate_bounding_box_transform_layer(BoundingBoxTransformLayerNode &node) |
| 65 | { |
| 66 | ARM_COMPUTE_LOG_GRAPH_VERBOSE("Validating BoundingBoxTransformLayer node with ID : " << node.id() << " and Name: " << node.name() << std::endl); |
| 67 | ARM_COMPUTE_RETURN_ERROR_ON(node.num_inputs() != 2); |
| 68 | ARM_COMPUTE_RETURN_ERROR_ON(node.num_outputs() != 1); |
| 69 | |
| 70 | // Extract IO and info |
| 71 | arm_compute::ITensorInfo *input = get_backing_tensor_info(node.input(0)); |
| 72 | arm_compute::ITensorInfo *deltas = get_backing_tensor_info(node.input(1)); |
| 73 | arm_compute::ITensorInfo *output = get_backing_tensor_info(node.output(0)); |
| 74 | const BoundingBoxTransformInfo bbox_info = node.info(); |
| 75 | |
| 76 | return BoundingBoxTransformLayer::validate(input, output, deltas, bbox_info); |
| 77 | } |
| 78 | |
Georgios Pinitas | 087eaf6 | 2018-05-16 15:52:35 +0100 | [diff] [blame] | 79 | /** Validates a Channel Shuffle layer node |
| 80 | * |
| 81 | * @tparam ChannelShuffleLayer Channel Shuffle layer function type |
| 82 | * |
| 83 | * @param[in] node Node to validate |
| 84 | * |
| 85 | * @return Status |
| 86 | */ |
| 87 | template <typename ChannelShuffleLayer> |
| 88 | Status validate_channel_shuffle_layer(ChannelShuffleLayerNode &node) |
| 89 | { |
| 90 | ARM_COMPUTE_LOG_GRAPH_VERBOSE("Validating ChannelShuffle node with ID : " << node.id() << " and Name: " << node.name() << std::endl); |
| 91 | ARM_COMPUTE_RETURN_ERROR_ON(node.num_inputs() != 1); |
| 92 | ARM_COMPUTE_RETURN_ERROR_ON(node.num_outputs() != 1); |
| 93 | |
| 94 | // Extract IO and info |
| 95 | arm_compute::ITensorInfo *input = get_backing_tensor_info(node.input(0)); |
| 96 | arm_compute::ITensorInfo *output = get_backing_tensor_info(node.output(0)); |
| 97 | const unsigned int num_groups = node.num_groups(); |
| 98 | |
| 99 | return ChannelShuffleLayer::validate(input, output, num_groups); |
| 100 | } |
| 101 | |
Georgios Pinitas | 2870516 | 2018-03-21 20:10:53 +0000 | [diff] [blame] | 102 | /** Validates a Convolution layer node |
| 103 | * |
| 104 | * @tparam ConvolutionLayer Default Convolution layer function type |
| 105 | * @tparam DirectConvolutionLayer Direct Convolution layer function type |
| 106 | * @tparam GEMMConvolutionLayer GEMM Convolution layer function type |
| 107 | * @tparam WinogradConvolutionLayer Winograd Convolution layer function type |
| 108 | * |
| 109 | * @param[in] node Node to validate |
| 110 | * |
| 111 | * @return Status |
| 112 | */ |
| 113 | template <typename ConvolutionLayer, typename DirectConvolutionLayer, typename GEMMConvolutionLayer, typename WinogradConvolutionLayer> |
| 114 | Status validate_convolution_layer(ConvolutionLayerNode &node) |
| 115 | { |
| 116 | ARM_COMPUTE_LOG_GRAPH_VERBOSE("Validating ConvolutionLayer node with ID : " << node.id() << " and Name: " << node.name() << std::endl); |
| 117 | ARM_COMPUTE_RETURN_ERROR_ON(node.num_inputs() != 3); |
| 118 | ARM_COMPUTE_RETURN_ERROR_ON(node.num_outputs() != 1); |
| 119 | |
| 120 | // Extract IO and info |
Giorgio Arena | bb54e4e | 2018-04-05 17:20:34 +0100 | [diff] [blame] | 121 | arm_compute::ITensorInfo *input = get_backing_tensor_info(node.input(0)); |
| 122 | arm_compute::ITensorInfo *weights = get_backing_tensor_info(node.input(1)); |
| 123 | arm_compute::ITensorInfo *biases = get_backing_tensor_info(node.input(2)); |
| 124 | arm_compute::ITensorInfo *output = get_backing_tensor_info(node.output(0)); |
| 125 | |
| 126 | if(is_data_type_quantized_asymmetric(input->data_type())) |
| 127 | { |
| 128 | biases->set_data_type(DataType::S32); |
| 129 | } |
| 130 | |
| 131 | const PadStrideInfo conv_info = node.convolution_info(); |
| 132 | const ConvolutionMethod conv_algorithm = node.convolution_method(); |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 133 | const bool fast_math = node.fast_math_hint() == FastMathHint::Enabled; |
Georgios Pinitas | 2a2db59 | 2018-08-15 12:14:46 +0100 | [diff] [blame] | 134 | const unsigned int num_groups = node.num_groups(); |
Georgios Pinitas | 2870516 | 2018-03-21 20:10:53 +0000 | [diff] [blame] | 135 | |
| 136 | // Validate function |
| 137 | Status status{}; |
| 138 | switch(conv_algorithm) |
| 139 | { |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 140 | case ConvolutionMethod::Direct: |
Georgios Pinitas | 2a2db59 | 2018-08-15 12:14:46 +0100 | [diff] [blame] | 141 | 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] | 142 | status = DirectConvolutionLayer::validate(input, weights, biases, output, conv_info); |
| 143 | break; |
| 144 | case ConvolutionMethod::GEMM: |
Georgios Pinitas | 2a2db59 | 2018-08-15 12:14:46 +0100 | [diff] [blame] | 145 | status = GEMMConvolutionLayer::validate(input, weights, biases, output, conv_info, |
| 146 | WeightsInfo(), Size2D(1, 1), ActivationLayerInfo(), num_groups); |
Georgios Pinitas | 2870516 | 2018-03-21 20:10:53 +0000 | [diff] [blame] | 147 | break; |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 148 | case ConvolutionMethod::Winograd: |
Georgios Pinitas | 2a2db59 | 2018-08-15 12:14:46 +0100 | [diff] [blame] | 149 | 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] | 150 | status = WinogradConvolutionLayer::validate(input, weights, biases, output, conv_info, ActivationLayerInfo(), fast_math); |
Georgios Pinitas | 2870516 | 2018-03-21 20:10:53 +0000 | [diff] [blame] | 151 | break; |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 152 | case ConvolutionMethod::Default: |
Georgios Pinitas | 2a2db59 | 2018-08-15 12:14:46 +0100 | [diff] [blame] | 153 | status = ConvolutionLayer::validate(input, weights, biases, output, conv_info, |
| 154 | WeightsInfo(), Size2D(1, 1), ActivationLayerInfo(), fast_math, num_groups); |
Georgios Pinitas | 54d6fae | 2018-05-10 15:50:14 +0100 | [diff] [blame] | 155 | break; |
Georgios Pinitas | 2870516 | 2018-03-21 20:10:53 +0000 | [diff] [blame] | 156 | default: |
Georgios Pinitas | 2a2db59 | 2018-08-15 12:14:46 +0100 | [diff] [blame] | 157 | ARM_COMPUTE_RETURN_ERROR_MSG("Unsupported convolution method"); |
Georgios Pinitas | 2870516 | 2018-03-21 20:10:53 +0000 | [diff] [blame] | 158 | } |
| 159 | |
| 160 | return status; |
| 161 | } |
| 162 | |
| 163 | /** Validates a Depthwise Convolution layer node |
| 164 | * |
| 165 | * @tparam DepthwiseConvolutionLayer Default Depthwise Convolution layer type |
| 166 | * @tparam DepthwiseConvolutionLayer3x3 Optimized 3x3 Depthwise Convolution layer type |
| 167 | * |
| 168 | * @param[in] node Node to validate |
| 169 | * |
| 170 | * @return Status |
| 171 | */ |
| 172 | template <typename DepthwiseConvolutionLayer, typename DepthwiseConvolutionLayer3x3> |
| 173 | Status validate_depthwise_convolution_layer(DepthwiseConvolutionLayerNode &node) |
| 174 | { |
| 175 | ARM_COMPUTE_LOG_GRAPH_VERBOSE("Validating DepthwiseConvolutionLayer node with ID : " << node.id() << " and Name: " << node.name() << std::endl); |
| 176 | ARM_COMPUTE_RETURN_ERROR_ON(node.num_inputs() != 3); |
| 177 | ARM_COMPUTE_RETURN_ERROR_ON(node.num_outputs() != 1); |
| 178 | |
| 179 | // Extract IO and info |
Georgios Pinitas | 2a2db59 | 2018-08-15 12:14:46 +0100 | [diff] [blame] | 180 | arm_compute::ITensorInfo *input = detail::get_backing_tensor_info(node.input(0)); |
| 181 | arm_compute::ITensorInfo *weights = detail::get_backing_tensor_info(node.input(1)); |
| 182 | arm_compute::ITensorInfo *biases = get_backing_tensor_info(node.input(2)); |
| 183 | arm_compute::ITensorInfo *output = get_backing_tensor_info(node.output(0)); |
Georgios Pinitas | 2870516 | 2018-03-21 20:10:53 +0000 | [diff] [blame] | 184 | |
Georgios Pinitas | 05045c1 | 2018-12-07 18:31:47 +0000 | [diff] [blame] | 185 | const PadStrideInfo conv_info = node.convolution_info(); |
| 186 | const DepthwiseConvolutionMethod dwc_algorithm = node.depthwise_convolution_method(); |
| 187 | const int depth_multiplier = node.depth_multiplier(); |
Georgios Pinitas | 2a2db59 | 2018-08-15 12:14:46 +0100 | [diff] [blame] | 188 | |
Georgios Pinitas | 2870516 | 2018-03-21 20:10:53 +0000 | [diff] [blame] | 189 | // Validate function |
Georgios Pinitas | 2a2db59 | 2018-08-15 12:14:46 +0100 | [diff] [blame] | 190 | Status status{}; |
| 191 | switch(dwc_algorithm) |
Georgios Pinitas | 2870516 | 2018-03-21 20:10:53 +0000 | [diff] [blame] | 192 | { |
Georgios Pinitas | 2a2db59 | 2018-08-15 12:14:46 +0100 | [diff] [blame] | 193 | case DepthwiseConvolutionMethod::Default: |
| 194 | case DepthwiseConvolutionMethod::GEMV: |
Georgios Pinitas | 05045c1 | 2018-12-07 18:31:47 +0000 | [diff] [blame] | 195 | status = DepthwiseConvolutionLayer::validate(input, weights, biases, output, conv_info, depth_multiplier); |
Georgios Pinitas | 2a2db59 | 2018-08-15 12:14:46 +0100 | [diff] [blame] | 196 | break; |
| 197 | case DepthwiseConvolutionMethod::Optimized3x3: |
Georgios Pinitas | 05045c1 | 2018-12-07 18:31:47 +0000 | [diff] [blame] | 198 | status = DepthwiseConvolutionLayer3x3::validate(input, weights, biases, output, conv_info, depth_multiplier); |
Georgios Pinitas | 2a2db59 | 2018-08-15 12:14:46 +0100 | [diff] [blame] | 199 | break; |
| 200 | default: |
| 201 | ARM_COMPUTE_RETURN_ERROR_MSG("Unsupported depthwise convolution method"); |
Georgios Pinitas | 2870516 | 2018-03-21 20:10:53 +0000 | [diff] [blame] | 202 | } |
| 203 | |
Georgios Pinitas | 2a2db59 | 2018-08-15 12:14:46 +0100 | [diff] [blame] | 204 | return status; |
Georgios Pinitas | 2870516 | 2018-03-21 20:10:53 +0000 | [diff] [blame] | 205 | } |
Isabella Gottardi | 7234ed8 | 2018-11-27 08:51:10 +0000 | [diff] [blame] | 206 | /** Validates a detection output layer node |
| 207 | * |
| 208 | * @tparam DetectionOutputLayer DetectionOutput layer type |
| 209 | * |
| 210 | * @param[in] node Node to validate |
| 211 | * |
| 212 | * @return Status |
| 213 | */ |
| 214 | template <typename DetectionOutputLayer> |
| 215 | Status validate_detection_output_layer(DetectionOutputLayerNode &node) |
| 216 | { |
| 217 | ARM_COMPUTE_LOG_GRAPH_VERBOSE("Validating DetectionOutputLayer node with ID : " << node.id() << " and Name: " << node.name() << std::endl); |
| 218 | ARM_COMPUTE_RETURN_ERROR_ON(node.num_inputs() != 3); |
| 219 | ARM_COMPUTE_RETURN_ERROR_ON(node.num_outputs() != 1); |
| 220 | |
| 221 | // Extract IO and info |
| 222 | arm_compute::ITensorInfo *input0 = get_backing_tensor_info(node.input(0)); |
| 223 | arm_compute::ITensorInfo *input1 = get_backing_tensor_info(node.input(1)); |
| 224 | arm_compute::ITensorInfo *input2 = get_backing_tensor_info(node.input(2)); |
| 225 | arm_compute::ITensorInfo *output = get_backing_tensor_info(node.output(0)); |
| 226 | const DetectionOutputLayerInfo detect_info = node.detection_output_info(); |
| 227 | |
| 228 | return DetectionOutputLayer::validate(input0, input1, input2, output, detect_info); |
| 229 | } |
Georgios Pinitas | 57c4824 | 2018-08-02 13:41:49 +0100 | [diff] [blame] | 230 | |
Michele Di Giorgio | 47e6fed | 2018-11-13 12:04:25 +0000 | [diff] [blame] | 231 | /** Validates a Generate Proposals layer node |
| 232 | * |
| 233 | * @tparam GenerateProposalsLayer Generate Proposals layer type |
| 234 | * |
| 235 | * @param[in] node Node to validate |
| 236 | * |
| 237 | * @return Status |
| 238 | */ |
| 239 | template <typename GenerateProposalsLayer> |
| 240 | Status validate_generate_proposals_layer(GenerateProposalsLayerNode &node) |
| 241 | { |
| 242 | ARM_COMPUTE_LOG_GRAPH_VERBOSE("Validating GenerateProposalsLayer node with ID : " << node.id() << " and Name: " << node.name() << std::endl); |
| 243 | ARM_COMPUTE_RETURN_ERROR_ON(node.num_inputs() != 3); |
| 244 | ARM_COMPUTE_RETURN_ERROR_ON(node.num_outputs() != 3); |
| 245 | |
| 246 | // Extract IO and info |
| 247 | arm_compute::ITensorInfo *scores = detail::get_backing_tensor_info(node.input(0)); |
| 248 | arm_compute::ITensorInfo *deltas = detail::get_backing_tensor_info(node.input(1)); |
| 249 | arm_compute::ITensorInfo *anchors = detail::get_backing_tensor_info(node.input(2)); |
| 250 | arm_compute::ITensorInfo *proposals = get_backing_tensor_info(node.output(0)); |
| 251 | arm_compute::ITensorInfo *scores_out = get_backing_tensor_info(node.output(1)); |
| 252 | arm_compute::ITensorInfo *num_valid_proposals = get_backing_tensor_info(node.output(2)); |
| 253 | const GenerateProposalsInfo info = node.info(); |
| 254 | |
| 255 | return GenerateProposalsLayer::validate(scores, deltas, anchors, proposals, scores_out, num_valid_proposals, info); |
| 256 | } |
| 257 | |
Michele Di Giorgio | 555d110 | 2018-09-12 13:51:59 +0100 | [diff] [blame] | 258 | /** Validates a NormalizePlanarYUV layer node |
| 259 | * |
| 260 | * @tparam NormalizePlanarYUVLayer layer type |
| 261 | * |
| 262 | * @param[in] node Node to validate |
| 263 | * |
| 264 | * @return Status |
| 265 | */ |
| 266 | template <typename NormalizePlanarYUVLayer> |
| 267 | Status validate_normalize_planar_yuv_layer(NormalizePlanarYUVLayerNode &node) |
| 268 | { |
| 269 | ARM_COMPUTE_LOG_GRAPH_VERBOSE("Validating NormalizePlanarYUVLayer node with ID : " << node.id() << " and Name: " << node.name() << std::endl); |
| 270 | ARM_COMPUTE_RETURN_ERROR_ON(node.num_inputs() != 3); |
| 271 | ARM_COMPUTE_RETURN_ERROR_ON(node.num_outputs() != 1); |
| 272 | |
| 273 | // Extract IO and info |
| 274 | arm_compute::ITensorInfo *input = detail::get_backing_tensor_info(node.input(0)); |
| 275 | arm_compute::ITensorInfo *mean = detail::get_backing_tensor_info(node.input(1)); |
| 276 | arm_compute::ITensorInfo *std = detail::get_backing_tensor_info(node.input(2)); |
| 277 | arm_compute::ITensorInfo *output = get_backing_tensor_info(node.output(0)); |
| 278 | |
| 279 | // Validate function |
| 280 | return NormalizePlanarYUVLayer::validate(input, output, mean, std); |
| 281 | } |
Michele Di Giorgio | 4bb1733 | 2018-09-26 13:56:51 +0100 | [diff] [blame] | 282 | |
| 283 | /** Validates a pad layer node |
| 284 | * |
| 285 | * @tparam PadLayer Pad layer type |
| 286 | * |
| 287 | * @param[in] node Node to validate |
| 288 | * |
| 289 | * @return Status |
| 290 | */ |
| 291 | template <typename PadLayer> |
| 292 | Status validate_pad_layer(PadLayerNode &node) |
| 293 | { |
| 294 | ARM_COMPUTE_LOG_GRAPH_VERBOSE("Validating PadLayer node with ID : " << node.id() << " and Name: " << node.name() << std::endl); |
| 295 | ARM_COMPUTE_RETURN_ERROR_ON(node.num_inputs() != 1); |
| 296 | ARM_COMPUTE_RETURN_ERROR_ON(node.num_outputs() != 1); |
| 297 | |
| 298 | // Extract IO and info |
| 299 | arm_compute::ITensorInfo *input = get_backing_tensor_info(node.input(0)); |
| 300 | arm_compute::ITensorInfo *output = get_backing_tensor_info(node.output(0)); |
| 301 | const PaddingList &padding = node.padding(); |
| 302 | |
| 303 | return PadLayer::validate(input, output, padding); |
| 304 | } |
| 305 | |
Georgios Pinitas | 57c4824 | 2018-08-02 13:41:49 +0100 | [diff] [blame] | 306 | /** Validates a permute layer node |
| 307 | * |
| 308 | * @tparam PermuteLayer Permute layer type |
| 309 | * |
| 310 | * @param[in] node Node to validate |
| 311 | * |
| 312 | * @return Status |
| 313 | */ |
| 314 | template <typename PermuteLayer> |
| 315 | Status validate_permute_layer(PermuteLayerNode &node) |
| 316 | { |
| 317 | ARM_COMPUTE_LOG_GRAPH_VERBOSE("Validating PermuteLayer node with ID : " << node.id() << " and Name: " << node.name() << std::endl); |
| 318 | ARM_COMPUTE_RETURN_ERROR_ON(node.num_inputs() != 1); |
| 319 | ARM_COMPUTE_RETURN_ERROR_ON(node.num_outputs() != 1); |
| 320 | |
| 321 | // Extract IO and info |
| 322 | arm_compute::ITensorInfo *input = get_backing_tensor_info(node.input(0)); |
| 323 | arm_compute::ITensorInfo *output = get_backing_tensor_info(node.output(0)); |
| 324 | const PermutationVector &perm = node.permutation_vector(); |
| 325 | |
| 326 | return PermuteLayer::validate(input, output, perm); |
| 327 | } |
Pablo Tello | 3252143 | 2018-11-15 14:43:10 +0000 | [diff] [blame] | 328 | /** Validates a priorbox layer node |
| 329 | * |
| 330 | * @tparam PriorBoxLayer PriorBox layer type |
| 331 | * |
| 332 | * @param[in] node Node to validate |
| 333 | * |
| 334 | * @return Status |
| 335 | */ |
| 336 | template <typename PriorBoxLayer> |
| 337 | Status validate_priorbox_layer(PriorBoxLayerNode &node) |
| 338 | { |
| 339 | ARM_COMPUTE_LOG_GRAPH_VERBOSE("Validating PriorBoxLayer node with ID : " << node.id() << " and Name: " << node.name() << std::endl); |
| 340 | ARM_COMPUTE_RETURN_ERROR_ON(node.num_inputs() != 2); |
| 341 | ARM_COMPUTE_RETURN_ERROR_ON(node.num_outputs() != 1); |
| 342 | |
| 343 | // Extract IO and info |
| 344 | arm_compute::ITensorInfo *input0 = get_backing_tensor_info(node.input(0)); |
| 345 | arm_compute::ITensorInfo *input1 = get_backing_tensor_info(node.input(1)); |
| 346 | arm_compute::ITensorInfo *output = get_backing_tensor_info(node.output(0)); |
| 347 | const PriorBoxLayerInfo prior_info = node.priorbox_info(); |
| 348 | |
| 349 | return PriorBoxLayer::validate(input0, input1, output, prior_info); |
| 350 | } |
Gian Marco Iodice | 23e2479 | 2018-09-07 15:32:14 +0100 | [diff] [blame] | 351 | |
| 352 | /** Validates a Reorg layer node |
| 353 | * |
| 354 | * @tparam ReorgLayer Reorg layer type |
| 355 | * |
| 356 | * @param[in] node Node to validate |
| 357 | * |
| 358 | * @return Status |
| 359 | */ |
| 360 | template <typename ReorgLayer> |
| 361 | Status validate_reorg_layer(ReorgLayerNode &node) |
| 362 | { |
| 363 | ARM_COMPUTE_LOG_GRAPH_VERBOSE("Validating ReorgLayer node with ID : " << node.id() << " and Name: " << node.name() << std::endl); |
| 364 | ARM_COMPUTE_RETURN_ERROR_ON(node.num_inputs() != 1); |
| 365 | ARM_COMPUTE_RETURN_ERROR_ON(node.num_outputs() != 1); |
| 366 | |
| 367 | // Extract input and output |
| 368 | arm_compute::ITensorInfo *input = detail::get_backing_tensor_info(node.input(0)); |
| 369 | arm_compute::ITensorInfo *output = get_backing_tensor_info(node.output(0)); |
| 370 | |
| 371 | // Validate function |
| 372 | return ReorgLayer::validate(input, output, node.stride()); |
| 373 | } |
Michalis Spyrou | 96f6769 | 2018-09-13 11:39:28 +0100 | [diff] [blame] | 374 | |
Manuel Bottini | 3f9d4d7 | 2018-10-19 14:04:42 +0100 | [diff] [blame] | 375 | /** Validates a ROI Align layer node |
| 376 | * |
| 377 | * @tparam ROIAlignLayer ROIAlign layer type |
| 378 | * |
| 379 | * @param[in] node Node to validate |
| 380 | * |
| 381 | * @return Status |
| 382 | */ |
| 383 | template <typename ROIAlignLayer> |
| 384 | Status validate_roi_align_layer(ROIAlignLayerNode &node) |
| 385 | { |
| 386 | ARM_COMPUTE_LOG_GRAPH_VERBOSE("Validating ROIAlignLayer node with ID : " << node.id() << " and Name: " << node.name() << std::endl); |
| 387 | ARM_COMPUTE_RETURN_ERROR_ON(node.num_inputs() != 2); |
| 388 | ARM_COMPUTE_RETURN_ERROR_ON(node.num_outputs() != 1); |
| 389 | |
| 390 | // Extract input and output |
| 391 | arm_compute::ITensorInfo *input = detail::get_backing_tensor_info(node.input(0)); |
| 392 | arm_compute::ITensorInfo *rois = detail::get_backing_tensor_info(node.input(1)); |
| 393 | arm_compute::ITensorInfo *output = detail::get_backing_tensor_info(node.output(0)); |
| 394 | const ROIPoolingLayerInfo &pool_info = node.pooling_info(); |
| 395 | |
| 396 | // Validate function |
| 397 | return ROIAlignLayer::validate(input, rois, output, pool_info); |
| 398 | } |
| 399 | |
Michele Di Giorgio | c30b668 | 2018-09-12 17:44:08 +0100 | [diff] [blame] | 400 | /** Validates a Slice layer node |
| 401 | * |
| 402 | * @tparam SliceLayer Slice layer function type |
| 403 | * |
| 404 | * @param[in] node Node to validate |
| 405 | * |
| 406 | * @return Status |
| 407 | */ |
| 408 | template <typename SliceLayer> |
| 409 | Status validate_slice_layer(SliceLayerNode &node) |
| 410 | { |
| 411 | ARM_COMPUTE_LOG_GRAPH_VERBOSE("Validating Slice node with ID : " << node.id() << " and Name: " << node.name() << std::endl); |
| 412 | ARM_COMPUTE_RETURN_ERROR_ON(node.num_inputs() != 1); |
| 413 | ARM_COMPUTE_RETURN_ERROR_ON(node.num_outputs() != 1); |
| 414 | |
| 415 | // Extract IO and info |
| 416 | arm_compute::ITensorInfo *input = get_backing_tensor_info(node.input(0)); |
| 417 | arm_compute::ITensorInfo *output = get_backing_tensor_info(node.output(0)); |
| 418 | const Coordinates starts = node.starts(); |
| 419 | const Coordinates ends = node.ends(); |
| 420 | |
| 421 | return SliceLayer::validate(input, output, starts, ends); |
| 422 | } |
| 423 | |
Michalis Spyrou | 4e1c3f3 | 2018-09-20 17:14:03 +0100 | [diff] [blame] | 424 | /** Validates a Upsample layer node |
| 425 | * |
| 426 | * @tparam UpsampleLayer Upsample layer type |
| 427 | * |
| 428 | * @param[in] node Node to validate |
| 429 | * |
| 430 | * @return Status |
| 431 | */ |
| 432 | template <typename UpsampleLayer> |
| 433 | Status validate_upsample_layer(UpsampleLayerNode &node) |
| 434 | { |
| 435 | ARM_COMPUTE_LOG_GRAPH_VERBOSE("Validating UpsampleLayer node with ID : " << node.id() << " and Name: " << node.name() << std::endl); |
| 436 | ARM_COMPUTE_RETURN_ERROR_ON(node.num_inputs() != 1); |
| 437 | ARM_COMPUTE_RETURN_ERROR_ON(node.num_outputs() != 1); |
| 438 | |
| 439 | // Extract input and output |
| 440 | arm_compute::ITensorInfo *input = detail::get_backing_tensor_info(node.input(0)); |
| 441 | arm_compute::ITensorInfo *output = get_backing_tensor_info(node.output(0)); |
| 442 | |
| 443 | // Validate function |
| 444 | return UpsampleLayer::validate(input, output, node.info(), node.upsampling_policy()); |
| 445 | } |
Michalis Spyrou | 96f6769 | 2018-09-13 11:39:28 +0100 | [diff] [blame] | 446 | /** Validates a YOLO layer node |
| 447 | * |
| 448 | * @tparam YOLOLayer YOLO layer type |
| 449 | * |
| 450 | * @param[in] node Node to validate |
| 451 | * |
| 452 | * @return Status |
| 453 | */ |
| 454 | template <typename YOLOLayer> |
| 455 | Status validate_yolo_layer(YOLOLayerNode &node) |
| 456 | { |
| 457 | ARM_COMPUTE_LOG_GRAPH_VERBOSE("Validating YOLOLayer node with ID : " << node.id() << " and Name: " << node.name() << std::endl); |
| 458 | ARM_COMPUTE_RETURN_ERROR_ON(node.num_inputs() != 1); |
| 459 | ARM_COMPUTE_RETURN_ERROR_ON(node.num_outputs() != 1); |
| 460 | |
| 461 | // Extract input and output |
| 462 | arm_compute::ITensorInfo *input = detail::get_backing_tensor_info(node.input(0)); |
| 463 | arm_compute::ITensorInfo *output = get_backing_tensor_info(node.output(0)); |
| 464 | |
| 465 | // Validate function |
| 466 | return YOLOLayer::validate(input, output, node.activation_info(), node.num_classes()); |
| 467 | } |
Georgios Pinitas | 2870516 | 2018-03-21 20:10:53 +0000 | [diff] [blame] | 468 | } // namespace detail |
| 469 | } // namespace backends |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 470 | } // namespace graph |
Georgios Pinitas | 2870516 | 2018-03-21 20:10:53 +0000 | [diff] [blame] | 471 | } // namespace arm_compute |
| 472 | |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 473 | #endif /* __ARM_COMPUTE_GRAPH_BACKENDS_DETAIL_VALIDATE_HELPERS_H__ */ |