blob: 75bba4c43c70b38f34def71adc101300f8b43137 [file] [log] [blame]
Georgios Pinitas28705162018-03-21 20:10:53 +00001/*
Georgios Pinitas0f7ef8a2021-01-10 04:23:52 +00002 * Copyright (c) 2018-2021 Arm Limited.
Georgios Pinitas28705162018-03-21 20:10:53 +00003 *
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 Pinitasd9eb2752018-04-03 13:44:29 +010024#include "arm_compute/graph/backends/NEON/NENodeValidator.h"
Georgios Pinitas28705162018-03-21 20:10:53 +000025
Georgios Pinitasd9eb2752018-04-03 13:44:29 +010026#include "arm_compute/graph/backends/ValidateHelpers.h"
27#include "arm_compute/graph/nodes/Nodes.h"
Georgios Pinitas28705162018-03-21 20:10:53 +000028
Isabella Gottardi7234ed82018-11-27 08:51:10 +000029#include "arm_compute/runtime/CPP/CPPFunctions.h"
Georgios Pinitas28705162018-03-21 20:10:53 +000030#include "arm_compute/runtime/NEON/NEFunctions.h"
Michalis Spyrouebcebf12020-10-21 00:04:14 +010031#include "src/core/NEON/kernels/NEConvertFullyConnectedWeightsKernel.h"
32#include "src/core/NEON/kernels/NEConvertQuantizedSignednessKernel.h"
33#include "src/core/NEON/kernels/NEGEMMInterleave4x4Kernel.h"
34#include "src/core/NEON/kernels/NEGEMMLowpMatrixMultiplyKernel.h"
35#include "src/core/NEON/kernels/NEGEMMLowpOffsetContributionKernel.h"
36#include "src/core/NEON/kernels/NEGEMMLowpOffsetContributionOutputStageKernel.h"
37#include "src/core/NEON/kernels/NEGEMMLowpReductionKernel.h"
38#include "src/core/NEON/kernels/NEGEMMMatrixAdditionKernel.h"
39#include "src/core/NEON/kernels/NEGEMMMatrixMultiplyKernel.h"
40#include "src/core/NEON/kernels/NEGEMMTranspose1xWKernel.h"
41#include "src/core/NEON/kernels/NEQLSTMLayerNormalizationKernel.h"
Michalis Spyrouebcebf12020-10-21 00:04:14 +010042#include "src/core/NEON/kernels/NEWeightsReshapeKernel.h"
Sang-Hoon Park68dd25f2020-10-19 16:00:11 +010043#include "support/Cast.h"
Georgios Pinitas28705162018-03-21 20:10:53 +000044
45using namespace arm_compute::utils::cast;
46
47namespace arm_compute
48{
Georgios Pinitasd9eb2752018-04-03 13:44:29 +010049namespace graph
Georgios Pinitas28705162018-03-21 20:10:53 +000050{
51namespace backends
52{
Sheri Zhang16dddd22020-05-27 15:03:48 +010053/** Collection of NEON element-wise functions */
54struct NEEltwiseLayerFunctions
55{
56 using ArithmeticAddition = NEArithmeticAddition;
57 using ArithmeticSubtraction = NEArithmeticSubtraction;
58 using PixelWiseMultiplication = NEPixelWiseMultiplication;
thecha01f8e35842020-07-28 17:28:17 +010059 using ElementwiseMax = NEElementwiseMax;
Sheri Zhang16dddd22020-05-27 15:03:48 +010060};
61
62/** Collection of NEON unary element-wise functions */
63struct NEUnaryEltwiseLayerFunctions
64{
65 using ExpLayer = NEExpLayer;
66};
67
Georgios Pinitas28705162018-03-21 20:10:53 +000068Status NENodeValidator::validate(INode *node)
69{
70 if(node == nullptr)
71 {
72 return Status{};
73 }
74
75 NodeType type = node->type();
76 switch(type)
77 {
thecha01e8f05da2020-08-24 17:21:41 +010078 case NodeType::ArgMinMaxLayer:
79 return detail::validate_arg_min_max_layer<NEArgMinMaxLayer>(*polymorphic_downcast<ArgMinMaxLayerNode *>(node));
Manuel Bottinid2048ce2018-10-23 17:00:42 +010080 case NodeType::BoundingBoxTransformLayer:
81 return ARM_COMPUTE_CREATE_ERROR(arm_compute::ErrorCode::RUNTIME_ERROR, "Unsupported operation : BoundingBoxTransformLayer");
Georgios Pinitas087eaf62018-05-16 15:52:35 +010082 case NodeType::ChannelShuffleLayer:
Georgios Pinitasf1adf112018-11-02 12:54:18 +000083 return detail::validate_channel_shuffle_layer<NEChannelShuffleLayer>(*polymorphic_downcast<ChannelShuffleLayerNode *>(node));
Georgios Pinitas28705162018-03-21 20:10:53 +000084 case NodeType::ConvolutionLayer:
85 return detail::validate_convolution_layer<NEConvolutionLayer,
86 NEDirectConvolutionLayer,
87 NEGEMMConvolutionLayer,
Georgios Pinitas9fb11592018-04-26 20:34:58 +010088 NEWinogradConvolutionLayer>(*polymorphic_downcast<ConvolutionLayerNode *>(node));
thecha010a05e6a2020-08-28 18:40:38 +010089 case NodeType::DepthToSpaceLayer:
90 return detail::validate_depth_to_space_layer<NEDepthToSpaceLayer>(*polymorphic_downcast<DepthToSpaceLayerNode *>(node));
Georgios Pinitas28705162018-03-21 20:10:53 +000091 case NodeType::DepthwiseConvolutionLayer:
Manuel Bottini05069f02019-09-26 17:18:26 +010092 return detail::validate_depthwise_convolution_layer<NEDepthwiseConvolutionLayer>(*polymorphic_downcast<DepthwiseConvolutionLayerNode *>(node));
Isabella Gottardicd4e9ab2019-11-05 17:50:27 +000093 case NodeType::DequantizationLayer:
94 return detail::validate_dequantization_layer<NEDequantizationLayer>(*polymorphic_downcast<DequantizationLayerNode *>(node));
Isabella Gottardi7234ed82018-11-27 08:51:10 +000095 case NodeType::DetectionOutputLayer:
96 return detail::validate_detection_output_layer<CPPDetectionOutputLayer>(*polymorphic_downcast<DetectionOutputLayerNode *>(node));
Isabella Gottardia7acb3c2019-01-08 13:48:44 +000097 case NodeType::DetectionPostProcessLayer:
Giuseppe Rossinid9853782019-10-25 11:11:44 +010098 return detail::validate_detection_post_process_layer<NEDetectionPostProcessLayer>(*polymorphic_downcast<DetectionPostProcessLayerNode *>(node));
Manuel Bottini5209be52019-02-13 16:34:56 +000099 case NodeType::GenerateProposalsLayer:
100 return ARM_COMPUTE_CREATE_ERROR(arm_compute::ErrorCode::RUNTIME_ERROR, "Unsupported operation : GenerateProposalsLayer");
thecha013603aff2020-09-01 14:52:38 +0100101 case NodeType::L2NormalizeLayer:
102 return detail::validate_l2_normalize_layer<NEL2NormalizeLayer>(*polymorphic_downcast<L2NormalizeLayerNode *>(node));
Michele Di Giorgioc30b6682018-09-12 17:44:08 +0100103 case NodeType::NormalizePlanarYUVLayer:
104 return ARM_COMPUTE_CREATE_ERROR(arm_compute::ErrorCode::RUNTIME_ERROR, "Unsupported operation : NormalizePlanarYUVLayer");
Michele Di Giorgio4bb17332018-09-26 13:56:51 +0100105 case NodeType::PadLayer:
Georgios Pinitas07fbe372020-02-04 13:21:02 +0000106 return detail::validate_pad_layer<NEPadLayer>(*polymorphic_downcast<PadLayerNode *>(node));
Georgios Pinitas57c48242018-08-02 13:41:49 +0100107 case NodeType::PermuteLayer:
108 return detail::validate_permute_layer<NEPermute>(*polymorphic_downcast<PermuteLayerNode *>(node));
Georgios Pinitasf8c47492020-02-04 17:39:59 +0000109 case NodeType::PReluLayer:
110 return detail::validate_prelu_layer<NEPReluLayer>(*polymorphic_downcast<PReluLayerNode *>(node));
Pablo Tello32521432018-11-15 14:43:10 +0000111 case NodeType::PriorBoxLayer:
112 return detail::validate_priorbox_layer<NEPriorBoxLayer>(*polymorphic_downcast<PriorBoxLayerNode *>(node));
Isabella Gottardi3db1ba92019-05-17 12:35:20 +0100113 case NodeType::QuantizationLayer:
114 return detail::validate_quantization_layer<NEQuantizationLayer>(*polymorphic_downcast<QuantizationLayerNode *>(node));
thecha01d64444b2020-09-07 14:50:21 +0100115 case NodeType::ReductionOperationLayer:
116 return detail::validate_reduction_operation_layer<NEReductionOperation>(*polymorphic_downcast<ReductionLayerNode *>(node));
Gian Marco Iodice23e24792018-09-07 15:32:14 +0100117 case NodeType::ReorgLayer:
118 return detail::validate_reorg_layer<NEReorgLayer>(*polymorphic_downcast<ReorgLayerNode *>(node));
Isabella Gottardi0ae5de92019-03-14 10:32:11 +0000119 case NodeType::ReshapeLayer:
120 return detail::validate_reshape_layer<NEReshapeLayer>(*polymorphic_downcast<ReshapeLayerNode *>(node));
Manuel Bottini3f9d4d72018-10-19 14:04:42 +0100121 case NodeType::ROIAlignLayer:
122 return ARM_COMPUTE_CREATE_ERROR(arm_compute::ErrorCode::RUNTIME_ERROR, "Unsupported operation : ROIAlignLayer");
Michele Di Giorgioc30b6682018-09-12 17:44:08 +0100123 case NodeType::SliceLayer:
Georgios Pinitas0b1c2db2020-12-04 15:51:34 +0000124 return detail::validate_slice_layer<NESlice>(*polymorphic_downcast<SliceLayerNode *>(node));
thecha012bfadd92020-08-12 17:25:51 +0100125 case NodeType::StridedSliceLayer:
126 return detail::validate_strided_slice_layer<NEStridedSlice>(*polymorphic_downcast<StridedSliceLayerNode *>(node));
Sheri Zhang16dddd22020-05-27 15:03:48 +0100127 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));
Georgios Pinitas28705162018-03-21 20:10:53 +0000131 default:
132 return Status{};
133 }
134}
135} // namespace backends
Georgios Pinitasd9eb2752018-04-03 13:44:29 +0100136} // namespace graph
Michele Di Giorgioc30b6682018-09-12 17:44:08 +0100137} // namespace arm_compute