From c53266e45f3c8c07dff88c61e5bfa01c6d3ba3f0 Mon Sep 17 00:00:00 2001 From: Georgios Pinitas Date: Wed, 9 Dec 2020 03:11:53 +0000 Subject: Remove (CL/NE)UpsampleLayer in favor to (NE/CL)Scale Upsample functions and kernels can be replaced with the Scale as they provide same functionality Partially resolves: COMPMID-3996 Signed-off-by: Georgios Pinitas Change-Id: Ic2f9ba352c183aa87d69d551d5c172d0f22119e8 Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/4679 Reviewed-by: Michele Di Giorgio Comments-Addressed: Arm Jenkins Tested-by: Arm Jenkins --- arm_compute/graph/GraphBuilder.h | 11 --- arm_compute/graph/backends/FunctionHelpers.h | 47 +---------- arm_compute/graph/backends/ValidateHelpers.h | 22 ----- arm_compute/graph/frontend/Layers.h | 26 ------ arm_compute/graph/nodes/Nodes.h | 1 - arm_compute/graph/nodes/NodesFwd.h | 1 - arm_compute/graph/nodes/UpsampleLayerNode.h | 74 ----------------- arm_compute/runtime/CL/CLFunctions.h | 1 - arm_compute/runtime/CL/functions/CLUpsampleLayer.h | 97 ---------------------- arm_compute/runtime/NEON/NEFunctions.h | 1 - .../runtime/NEON/functions/NEUpsampleLayer.h | 85 ------------------- 11 files changed, 1 insertion(+), 365 deletions(-) delete mode 100644 arm_compute/graph/nodes/UpsampleLayerNode.h delete mode 100644 arm_compute/runtime/CL/functions/CLUpsampleLayer.h delete mode 100644 arm_compute/runtime/NEON/functions/NEUpsampleLayer.h (limited to 'arm_compute') diff --git a/arm_compute/graph/GraphBuilder.h b/arm_compute/graph/GraphBuilder.h index 54bb33d1a4..8c727e3c8e 100644 --- a/arm_compute/graph/GraphBuilder.h +++ b/arm_compute/graph/GraphBuilder.h @@ -571,17 +571,6 @@ public: * @return Node ID of the created node, EmptyNodeID in case of error */ static NodeID add_strided_slice_node(Graph &g, NodeParams params, NodeIdxPair input, Coordinates &starts, Coordinates &ends, BiStrides &strides, StridedSliceLayerInfo info); - /** Adds an upsample 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] info Upsample layer stride info - * @param[in] upsampling_policy Upsampling policy used - * - * @return Node ID of the created node, EmptyNodeID in case of error - */ - 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 diff --git a/arm_compute/graph/backends/FunctionHelpers.h b/arm_compute/graph/backends/FunctionHelpers.h index 18fdb9f3bb..873957e6b7 100644 --- a/arm_compute/graph/backends/FunctionHelpers.h +++ b/arm_compute/graph/backends/FunctionHelpers.h @@ -1619,7 +1619,7 @@ std::unique_ptr create_resize_layer(ResizeLayerNode &node) // Create and configure function auto func = std::make_unique(); - func->configure(input, output, ScaleKernelInfo{ policy, BorderMode::CONSTANT }); + func->configure(input, output, ScaleKernelInfo{ policy, BorderMode::CONSTANT, PixelValue(), SamplingPolicy::CENTER, false, false }); // Log info ARM_COMPUTE_LOG_GRAPH_INFO("Instantiated " @@ -1840,51 +1840,6 @@ std::unique_ptr create_strided_slice_layer(StridedSliceLayerNode &nod return RETURN_UNIQUE_PTR(func); } - -/** Create a backend Upsample layer function - * - * @tparam UpsampleLayerFunction Backend Upsample function - * @tparam TargetInfo Target-specific information - * - * @param[in] node Node to create the backend function for - * @param[in] ctx Graph context - * - * @return Backend Upsample layer function - */ -template -std::unique_ptr create_upsample_layer(UpsampleLayerNode &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 Size2D info = node.info(); - const InterpolationPolicy upsampling_policy = node.upsampling_policy(); - ARM_COMPUTE_ERROR_ON(upsampling_policy != InterpolationPolicy::NEAREST_NEIGHBOR); - ARM_COMPUTE_ERROR_ON(info.x() != 2 || info.y() != 2); - 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, info, upsampling_policy); - - // 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() - << " Strides: " << info - << " Upsampling policy: " << upsampling_policy - << 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 df1c17697b..f8cb1c12e9 100644 --- a/arm_compute/graph/backends/ValidateHelpers.h +++ b/arm_compute/graph/backends/ValidateHelpers.h @@ -654,28 +654,6 @@ Status validate_strided_slice_layer(StridedSliceLayerNode &node) return StridedSliceLayer::validate(input, output, starts, ends, strides, info.begin_mask(), info.end_mask(), info.shrink_axis_mask()); } -/** Validates a Upsample layer node - * - * @tparam UpsampleLayer Upsample layer type - * - * @param[in] node Node to validate - * - * @return Status - */ -template -Status validate_upsample_layer(UpsampleLayerNode &node) -{ - ARM_COMPUTE_LOG_GRAPH_VERBOSE("Validating UpsampleLayer 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 UpsampleLayer::validate(input, output, node.info(), node.upsampling_policy()); -} /** 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 dfe7842aa1..c4de4013b2 100644 --- a/arm_compute/graph/frontend/Layers.h +++ b/arm_compute/graph/frontend/Layers.h @@ -1459,32 +1459,6 @@ private: StridedSliceLayerInfo _info; }; -/** Upsample Layer */ -class UpsampleLayer final : public ILayer -{ -public: - /** Construct a Upsample layer. - * - * @param[in] info Stride info - * @param[in] upsampling_policy Upsampling policy - */ - UpsampleLayer(Size2D info, InterpolationPolicy upsampling_policy) - : _info(info), _upsampling_policy(upsampling_policy) - { - } - - NodeID create_layer(IStream &s) override - { - NodeParams common_params = { name(), s.hints().target_hint }; - NodeIdxPair input = { s.tail_node(), 0 }; - return GraphBuilder::add_upsample_node(s.graph(), common_params, input, _info, _upsampling_policy); - } - -private: - Size2D _info; - InterpolationPolicy _upsampling_policy; -}; - /** YOLO Layer */ class YOLOLayer final : public ILayer { diff --git a/arm_compute/graph/nodes/Nodes.h b/arm_compute/graph/nodes/Nodes.h index 9a6f982da7..edb1876722 100644 --- a/arm_compute/graph/nodes/Nodes.h +++ b/arm_compute/graph/nodes/Nodes.h @@ -67,6 +67,5 @@ #include "arm_compute/graph/nodes/SplitLayerNode.h" #include "arm_compute/graph/nodes/StackLayerNode.h" #include "arm_compute/graph/nodes/StridedSliceLayerNode.h" -#include "arm_compute/graph/nodes/UpsampleLayerNode.h" #endif /* ARM_COMPUTE_GRAPH_NODES_H */ diff --git a/arm_compute/graph/nodes/NodesFwd.h b/arm_compute/graph/nodes/NodesFwd.h index b46b5d5f09..485361296a 100644 --- a/arm_compute/graph/nodes/NodesFwd.h +++ b/arm_compute/graph/nodes/NodesFwd.h @@ -73,7 +73,6 @@ class SliceLayerNode; class SplitLayerNode; class StackLayerNode; class StridedSliceLayerNode; -class UpsampleLayerNode; } // namespace graph } // namespace arm_compute #endif /* ARM_COMPUTE_GRAPH_NODES_FWD_H */ diff --git a/arm_compute/graph/nodes/UpsampleLayerNode.h b/arm_compute/graph/nodes/UpsampleLayerNode.h deleted file mode 100644 index 8e43ac23f3..0000000000 --- a/arm_compute/graph/nodes/UpsampleLayerNode.h +++ /dev/null @@ -1,74 +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_UPSAMPLE_LAYER_NODE_H -#define ARM_COMPUTE_GRAPH_UPSAMPLE_LAYER_NODE_H - -#include "arm_compute/graph/INode.h" - -namespace arm_compute -{ -namespace graph -{ -/** Upsample Layer node */ -class UpsampleLayerNode final : public INode -{ -public: - /** Constructor - * - * @param[in] info Stride info - * @param[in] upsampling_policy Upsampling policy - */ - UpsampleLayerNode(Size2D info, InterpolationPolicy upsampling_policy); - /** Stride info metadata accessor - * - * @return The stride info of the layer - */ - Size2D info() const; - /** Upsampling policy metadata accessor - * - * @return The upsampling policy of the layer - */ - InterpolationPolicy upsampling_policy() const; - /** Computes upsample output descriptor - * - * @param[in] input_descriptor Input descriptor - * @param[in] info Stride information - * - * @return Output descriptor - */ - static TensorDescriptor compute_output_descriptor(const TensorDescriptor &input_descriptor, Size2D info); - - // 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: - Size2D _info; - InterpolationPolicy _upsampling_policy; -}; -} // namespace graph -} // namespace arm_compute -#endif /* ARM_COMPUTE_GRAPH_UPSAMPLE_LAYER_NODE_H */ diff --git a/arm_compute/runtime/CL/CLFunctions.h b/arm_compute/runtime/CL/CLFunctions.h index 2f336b30ad..26c2670cbc 100644 --- a/arm_compute/runtime/CL/CLFunctions.h +++ b/arm_compute/runtime/CL/CLFunctions.h @@ -148,7 +148,6 @@ #include "arm_compute/runtime/CL/functions/CLTile.h" #include "arm_compute/runtime/CL/functions/CLTranspose.h" #include "arm_compute/runtime/CL/functions/CLUnstack.h" -#include "arm_compute/runtime/CL/functions/CLUpsampleLayer.h" #include "arm_compute/runtime/CL/functions/CLWarpAffine.h" #include "arm_compute/runtime/CL/functions/CLWarpPerspective.h" #include "arm_compute/runtime/CL/functions/CLWinogradConvolutionLayer.h" diff --git a/arm_compute/runtime/CL/functions/CLUpsampleLayer.h b/arm_compute/runtime/CL/functions/CLUpsampleLayer.h deleted file mode 100644 index 88b293069d..0000000000 --- a/arm_compute/runtime/CL/functions/CLUpsampleLayer.h +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (c) 2018-2020 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_CLUPSAMPLELAYER_H -#define ARM_COMPUTE_CLUPSAMPLELAYER_H - -#include "arm_compute/runtime/IFunction.h" - -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/IFunction.h" - -#include - -namespace arm_compute -{ -class CLCompileContext; -class CLUpsampleLayerKernel; -class ICLTensor; -class ITensorInfo; - -/** Basic function to run @ref CLUpsampleLayerKernel */ -class CLUpsampleLayer : public IFunction -{ -public: - /** Default constructor */ - CLUpsampleLayer(); - /** Prevent instances of this class from being copied (As this class contains pointers) */ - CLUpsampleLayer(const CLUpsampleLayer &) = delete; - /** Prevent instances of this class from being copied (As this class contains pointers) */ - CLUpsampleLayer &operator=(const CLUpsampleLayer &) = delete; - /** Allow instances of this class to be moved */ - CLUpsampleLayer(CLUpsampleLayer &&) = default; - /** Allow instances of this class to be moved */ - CLUpsampleLayer &operator=(CLUpsampleLayer &&) = default; - /** Default destructor */ - ~CLUpsampleLayer(); - - /** Initialize the function's source, destination, interpolation type and border_mode. - * - * @param[in] input Source tensor. Data type supported: All. - * @param[out] output Destination tensor. Data types supported: same as @p input. - * @param[in] info Contains stride information described in @ref Size2D. - * @param[in] upsampling_policy Defines the policy to fill the intermediate pixels. - */ - void configure(ICLTensor *input, ICLTensor *output, - const Size2D &info, const InterpolationPolicy upsampling_policy); - /** Initialize the function's source, destination, interpolation type and border_mode. - * - * @param[in] compile_context The compile context to be used. - * @param[in] input Source tensor. Data type supported: All. - * @param[out] output Destination tensor. Data types supported: same as @p input. - * @param[in] info Contains stride information described in @ref Size2D. - * @param[in] upsampling_policy Defines the policy to fill the intermediate pixels. - */ - void configure(const CLCompileContext &compile_context, ICLTensor *input, ICLTensor *output, - const Size2D &info, const InterpolationPolicy upsampling_policy); - /** Static function to check if given info will lead to a valid configuration of @ref CLUpsampleLayerKernel - * - * @param[in] input Source tensor info. Data types supported: All. - * @param[in] output Destination tensor info. Data types supported: same as @p input. - * @param[in] info Contains stride information described in @ref Size2D. - * @param[in] upsampling_policy Defines the policy to fill the intermediate pixels. - * - * @return a status - */ - static Status validate(const ITensorInfo *input, const ITensorInfo *output, - const Size2D &info, const InterpolationPolicy upsampling_policy); - - // Inherited methods overridden: - void run() override; - -private: - std::unique_ptr _upsample; - ICLTensor *_output; -}; -} // namespace arm_compute -#endif /* ARM_COMPUTE_CLUPSAMPLELAYER_H */ diff --git a/arm_compute/runtime/NEON/NEFunctions.h b/arm_compute/runtime/NEON/NEFunctions.h index 1df6f8f08e..b7d05f9078 100644 --- a/arm_compute/runtime/NEON/NEFunctions.h +++ b/arm_compute/runtime/NEON/NEFunctions.h @@ -145,7 +145,6 @@ #include "arm_compute/runtime/NEON/functions/NETile.h" #include "arm_compute/runtime/NEON/functions/NETranspose.h" #include "arm_compute/runtime/NEON/functions/NEUnstack.h" -#include "arm_compute/runtime/NEON/functions/NEUpsampleLayer.h" #include "arm_compute/runtime/NEON/functions/NEWarpAffine.h" #include "arm_compute/runtime/NEON/functions/NEWarpPerspective.h" #include "arm_compute/runtime/NEON/functions/NEWinogradConvolutionLayer.h" diff --git a/arm_compute/runtime/NEON/functions/NEUpsampleLayer.h b/arm_compute/runtime/NEON/functions/NEUpsampleLayer.h deleted file mode 100644 index 168845d203..0000000000 --- a/arm_compute/runtime/NEON/functions/NEUpsampleLayer.h +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (c) 2018-2020 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_NEUPSAMPLELAYER_H -#define ARM_COMPUTE_NEUPSAMPLELAYER_H - -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/IFunction.h" -#include "arm_compute/runtime/NEON/NEScheduler.h" -#include "arm_compute/runtime/Tensor.h" - -#include - -namespace arm_compute -{ -class ITensor; -class NEUpsampleLayerKernel; - -/** Function to run upsample layer */ -class NEUpsampleLayer : public IFunction -{ -public: - /** Constructor */ - NEUpsampleLayer(); - /** Prevent instances of this class from being copied (As this class contains pointers) */ - NEUpsampleLayer(const NEUpsampleLayer &) = delete; - /** Prevent instances of this class from being copied (As this class contains pointers) */ - NEUpsampleLayer &operator=(const NEUpsampleLayer &) = delete; - /** Prevent instances of this class from being moved (As this class contains non movable objects) */ - NEUpsampleLayer(NEUpsampleLayer &&) = delete; - /** Prevent instances of this class from being moved (As this class contains non movable objects) */ - NEUpsampleLayer &operator=(NEUpsampleLayer &&) = delete; - /** Default destructor */ - ~NEUpsampleLayer(); - /** Set the input output tensors. - * - * @param[in] input Source tensor. Data types supported: QASYMM8_SIGNED/QASYMM8/F16/F32. - * @param[out] output Destination tensor. Data types supported: same as @p input. - * @param[in] info Contains stride information described in @ref Size2D. - * @param[in] policy Defines the policy to fill the intermediate pixels. - * - */ - void configure(const ITensor *input, ITensor *output, const Size2D &info, - const InterpolationPolicy &policy); - /** Static function to check if given info will lead to a valid configuration of @ref NEUpsampleLayer - * - * @param[in] input Source tensor info. Data types supported: QASYMM8_SIGNED/QASYMM8/F16/F32. - * @param[out] output Destination tensor info. Data types supported: same as @p input. - * @param[in] info Contains stride information described in @ref Size2D. - * @param[in] policy Defines the policy to fill the intermediate pixels. - * - * @return a status - */ - static Status validate(const ITensorInfo *input, const ITensorInfo *output, const Size2D &info, - const InterpolationPolicy &policy); - - // Inherited methods overridden: - void run() override; - -private: - std::unique_ptr _kernel; - DataLayout _data_layout; -}; -} // arm_compute -#endif /* ARM_COMPUTE_NEUPSAMPLELAYER_H */ -- cgit v1.2.1