From 2aad21a900a21f467b3ec6b37420f892f0d80221 Mon Sep 17 00:00:00 2001 From: Michalis Spyrou Date: Thu, 2 Jul 2020 12:43:53 +0100 Subject: COMPMID-3388: Async support to CLReshapeLayerKernel kernels/functions Signed-off-by: Michalis Spyrou Change-Id: I141a943dfd691069317860e852ecdd0ba7391604 Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/3501 Tested-by: Arm Jenkins Reviewed-by: Georgios Pinitas Comments-Addressed: Arm Jenkins --- .../runtime/CL/functions/CLArgMinMaxLayer.h | 4 +- .../CL/functions/CLGenerateProposalsLayer.h | 6 +-- .../runtime/CL/functions/CLReductionOperation.h | 4 +- arm_compute/runtime/CL/functions/CLReshapeLayer.h | 50 +++++++++++++++++++++- arm_compute/runtime/CL/functions/CLSoftmaxLayer.h | 8 ++-- 5 files changed, 60 insertions(+), 12 deletions(-) (limited to 'arm_compute/runtime/CL/functions') diff --git a/arm_compute/runtime/CL/functions/CLArgMinMaxLayer.h b/arm_compute/runtime/CL/functions/CLArgMinMaxLayer.h index 997bb79a47..64b7ea6668 100644 --- a/arm_compute/runtime/CL/functions/CLArgMinMaxLayer.h +++ b/arm_compute/runtime/CL/functions/CLArgMinMaxLayer.h @@ -25,9 +25,9 @@ #define ARM_COMPUTE_CLARGMINMAXLAYER_H #include "arm_compute/core/CL/kernels/CLArgMinMaxLayerKernel.h" -#include "arm_compute/core/CL/kernels/CLReshapeLayerKernel.h" #include "arm_compute/core/Types.h" #include "arm_compute/runtime/CL/CLTensor.h" +#include "arm_compute/runtime/CL/functions/CLReshapeLayer.h" #include "arm_compute/runtime/IFunction.h" #include "arm_compute/runtime/IMemoryManager.h" #include "arm_compute/runtime/MemoryGroup.h" @@ -89,7 +89,7 @@ private: std::vector _results_vector; CLTensor _not_reshaped_output; std::vector _reduction_kernels_vector; - CLReshapeLayerKernel _reshape_kernel; + CLReshapeLayer _reshape; unsigned int _num_of_stages; unsigned int _reduction_axis; }; diff --git a/arm_compute/runtime/CL/functions/CLGenerateProposalsLayer.h b/arm_compute/runtime/CL/functions/CLGenerateProposalsLayer.h index 91b30fabcb..490b07bfe4 100644 --- a/arm_compute/runtime/CL/functions/CLGenerateProposalsLayer.h +++ b/arm_compute/runtime/CL/functions/CLGenerateProposalsLayer.h @@ -29,10 +29,10 @@ #include "arm_compute/core/CL/kernels/CLPadLayerKernel.h" #include "arm_compute/core/CL/kernels/CLPermuteKernel.h" #include "arm_compute/core/CL/kernels/CLQuantizationLayerKernel.h" -#include "arm_compute/core/CL/kernels/CLReshapeLayerKernel.h" #include "arm_compute/core/Types.h" #include "arm_compute/runtime/CL/CLScheduler.h" #include "arm_compute/runtime/CL/CLTensor.h" +#include "arm_compute/runtime/CL/functions/CLReshapeLayer.h" #include "arm_compute/runtime/CPP/CPPScheduler.h" #include "arm_compute/runtime/CPP/functions/CPPBoxWithNonMaximaSuppressionLimit.h" #include "arm_compute/runtime/IFunction.h" @@ -131,9 +131,9 @@ private: // OpenCL kernels CLPermuteKernel _permute_deltas_kernel; - CLReshapeLayerKernel _flatten_deltas_kernel; + CLReshapeLayer _flatten_deltas; CLPermuteKernel _permute_scores_kernel; - CLReshapeLayerKernel _flatten_scores_kernel; + CLReshapeLayer _flatten_scores; CLComputeAllAnchorsKernel _compute_anchors_kernel; CLBoundingBoxTransformKernel _bounding_box_kernel; CLPadLayerKernel _pad_kernel; diff --git a/arm_compute/runtime/CL/functions/CLReductionOperation.h b/arm_compute/runtime/CL/functions/CLReductionOperation.h index 25cf655802..b420bbf631 100644 --- a/arm_compute/runtime/CL/functions/CLReductionOperation.h +++ b/arm_compute/runtime/CL/functions/CLReductionOperation.h @@ -26,9 +26,9 @@ #include "arm_compute/core/CL/kernels/CLFillBorderKernel.h" #include "arm_compute/core/CL/kernels/CLReductionOperationKernel.h" -#include "arm_compute/core/CL/kernels/CLReshapeLayerKernel.h" #include "arm_compute/core/Types.h" #include "arm_compute/runtime/CL/CLTensor.h" +#include "arm_compute/runtime/CL/functions/CLReshapeLayer.h" #include "arm_compute/runtime/IFunction.h" #include "arm_compute/runtime/IMemoryManager.h" #include "arm_compute/runtime/MemoryGroup.h" @@ -94,7 +94,7 @@ private: std::vector _results_vector; std::vector _reduction_kernels_vector; std::vector _border_handlers_vector; - CLReshapeLayerKernel _reshape_kernel; + CLReshapeLayer _reshape; ReductionOperation _op; unsigned int _num_of_stages; unsigned int _reduction_axis; diff --git a/arm_compute/runtime/CL/functions/CLReshapeLayer.h b/arm_compute/runtime/CL/functions/CLReshapeLayer.h index e91c2c739b..9017384545 100644 --- a/arm_compute/runtime/CL/functions/CLReshapeLayer.h +++ b/arm_compute/runtime/CL/functions/CLReshapeLayer.h @@ -24,6 +24,7 @@ #ifndef ARM_COMPUTE_CLRESHAPELAYER_H #define ARM_COMPUTE_CLRESHAPELAYER_H +#include "arm_compute/runtime/CL/ICLOperator.h" #include "arm_compute/runtime/CL/ICLSimpleFunction.h" namespace arm_compute @@ -31,9 +32,21 @@ namespace arm_compute class ICLTensor; /** Basic function to run @ref CLReshapeLayerKernel */ -class CLReshapeLayer : public ICLSimpleFunction +class CLReshapeLayer : public IFunction { public: + /** Default Constructor */ + CLReshapeLayer(); + /** Default Destructor */ + ~CLReshapeLayer(); + /** Prevent instances of this class from being copied (As this class contains pointers) */ + CLReshapeLayer(const CLReshapeLayer &) = delete; + /** Default move constructor */ + CLReshapeLayer(CLReshapeLayer &&); + /** Prevent instances of this class from being copied (As this class contains pointers) */ + CLReshapeLayer &operator=(const CLReshapeLayer &) = delete; + /** Default move assignment operator */ + CLReshapeLayer &operator=(CLReshapeLayer &&); /** Initialise the kernel's inputs and outputs * * @param[in] input First tensor input. Data type supported: All @@ -56,6 +69,41 @@ public: * @return a status */ static Status validate(const ITensorInfo *input, const ITensorInfo *output); + + // Inherited methods overridden: + void run() override; + +private: + struct Impl; + std::unique_ptr _impl; +}; + +namespace experimental +{ +/** Basic function to run @ref CLReshapeLayerKernel */ +class CLReshapeLayer : public ICLOperator +{ +public: + /** Initialise the kernel's inputs and outputs + * + * @param[in] compile_context The compile context to be used. + * @param[in] input Input tensor info. Data type supported: All + * @param[out] output Output info. Data type supported: Same as @p input + */ + void configure(const CLCompileContext &compile_context, const ITensorInfo *input, ITensorInfo *output); + + /** Static function to check if given info will lead to a valid configuration of @ref CLReshapeLayer + * + * @param[in] input Input tensor info. Data type supported: All + * @param[in] output Output tensor info. Data type supported: Same as @p input + * + * @return a status + */ + static Status validate(const ITensorInfo *input, const ITensorInfo *output); + + // Inherited methods overridden: + MemoryRequirements workspace() const override; }; +} // namespace experimental } #endif /*ARM_COMPUTE_CLRESHAPELAYER_H */ diff --git a/arm_compute/runtime/CL/functions/CLSoftmaxLayer.h b/arm_compute/runtime/CL/functions/CLSoftmaxLayer.h index 231a56f712..f0ef15acd7 100644 --- a/arm_compute/runtime/CL/functions/CLSoftmaxLayer.h +++ b/arm_compute/runtime/CL/functions/CLSoftmaxLayer.h @@ -24,10 +24,10 @@ #ifndef ARM_COMPUTE_CLSOFTMAXLAYER_H #define ARM_COMPUTE_CLSOFTMAXLAYER_H -#include "arm_compute/core/CL/kernels/CLFlattenLayerKernel.h" -#include "arm_compute/core/CL/kernels/CLReshapeLayerKernel.h" #include "arm_compute/core/CL/kernels/CLSoftmaxLayerKernel.h" #include "arm_compute/runtime/CL/CLTensor.h" +#include "arm_compute/runtime/CL/functions/CLFlattenLayer.h" +#include "arm_compute/runtime/CL/functions/CLReshapeLayer.h" #include "arm_compute/runtime/IFunction.h" #include "arm_compute/runtime/IMemoryManager.h" #include "arm_compute/runtime/MemoryGroup.h" @@ -136,8 +136,8 @@ private: MemoryGroup _memory_group; CLLogits1DMaxShiftExpSumKernel _max_shift_exp_sum_kernel; CLLogits1DNormKernel _norm_kernel; - std::unique_ptr _flatten_kernel_ptr; - CLReshapeLayerKernel _reshape_kernel; + std::unique_ptr _flatten_ptr; + CLReshapeLayer _reshape; CLTensor _max; CLTensor _sum; CLTensor _tmp; -- cgit v1.2.1