From 0b1c2db5c29ed80b7f4dd0c4fd6d4ed91b3d1538 Mon Sep 17 00:00:00 2001 From: Georgios Pinitas Date: Fri, 4 Dec 2020 15:51:34 +0000 Subject: Remove (NE/CL)YoloLayer support YOLO layer is too specialized and specific to a single model type. Can be decomposed using split, activation and concatenate layers Partially Resolves: COMPMID-3996 Signed-off-by: Georgios Pinitas Change-Id: I3cde88f8d4cc7d8c70ce1bb3b32b00f8d09bdca2 Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/4678 Tested-by: Arm Jenkins Reviewed-by: Michele Di Giorgio --- arm_compute/graph/GraphBuilder.h | 11 +++-- arm_compute/graph/TypePrinter.h | 3 -- arm_compute/graph/Types.h | 1 - arm_compute/graph/backends/FunctionHelpers.h | 43 ------------------ arm_compute/graph/backends/ValidateHelpers.h | 22 ---------- arm_compute/graph/frontend/Layers.h | 7 ++- arm_compute/graph/nodes/Nodes.h | 1 - arm_compute/graph/nodes/NodesFwd.h | 1 - arm_compute/graph/nodes/SliceLayerNode.h | 4 +- arm_compute/graph/nodes/YOLOLayerNode.h | 66 ---------------------------- 10 files changed, 10 insertions(+), 149 deletions(-) delete mode 100644 arm_compute/graph/nodes/YOLOLayerNode.h (limited to 'arm_compute/graph') diff --git a/arm_compute/graph/GraphBuilder.h b/arm_compute/graph/GraphBuilder.h index f29db3f081..54bb33d1a4 100644 --- a/arm_compute/graph/GraphBuilder.h +++ b/arm_compute/graph/GraphBuilder.h @@ -584,15 +584,14 @@ public: static NodeID add_upsample_node(Graph &g, NodeParams params, NodeIdxPair input, Size2D info, InterpolationPolicy upsampling_policy); /** Adds a yolo layer to the graph * - * @param[in] g Graph to add the node to - * @param[in] params Common node parameters - * @param[in] input Input to the yolo layer node as a NodeID-Index pair - * @param[in] act_info Activation layer parameters - * @param[in] num_classes Number of classes to activate + * @param[in] g Graph to add the node to + * @param[in] params Common node parameters + * @param[in] input Input to the yolo layer node as a NodeID-Index pair + * @param[in] act_info Activation layer parameters * * @return Node ID of the created node, EmptyNodeID in case of error */ - static NodeID add_yolo_node(Graph &g, NodeParams params, NodeIdxPair input, ActivationLayerInfo act_info, int32_t num_classes); + static NodeID add_yolo_node(Graph &g, NodeParams params, NodeIdxPair input, ActivationLayerInfo act_info); }; } // namespace graph } // namespace arm_compute diff --git a/arm_compute/graph/TypePrinter.h b/arm_compute/graph/TypePrinter.h index e8024980c1..62bacae89f 100644 --- a/arm_compute/graph/TypePrinter.h +++ b/arm_compute/graph/TypePrinter.h @@ -185,9 +185,6 @@ inline ::std::ostream &operator<<(::std::ostream &os, const NodeType &node_type) case NodeType::UpsampleLayer: os << "UpsampleLayer"; break; - case NodeType::YOLOLayer: - os << "YOLOLayer"; - break; case NodeType::Input: os << "Input"; break; diff --git a/arm_compute/graph/Types.h b/arm_compute/graph/Types.h index 5f851ac67e..c5d3d17a9b 100644 --- a/arm_compute/graph/Types.h +++ b/arm_compute/graph/Types.h @@ -181,7 +181,6 @@ enum class NodeType StridedSliceLayer, UpsampleLayer, UnaryEltwiseLayer, - YOLOLayer, Input, Output, diff --git a/arm_compute/graph/backends/FunctionHelpers.h b/arm_compute/graph/backends/FunctionHelpers.h index 05bd483cfd..18fdb9f3bb 100644 --- a/arm_compute/graph/backends/FunctionHelpers.h +++ b/arm_compute/graph/backends/FunctionHelpers.h @@ -1885,49 +1885,6 @@ std::unique_ptr create_upsample_layer(UpsampleLayerNode &node, GraphC return RETURN_UNIQUE_PTR(func); } -/** Create a backend YOLO layer function - * - * @tparam YoloLayerFunction Backend YOLO function - * @tparam TargetInfo Target-specific information - * - * @param[in] node Node to create the backend function for - * @param[in] ctx Graph context - * - * @return Backend YOLO layer function - */ -template -std::unique_ptr create_yolo_layer(YOLOLayerNode &node, GraphContext &ctx) -{ - ARM_COMPUTE_UNUSED(ctx); - validate_node(node, 1 /* expected inputs */, 1 /* expected outputs */); - - // Extract IO and info - typename TargetInfo::TensorType *input = get_backing_tensor(node.input(0)); - typename TargetInfo::TensorType *output = get_backing_tensor(node.output(0)); - const ActivationLayerInfo act_info = node.activation_info(); - const int32_t num_classes = node.num_classes(); - ARM_COMPUTE_ERROR_ON(num_classes <= 0); - ARM_COMPUTE_ERROR_ON(input == nullptr); - ARM_COMPUTE_ERROR_ON(output == nullptr); - - // Create and configure function - auto func = std::make_unique(); - func->configure(input, output, act_info, num_classes); - - // Log info - ARM_COMPUTE_LOG_GRAPH_INFO("Instantiated " - << node.name() - << " Type: " << node.type() - << " Target: " << TargetInfo::TargetType - << " Data Type: " << input->info()->data_type() - << " Input shape: " << input->info()->tensor_shape() - << " Output shape: " << output->info()->tensor_shape() - << " Activation function: " << act_info.activation() - << " Num classes: " << num_classes - << std::endl); - - return RETURN_UNIQUE_PTR(func); -} } // namespace detail } // namespace backends } // namespace graph diff --git a/arm_compute/graph/backends/ValidateHelpers.h b/arm_compute/graph/backends/ValidateHelpers.h index dd519fbd5e..df1c17697b 100644 --- a/arm_compute/graph/backends/ValidateHelpers.h +++ b/arm_compute/graph/backends/ValidateHelpers.h @@ -676,28 +676,6 @@ Status validate_upsample_layer(UpsampleLayerNode &node) // Validate function return UpsampleLayer::validate(input, output, node.info(), node.upsampling_policy()); } -/** Validates a YOLO layer node - * - * @tparam YOLOLayer YOLO layer type - * - * @param[in] node Node to validate - * - * @return Status - */ -template -Status validate_yolo_layer(YOLOLayerNode &node) -{ - ARM_COMPUTE_LOG_GRAPH_VERBOSE("Validating YOLOLayer node with ID : " << node.id() << " and Name: " << node.name() << std::endl); - ARM_COMPUTE_RETURN_ERROR_ON(node.num_inputs() != 1); - ARM_COMPUTE_RETURN_ERROR_ON(node.num_outputs() != 1); - - // Extract input and output - arm_compute::ITensorInfo *input = detail::get_backing_tensor_info(node.input(0)); - arm_compute::ITensorInfo *output = get_backing_tensor_info(node.output(0)); - - // Validate function - return YOLOLayer::validate(input, output, node.activation_info(), node.num_classes()); -} /** Validates a element-wise layer node * * @param[in] node Node to validate diff --git a/arm_compute/graph/frontend/Layers.h b/arm_compute/graph/frontend/Layers.h index 23f503342b..dfe7842aa1 100644 --- a/arm_compute/graph/frontend/Layers.h +++ b/arm_compute/graph/frontend/Layers.h @@ -1494,8 +1494,8 @@ public: * @param[in] act_info Activation info * @param[in] num_classes Number of classes to activate */ - YOLOLayer(ActivationLayerInfo act_info, int32_t num_classes) - : _act_info(act_info), _num_classes(num_classes) + YOLOLayer(ActivationLayerInfo act_info) + : _act_info(act_info) { } @@ -1503,12 +1503,11 @@ public: { NodeParams common_params = { name(), s.hints().target_hint }; NodeIdxPair input = { s.tail_node(), 0 }; - return GraphBuilder::add_yolo_node(s.graph(), common_params, input, _act_info, _num_classes); + return GraphBuilder::add_yolo_node(s.graph(), common_params, input, _act_info); } private: ActivationLayerInfo _act_info; - int32_t _num_classes; }; } // namespace frontend } // namespace graph diff --git a/arm_compute/graph/nodes/Nodes.h b/arm_compute/graph/nodes/Nodes.h index a6c569af88..9a6f982da7 100644 --- a/arm_compute/graph/nodes/Nodes.h +++ b/arm_compute/graph/nodes/Nodes.h @@ -68,6 +68,5 @@ #include "arm_compute/graph/nodes/StackLayerNode.h" #include "arm_compute/graph/nodes/StridedSliceLayerNode.h" #include "arm_compute/graph/nodes/UpsampleLayerNode.h" -#include "arm_compute/graph/nodes/YOLOLayerNode.h" #endif /* ARM_COMPUTE_GRAPH_NODES_H */ diff --git a/arm_compute/graph/nodes/NodesFwd.h b/arm_compute/graph/nodes/NodesFwd.h index cf8fc4f37c..b46b5d5f09 100644 --- a/arm_compute/graph/nodes/NodesFwd.h +++ b/arm_compute/graph/nodes/NodesFwd.h @@ -74,7 +74,6 @@ class SplitLayerNode; class StackLayerNode; class StridedSliceLayerNode; class UpsampleLayerNode; -class YOLOLayerNode; } // namespace graph } // namespace arm_compute #endif /* ARM_COMPUTE_GRAPH_NODES_FWD_H */ diff --git a/arm_compute/graph/nodes/SliceLayerNode.h b/arm_compute/graph/nodes/SliceLayerNode.h index 55f52a78a9..08d3794e26 100644 --- a/arm_compute/graph/nodes/SliceLayerNode.h +++ b/arm_compute/graph/nodes/SliceLayerNode.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2019 Arm Limited. + * Copyright (c) 2018-2020 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -41,7 +41,7 @@ public: * @param[in] starts The starts of the dimensions of the input tensor to be sliced. The length must be of rank(input). * @param[in] ends The ends of the dimensions of the input tensor to be sliced. The length must be of rank(input). */ - SliceLayerNode(Coordinates &starts, Coordinates &ends); + SliceLayerNode(const Coordinates &starts, const Coordinates &ends); /** Computes slice layer output descriptor * * @param[in] input_descriptor Descriptor of the input tensor diff --git a/arm_compute/graph/nodes/YOLOLayerNode.h b/arm_compute/graph/nodes/YOLOLayerNode.h deleted file mode 100644 index f9ced5160a..0000000000 --- a/arm_compute/graph/nodes/YOLOLayerNode.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (c) 2018-2019 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_GRAPH_YOLO_LAYER_NODE_H -#define ARM_COMPUTE_GRAPH_YOLO_LAYER_NODE_H - -#include "arm_compute/graph/INode.h" - -namespace arm_compute -{ -namespace graph -{ -/** YOLO Layer node */ -class YOLOLayerNode final : public INode -{ -public: - /** Constructor - * - * @param[in] act_info Activation info - * @param[in] num_classes Number of classes to activate - */ - YOLOLayerNode(ActivationLayerInfo act_info, int32_t num_classes); - /** Activation metadata accessor - * - * @return The activation info of the layer - */ - ActivationLayerInfo activation_info() const; - /** Number of classes metadata accessor - * - * @return The number of classes to activate of the layer - */ - int32_t num_classes() const; - - // Inherited overridden methods: - NodeType type() const override; - bool forward_descriptors() override; - TensorDescriptor configure_output(size_t idx) const override; - void accept(INodeVisitor &v) override; - -private: - ActivationLayerInfo _act_info; - int32_t _num_classes; -}; -} // namespace graph -} // namespace arm_compute -#endif /* ARM_COMPUTE_GRAPH_YOLO_LAYER_NODE_H */ -- cgit v1.2.1