Compute Library
 21.02
NENodeValidator.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018-2021 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  */
25 
28 
43 #include "support/Cast.h"
44 
45 using namespace arm_compute::utils::cast;
46 
47 namespace arm_compute
48 {
49 namespace graph
50 {
51 namespace backends
52 {
53 /** Collection of Neon element-wise functions */
54 struct NEEltwiseLayerFunctions
55 {
56  using ArithmeticAddition = NEArithmeticAddition;
57  using ArithmeticSubtraction = NEArithmeticSubtraction;
58  using PixelWiseMultiplication = NEPixelWiseMultiplication;
59  using ElementwiseMax = NEElementwiseMax;
60 };
61 
62 /** Collection of Neon unary element-wise functions */
63 struct NEUnaryEltwiseLayerFunctions
64 {
65  using ExpLayer = NEExpLayer;
66 };
67 
69 {
70  if(node == nullptr)
71  {
72  return Status{};
73  }
74 
75  NodeType type = node->type();
76  switch(type)
77  {
78  case NodeType::ArgMinMaxLayer:
79  return detail::validate_arg_min_max_layer<NEArgMinMaxLayer>(*polymorphic_downcast<ArgMinMaxLayerNode *>(node));
80  case NodeType::BoundingBoxTransformLayer:
81  return ARM_COMPUTE_CREATE_ERROR(arm_compute::ErrorCode::RUNTIME_ERROR, "Unsupported operation : BoundingBoxTransformLayer");
82  case NodeType::ChannelShuffleLayer:
83  return detail::validate_channel_shuffle_layer<NEChannelShuffleLayer>(*polymorphic_downcast<ChannelShuffleLayerNode *>(node));
84  case NodeType::ConvolutionLayer:
88  NEWinogradConvolutionLayer>(*polymorphic_downcast<ConvolutionLayerNode *>(node));
89  case NodeType::DepthToSpaceLayer:
90  return detail::validate_depth_to_space_layer<NEDepthToSpaceLayer>(*polymorphic_downcast<DepthToSpaceLayerNode *>(node));
91  case NodeType::DepthwiseConvolutionLayer:
92  return detail::validate_depthwise_convolution_layer<NEDepthwiseConvolutionLayer>(*polymorphic_downcast<DepthwiseConvolutionLayerNode *>(node));
93  case NodeType::DequantizationLayer:
94  return detail::validate_dequantization_layer<NEDequantizationLayer>(*polymorphic_downcast<DequantizationLayerNode *>(node));
95  case NodeType::DetectionOutputLayer:
96  return detail::validate_detection_output_layer<CPPDetectionOutputLayer>(*polymorphic_downcast<DetectionOutputLayerNode *>(node));
97  case NodeType::DetectionPostProcessLayer:
98  return detail::validate_detection_post_process_layer<NEDetectionPostProcessLayer>(*polymorphic_downcast<DetectionPostProcessLayerNode *>(node));
99  case NodeType::GenerateProposalsLayer:
100  return ARM_COMPUTE_CREATE_ERROR(arm_compute::ErrorCode::RUNTIME_ERROR, "Unsupported operation : GenerateProposalsLayer");
101  case NodeType::L2NormalizeLayer:
102  return detail::validate_l2_normalize_layer<NEL2NormalizeLayer>(*polymorphic_downcast<L2NormalizeLayerNode *>(node));
103  case NodeType::NormalizePlanarYUVLayer:
104  return ARM_COMPUTE_CREATE_ERROR(arm_compute::ErrorCode::RUNTIME_ERROR, "Unsupported operation : NormalizePlanarYUVLayer");
105  case NodeType::PadLayer:
106  return detail::validate_pad_layer<NEPadLayer>(*polymorphic_downcast<PadLayerNode *>(node));
107  case NodeType::PermuteLayer:
108  return detail::validate_permute_layer<NEPermute>(*polymorphic_downcast<PermuteLayerNode *>(node));
109  case NodeType::PReluLayer:
110  return detail::validate_prelu_layer<NEPReluLayer>(*polymorphic_downcast<PReluLayerNode *>(node));
111  case NodeType::PriorBoxLayer:
112  return detail::validate_priorbox_layer<NEPriorBoxLayer>(*polymorphic_downcast<PriorBoxLayerNode *>(node));
113  case NodeType::QuantizationLayer:
114  return detail::validate_quantization_layer<NEQuantizationLayer>(*polymorphic_downcast<QuantizationLayerNode *>(node));
115  case NodeType::ReductionOperationLayer:
116  return detail::validate_reduction_operation_layer<NEReductionOperation>(*polymorphic_downcast<ReductionLayerNode *>(node));
117  case NodeType::ReorgLayer:
118  return detail::validate_reorg_layer<NEReorgLayer>(*polymorphic_downcast<ReorgLayerNode *>(node));
119  case NodeType::ReshapeLayer:
120  return detail::validate_reshape_layer<NEReshapeLayer>(*polymorphic_downcast<ReshapeLayerNode *>(node));
121  case NodeType::ROIAlignLayer:
122  return ARM_COMPUTE_CREATE_ERROR(arm_compute::ErrorCode::RUNTIME_ERROR, "Unsupported operation : ROIAlignLayer");
123  case NodeType::SliceLayer:
124  return detail::validate_slice_layer<NESlice>(*polymorphic_downcast<SliceLayerNode *>(node));
125  case NodeType::StridedSliceLayer:
126  return detail::validate_strided_slice_layer<NEStridedSlice>(*polymorphic_downcast<StridedSliceLayerNode *>(node));
127  case NodeType::EltwiseLayer:
128  return detail::validate_eltwise_Layer<NEEltwiseLayerFunctions>(*polymorphic_downcast<EltwiseLayerNode *>(node));
129  case NodeType::UnaryEltwiseLayer:
130  return detail::validate_unary_eltwise_layer<NEUnaryEltwiseLayerFunctions>(*polymorphic_downcast<UnaryEltwiseLayerNode *>(node));
131  default:
132  return Status{};
133  }
134 }
135 } // namespace backends
136 } // namespace graph
137 } // namespace arm_compute
NEElementwiseUnaryLayer< ElementWiseUnary::EXP > NEExpLayer
Status class.
Definition: Error.h:52
decltype(strategy::transforms) typedef type
Basic function to compute the convolution layer.
Includes all the Neon functions at once.
Copyright (c) 2017-2021 Arm Limited.
Node interface.
Definition: INode.h:45
Basic function to simulate a convolution layer.
Basic function to simulate a convolution layer.
NodeType
Supported nodes.
Definition: Types.h:142
Function to run the direct convolution.
#define ARM_COMPUTE_CREATE_ERROR(error_code, msg)
Creates an error with a given message.
Definition: Error.h:159
Status validate_convolution_layer(ConvolutionLayerNode &node)
Validates a Convolution layer node.
virtual NodeType type() const =0
Returns node&#39;s type.
Status validate(const ITensorInfo *scores_in, const ITensorInfo *boxes_in, const ITensorInfo *batch_splits_in, const ITensorInfo *scores_out, const ITensorInfo *boxes_out, const ITensorInfo *classes, const ITensorInfo *batch_splits_out, const ITensorInfo *keeps, const ITensorInfo *keeps_size, const BoxNMSLimitInfo info)