Compute Library
 23.08
CLNodeValidator.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 
31 
32 #include "support/Cast.h"
33 
34 using namespace arm_compute::utils::cast;
35 
36 namespace arm_compute
37 {
38 namespace graph
39 {
40 namespace backends
41 {
42 /** Collection of CL element-wise functions */
43 struct CLEltwiseLayerFunctions
44 {
45  using ArithmeticAddition = CLArithmeticAddition;
46  using ArithmeticSubtraction = CLArithmeticSubtraction;
47  using PixelWiseMultiplication = CLPixelWiseMultiplication;
48  using ElementwiseMax = CLElementwiseMax;
49  using ArithmeticDivision = CLArithmeticDivision;
50 };
51 
52 /** Collection of CL unary element-wise functions */
53 struct CLUnaryEltwiseLayerFunctions
54 {
55  using ExpLayer = CLExpLayer;
56 };
57 
59 {
60  if(node == nullptr)
61  {
62  return Status{};
63  }
64 
65  NodeType type = node->type();
66  switch(type)
67  {
68  case NodeType::ArgMinMaxLayer:
69  return detail::validate_arg_min_max_layer<CLArgMinMaxLayer>(*polymorphic_downcast<ArgMinMaxLayerNode *>(node));
70  case NodeType::BoundingBoxTransformLayer:
71  return detail::validate_bounding_box_transform_layer<CLBoundingBoxTransform>(*polymorphic_downcast<BoundingBoxTransformLayerNode *>(node));
72  case NodeType::ChannelShuffleLayer:
73  return detail::validate_channel_shuffle_layer<CLChannelShuffleLayer>(*polymorphic_downcast<ChannelShuffleLayerNode *>(node));
74  case NodeType::ConvolutionLayer:
78  CLWinogradConvolutionLayer>(*polymorphic_downcast<ConvolutionLayerNode *>(node));
79  case NodeType::FusedConvolutionWithPostOp:
80  return detail::validate_fused_convolution_with_post_op<CLGEMMConvolutionLayer>(*polymorphic_downcast<FusedConvolutionWithPostOpNode *>(node));
81  case NodeType::DepthToSpaceLayer:
82  return detail::validate_depth_to_space_layer<CLDepthToSpaceLayer>(*polymorphic_downcast<DepthToSpaceLayerNode *>(node));
83  case NodeType::DepthwiseConvolutionLayer:
84  return detail::validate_depthwise_convolution_layer<CLDepthwiseConvolutionLayer>(*polymorphic_downcast<DepthwiseConvolutionLayerNode *>(node));
85  case NodeType::DequantizationLayer:
86  return detail::validate_dequantization_layer<CLDequantizationLayer>(*polymorphic_downcast<DequantizationLayerNode *>(node));
87  case NodeType::DetectionOutputLayer:
88  return detail::validate_detection_output_layer<CPPDetectionOutputLayer>(*polymorphic_downcast<DetectionOutputLayerNode *>(node));
89  case NodeType::DetectionPostProcessLayer:
90  return detail::validate_detection_post_process_layer<CPPDetectionPostProcessLayer>(*polymorphic_downcast<DetectionPostProcessLayerNode *>(node));
91  case NodeType::GenerateProposalsLayer:
92  return detail::validate_generate_proposals_layer<CLGenerateProposalsLayer>(*polymorphic_downcast<GenerateProposalsLayerNode *>(node));
93  case NodeType::L2NormalizeLayer:
94  return detail::validate_l2_normalize_layer<CLL2NormalizeLayer>(*polymorphic_downcast<L2NormalizeLayerNode *>(node));
95  case NodeType::NormalizePlanarYUVLayer:
96  return detail::validate_normalize_planar_yuv_layer<CLNormalizePlanarYUVLayer>(*polymorphic_downcast<NormalizePlanarYUVLayerNode *>(node));
97  case NodeType::PadLayer:
98  return detail::validate_pad_layer<CLPadLayer>(*polymorphic_downcast<PadLayerNode *>(node));
99  case NodeType::PermuteLayer:
100  return detail::validate_permute_layer<CLPermute>(*polymorphic_downcast<PermuteLayerNode *>(node));
101  case NodeType::PReluLayer:
102  return detail::validate_prelu_layer<CLPReluLayer>(*polymorphic_downcast<PReluLayerNode *>(node));
103  case NodeType::PriorBoxLayer:
104  return detail::validate_priorbox_layer<CLPriorBoxLayer>(*polymorphic_downcast<PriorBoxLayerNode *>(node));
105  case NodeType::QuantizationLayer:
106  return detail::validate_quantization_layer<CLQuantizationLayer>(*polymorphic_downcast<QuantizationLayerNode *>(node));
107  case NodeType::ReductionOperationLayer:
108  return detail::validate_reduction_operation_layer<CLReductionOperation>(*polymorphic_downcast<ReductionLayerNode *>(node));
109  case NodeType::ReorgLayer:
110  return detail::validate_reorg_layer<CLReorgLayer>(*polymorphic_downcast<ReorgLayerNode *>(node));
111  case NodeType::ReshapeLayer:
112  return detail::validate_reshape_layer<CLReshapeLayer>(*polymorphic_downcast<ReshapeLayerNode *>(node));
113  case NodeType::ROIAlignLayer:
114  return detail::validate_roi_align_layer<CLROIAlignLayer>(*polymorphic_downcast<ROIAlignLayerNode *>(node));
115  case NodeType::SliceLayer:
116  return detail::validate_slice_layer<CLSlice>(*polymorphic_downcast<SliceLayerNode *>(node));
117  case NodeType::StridedSliceLayer:
118  return detail::validate_strided_slice_layer<CLStridedSlice>(*polymorphic_downcast<StridedSliceLayerNode *>(node));
119  case NodeType::EltwiseLayer:
120  return detail::validate_eltwise_Layer<CLEltwiseLayerFunctions>(*polymorphic_downcast<EltwiseLayerNode *>(node));
121  case NodeType::UnaryEltwiseLayer:
122  return detail::validate_unary_eltwise_layer<CLUnaryEltwiseLayerFunctions>(*polymorphic_downcast<UnaryEltwiseLayerNode *>(node));
123  default:
124  return Status{};
125  }
126 }
127 } // namespace backends
128 } // namespace graph
129 } // namespace arm_compute
Cast.h
type
decltype(strategy::transforms) typedef type
Definition: gemm_interleaved.hpp:261
arm_compute::graph::backends::detail::validate_convolution_layer
Status validate_convolution_layer(ConvolutionLayerNode &node)
Validates a Convolution layer node.
Definition: ValidateHelpers.h:137
arm_compute::CLConvolutionLayer
Basic function to compute the convolution layer.
Definition: CLConvolutionLayer.h:76
arm_compute::CLWinogradConvolutionLayer
Basic function to execute Winograd-based convolution on OpenCL.
Definition: CLWinogradConvolutionLayer.h:45
CPPFunctions.h
CLNodeValidator.h
arm_compute::graph::INode
Node interface.
Definition: INode.h:46
arm_compute::Status
Status class.
Definition: Error.h:52
arm_compute::graph::NodeType
NodeType
Supported nodes.
Definition: Types.h:203
arm_compute::utils::cast
Definition: Cast.h:33
arm_compute::CLDirectConvolutionLayer
Basic function to execute direct convolution function:
Definition: CLDirectConvolutionLayer.h:42
Nodes.h
arm_compute::graph::INode::type
virtual NodeType type() const =0
Returns node's type.
arm_compute
Copyright (c) 2017-2023 Arm Limited.
Definition: introduction.dox:24
ValidateHelpers.h
arm_compute::validate
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)
Definition: CPPBoxWithNonMaximaSuppressionLimit.cpp:214
CLFunctions.h
Includes all the OpenCL functions at once.
arm_compute::CLGEMMConvolutionLayer
Basic function to compute the convolution layer.
Definition: CLGEMMConvolutionLayer.h:48