aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSheri Zhang <sheri.zhang@arm.com>2021-02-02 11:49:34 +0000
committerSheri Zhang <sheri.zhang@arm.com>2021-02-08 13:35:26 +0000
commit7e20e29904c98adae5a91c6492fd78da88b7a9bf (patch)
tree96309359fd28c2244984ed1d4d1a9069528b64dc
parentafc9c3df7600dcecf12d3d3a4686d2008502a813 (diff)
downloadComputeLibrary-7e20e29904c98adae5a91c6492fd78da88b7a9bf.tar.gz
Make memset/copy functions state-less
Port following functions: - CLCopy - CLFill - CLPermute - CLReshapeLayer - CLCropResize Resolves: COMPMID-4002 Signed-off-by: Sheri Zhang <sheri.zhang@arm.com> Change-Id: I8392aa515aaeb5b44dab6122be6a795d08376d5f Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/5003 Comments-Addressed: Arm Jenkins <bsgcomp@arm.com> Reviewed-by: Michele Di Giorgio <michele.digiorgio@arm.com> Tested-by: Arm Jenkins <bsgcomp@arm.com>
-rw-r--r--Android.bp16
-rw-r--r--arm_compute/runtime/CL/CLFunctions.h3
-rw-r--r--arm_compute/runtime/CL/functions/CLCopy.h48
-rw-r--r--arm_compute/runtime/CL/functions/CLCrop.h (renamed from src/core/CL/kernels/CLCropKernel.h)53
-rw-r--r--arm_compute/runtime/CL/functions/CLCropResize.h17
-rw-r--r--arm_compute/runtime/CL/functions/CLDeconvolutionLayerUpsample.h9
-rw-r--r--arm_compute/runtime/CL/functions/CLFill.h57
-rw-r--r--arm_compute/runtime/CL/functions/CLGenerateProposalsLayer.h6
-rw-r--r--arm_compute/runtime/CL/functions/CLLSTMLayer.h12
-rw-r--r--arm_compute/runtime/CL/functions/CLMaxUnpoolingLayer.h8
-rw-r--r--arm_compute/runtime/CL/functions/CLPadLayer.h9
-rw-r--r--arm_compute/runtime/CL/functions/CLPermute.h29
-rw-r--r--arm_compute/runtime/CL/functions/CLQLSTMLayer.h12
-rw-r--r--arm_compute/runtime/CL/functions/CLRNNLayer.h24
-rw-r--r--arm_compute/runtime/CL/functions/CLReshapeLayer.h30
-rw-r--r--arm_compute/runtime/CL/functions/CLSpaceToBatchLayer.h8
-rw-r--r--docs/00_introduction.dox12
-rw-r--r--docs/04_adding_operator.dox2
-rw-r--r--src/core/CL/CLKernels.h5
-rw-r--r--src/core/CL/kernels/CLCopyKernel.h83
-rw-r--r--src/core/CL/kernels/CLPermuteKernel.h90
-rw-r--r--src/core/gpu/cl/kernels/ClCopyKernel.cpp (renamed from src/core/CL/kernels/CLCopyKernel.cpp)97
-rw-r--r--src/core/gpu/cl/kernels/ClCopyKernel.h71
-rw-r--r--src/core/gpu/cl/kernels/ClCropKernel.cpp (renamed from src/core/CL/kernels/CLCropKernel.cpp)89
-rw-r--r--src/core/gpu/cl/kernels/ClCropKernel.h98
-rw-r--r--src/core/gpu/cl/kernels/ClFillKernel.cpp (renamed from src/core/CL/kernels/CLMemsetKernel.cpp)54
-rw-r--r--src/core/gpu/cl/kernels/ClFillKernel.h (renamed from src/core/CL/kernels/CLMemsetKernel.h)52
-rw-r--r--src/core/gpu/cl/kernels/ClPermuteKernel.cpp (renamed from src/core/CL/kernels/CLPermuteKernel.cpp)98
-rw-r--r--src/core/gpu/cl/kernels/ClPermuteKernel.h86
-rw-r--r--src/core/gpu/cl/kernels/ClReshapeKernel.cpp (renamed from src/core/CL/kernels/CLReshapeLayerKernel.cpp)70
-rw-r--r--src/core/gpu/cl/kernels/ClReshapeKernel.h66
-rw-r--r--src/runtime/CL/functions/CLCopy.cpp56
-rw-r--r--src/runtime/CL/functions/CLCrop.cpp82
-rw-r--r--src/runtime/CL/functions/CLCropResize.cpp46
-rw-r--r--src/runtime/CL/functions/CLDeconvolutionLayerUpsample.cpp9
-rw-r--r--src/runtime/CL/functions/CLDirectDeconvolutionLayer.cpp3
-rw-r--r--src/runtime/CL/functions/CLFFTConvolutionLayer.cpp3
-rw-r--r--src/runtime/CL/functions/CLFill.cpp50
-rw-r--r--src/runtime/CL/functions/CLGenerateProposalsLayer.cpp19
-rw-r--r--src/runtime/CL/functions/CLLSTMLayer.cpp37
-rw-r--r--src/runtime/CL/functions/CLMaxUnpoolingLayer.cpp11
-rw-r--r--src/runtime/CL/functions/CLPadLayer.cpp11
-rw-r--r--src/runtime/CL/functions/CLPermute.cpp47
-rw-r--r--src/runtime/CL/functions/CLQLSTMLayer.cpp11
-rw-r--r--src/runtime/CL/functions/CLRNNLayer.cpp11
-rw-r--r--src/runtime/CL/functions/CLReshapeLayer.cpp35
-rw-r--r--src/runtime/CL/functions/CLSpaceToBatchLayer.cpp16
-rw-r--r--src/runtime/gpu/cl/operators/ClCopy.cpp45
-rw-r--r--src/runtime/gpu/cl/operators/ClCopy.h62
-rw-r--r--src/runtime/gpu/cl/operators/ClCrop.cpp46
-rw-r--r--src/runtime/gpu/cl/operators/ClCrop.h74
-rw-r--r--src/runtime/gpu/cl/operators/ClFill.cpp45
-rw-r--r--src/runtime/gpu/cl/operators/ClFill.h61
-rw-r--r--src/runtime/gpu/cl/operators/ClPermute.cpp45
-rw-r--r--src/runtime/gpu/cl/operators/ClPermute.h64
-rw-r--r--src/runtime/gpu/cl/operators/ClReshape.cpp45
-rw-r--r--src/runtime/gpu/cl/operators/ClReshape.h (renamed from src/core/CL/kernels/CLReshapeLayerKernel.h)38
-rw-r--r--tests/CL/Helper.h13
58 files changed, 1582 insertions, 717 deletions
diff --git a/Android.bp b/Android.bp
index 5653fc8a63..94a4e6c13a 100644
--- a/Android.bp
+++ b/Android.bp
@@ -95,8 +95,6 @@ cc_library_static {
"src/core/CL/kernels/CLComparisonKernel.cpp",
"src/core/CL/kernels/CLConvertFullyConnectedWeightsKernel.cpp",
"src/core/CL/kernels/CLConvolutionKernel.cpp",
- "src/core/CL/kernels/CLCopyKernel.cpp",
- "src/core/CL/kernels/CLCropKernel.cpp",
"src/core/CL/kernels/CLDeconvolutionLayerUpsampleKernel.cpp",
"src/core/CL/kernels/CLDeconvolutionReshapeOutputKernel.cpp",
"src/core/CL/kernels/CLDepthConvertLayerKernel.cpp",
@@ -150,7 +148,6 @@ cc_library_static {
"src/core/CL/kernels/CLMeanStdDevKernel.cpp",
"src/core/CL/kernels/CLMeanStdDevNormalizationKernel.cpp",
"src/core/CL/kernels/CLMedian3x3Kernel.cpp",
- "src/core/CL/kernels/CLMemsetKernel.cpp",
"src/core/CL/kernels/CLMinMaxLayerKernel.cpp",
"src/core/CL/kernels/CLMinMaxLocationKernel.cpp",
"src/core/CL/kernels/CLNonLinearFilterKernel.cpp",
@@ -158,7 +155,6 @@ cc_library_static {
"src/core/CL/kernels/CLNormalizationLayerKernel.cpp",
"src/core/CL/kernels/CLNormalizePlanarYUVLayerKernel.cpp",
"src/core/CL/kernels/CLPadLayerKernel.cpp",
- "src/core/CL/kernels/CLPermuteKernel.cpp",
"src/core/CL/kernels/CLPixelWiseMultiplicationKernel.cpp",
"src/core/CL/kernels/CLPriorBoxLayerKernel.cpp",
"src/core/CL/kernels/CLQLSTMLayerNormalizationKernel.cpp",
@@ -169,7 +165,6 @@ cc_library_static {
"src/core/CL/kernels/CLReductionOperationKernel.cpp",
"src/core/CL/kernels/CLRemapKernel.cpp",
"src/core/CL/kernels/CLReorgLayerKernel.cpp",
- "src/core/CL/kernels/CLReshapeLayerKernel.cpp",
"src/core/CL/kernels/CLReverseKernel.cpp",
"src/core/CL/kernels/CLScaleKernel.cpp",
"src/core/CL/kernels/CLScharr3x3Kernel.cpp",
@@ -437,12 +432,17 @@ cc_library_static {
"src/core/cpu/kernels/sub/neon/qsymm16.cpp",
"src/core/gpu/cl/kernels/ClActivationKernel.cpp",
"src/core/gpu/cl/kernels/ClBatchConcatenateKernel.cpp",
+ "src/core/gpu/cl/kernels/ClCopyKernel.cpp",
+ "src/core/gpu/cl/kernels/ClCropKernel.cpp",
"src/core/gpu/cl/kernels/ClDepthConcatenateKernel.cpp",
"src/core/gpu/cl/kernels/ClElementwiseKernel.cpp",
"src/core/gpu/cl/kernels/ClElementwiseUnaryKernel.cpp",
+ "src/core/gpu/cl/kernels/ClFillKernel.cpp",
"src/core/gpu/cl/kernels/ClFloorKernel.cpp",
"src/core/gpu/cl/kernels/ClHeightConcatenateKernel.cpp",
+ "src/core/gpu/cl/kernels/ClPermuteKernel.cpp",
"src/core/gpu/cl/kernels/ClPoolingKernel.cpp",
+ "src/core/gpu/cl/kernels/ClReshapeKernel.cpp",
"src/core/gpu/cl/kernels/ClWidthConcatenate2TensorsKernel.cpp",
"src/core/gpu/cl/kernels/ClWidthConcatenate4TensorsKernel.cpp",
"src/core/gpu/cl/kernels/ClWidthConcatenateKernel.cpp",
@@ -505,6 +505,7 @@ cc_library_static {
"src/runtime/CL/functions/CLConvolution.cpp",
"src/runtime/CL/functions/CLConvolutionLayer.cpp",
"src/runtime/CL/functions/CLCopy.cpp",
+ "src/runtime/CL/functions/CLCrop.cpp",
"src/runtime/CL/functions/CLCropResize.cpp",
"src/runtime/CL/functions/CLDeconvolutionLayer.cpp",
"src/runtime/CL/functions/CLDeconvolutionLayerUpsample.cpp",
@@ -802,11 +803,16 @@ cc_library_static {
"src/runtime/gpu/cl/operators/ClActivation.cpp",
"src/runtime/gpu/cl/operators/ClAdd.cpp",
"src/runtime/gpu/cl/operators/ClConcatenate.cpp",
+ "src/runtime/gpu/cl/operators/ClCopy.cpp",
+ "src/runtime/gpu/cl/operators/ClCrop.cpp",
"src/runtime/gpu/cl/operators/ClElementwiseOperations.cpp",
"src/runtime/gpu/cl/operators/ClElementwiseUnary.cpp",
+ "src/runtime/gpu/cl/operators/ClFill.cpp",
"src/runtime/gpu/cl/operators/ClFloor.cpp",
"src/runtime/gpu/cl/operators/ClLogicalNot.cpp",
+ "src/runtime/gpu/cl/operators/ClPermute.cpp",
"src/runtime/gpu/cl/operators/ClPooling.cpp",
+ "src/runtime/gpu/cl/operators/ClReshape.cpp",
"src/runtime/gpu/cl/operators/ClSub.cpp",
"utils/CommonGraphOptions.cpp",
"utils/GraphUtils.cpp",
diff --git a/arm_compute/runtime/CL/CLFunctions.h b/arm_compute/runtime/CL/CLFunctions.h
index 26c2670cbc..b2bdb9a3e7 100644
--- a/arm_compute/runtime/CL/CLFunctions.h
+++ b/arm_compute/runtime/CL/CLFunctions.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016-2020 Arm Limited.
+ * Copyright (c) 2016-2021 Arm Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -49,6 +49,7 @@
#include "arm_compute/runtime/CL/functions/CLConvolution.h"
#include "arm_compute/runtime/CL/functions/CLConvolutionLayer.h"
#include "arm_compute/runtime/CL/functions/CLCopy.h"
+#include "arm_compute/runtime/CL/functions/CLCrop.h"
#include "arm_compute/runtime/CL/functions/CLCropResize.h"
#include "arm_compute/runtime/CL/functions/CLDeconvolutionLayer.h"
#include "arm_compute/runtime/CL/functions/CLDeconvolutionLayerUpsample.h"
diff --git a/arm_compute/runtime/CL/functions/CLCopy.h b/arm_compute/runtime/CL/functions/CLCopy.h
index f1a091df84..795a183e1f 100644
--- a/arm_compute/runtime/CL/functions/CLCopy.h
+++ b/arm_compute/runtime/CL/functions/CLCopy.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018-2020 Arm Limited.
+ * Copyright (c) 2018-2021 Arm Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -25,9 +25,9 @@
#define ARM_COMPUTE_CLCOPY_H
#include "arm_compute/core/Types.h"
-#include "arm_compute/runtime/CL/ICLSimpleFunction.h"
-
-#include <cstdint>
+#include "arm_compute/core/Window.h"
+#include "arm_compute/runtime/IFunction.h"
+#include <memory>
namespace arm_compute
{
@@ -35,32 +35,54 @@ class CLCompileContext;
class ICLTensor;
class ITensorInfo;
-class CLCopy : public ICLSimpleFunction
+/** Basic function to run @ref opencl::kernels::ClCopyKernel */
+class CLCopy : public IFunction
{
public:
+ /** Constructor */
+ CLCopy();
+ /** Destructor */
+ ~CLCopy();
+ /** Prevent instances of this class from being copied (As this class contains pointers) */
+ CLCopy(const CLCopy &) = delete;
+ /** Default move constructor */
+ CLCopy(CLCopy &&);
+ /** Prevent instances of this class from being copied (As this class contains pointers) */
+ CLCopy &operator=(const CLCopy &) = delete;
+ /** Default move assignment operator */
+ CLCopy &operator=(CLCopy &&);
/** Initialise the function's source and destination.
*
- * @param[in] input Source tensor. Data types supported: All.
- * @param[out] output Output tensor. Data types supported: Same as @p input.
- *
+ * @param[in] input Source tensor. Data types supported: All.
+ * @param[out] output Output tensor. Data types supported: Same as @p input.
+ * @param[in] dst_window (Optional) Window to be used in case only copying into part of a tensor. Default is nullptr.
*/
- void configure(ICLTensor *input, ICLTensor *output);
+ void configure(ICLTensor *input, ICLTensor *output, Window *dst_window = nullptr);
/** Initialise the function's source and destination.
*
* @param[in] compile_context The compile context to be used.
* @param[in] input Source tensor. Data types supported: All.
* @param[out] output Output tensor. Data types supported: Same as @p input.
+ * @param[in] dst_window (Optional) Window to be used in case only copying into part of a tensor. Default is nullptr.
*
*/
- void configure(const CLCompileContext &compile_context, ICLTensor *input, ICLTensor *output);
+ void configure(const CLCompileContext &compile_context, ICLTensor *input, ICLTensor *output, Window *dst_window = nullptr);
/** Static function to check if given info will lead to a valid configuration of @ref CLCopy
*
- * @param[in] input Source tensor. Data types supported: All.
- * @param[in] output Output tensor. Data types supported: Same as @p input.
+ * @param[in] input Source tensor. Data types supported: All.
+ * @param[in] output Output tensor. Data types supported: Same as @p input.
+ * @param[in] dst_window (Optional) Window to be used in case only copying into part of a tensor. Default is nullptr.
*
* @return a status
*/
- static Status validate(const ITensorInfo *input, const ITensorInfo *output);
+ static Status validate(const ITensorInfo *input, const ITensorInfo *output, Window *dst_window = nullptr);
+
+ // Inherited methods overridden:
+ void run() override;
+
+private:
+ struct Impl;
+ std::unique_ptr<Impl> _impl;
};
} // namespace arm_compute
#endif /*ARM_COMPUTE_CLCOPY_H */
diff --git a/src/core/CL/kernels/CLCropKernel.h b/arm_compute/runtime/CL/functions/CLCrop.h
index cbfada58ab..dc509b5b84 100644
--- a/src/core/CL/kernels/CLCropKernel.h
+++ b/arm_compute/runtime/CL/functions/CLCrop.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019-2020 Arm Limited.
+ * Copyright (c) 2021 Arm Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -21,31 +21,37 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
-#ifndef ARM_COMPUTE_CLCROPKERNEL_H
-#define ARM_COMPUTE_CLCROPKERNEL_H
+#ifndef ARM_COMPUTE_CL_CROP_H
+#define ARM_COMPUTE_CL_CROP_H
#include "arm_compute/core/Types.h"
-#include "src/core/CL/ICLKernel.h"
+#include "arm_compute/core/Window.h"
+#include "arm_compute/runtime/IFunction.h"
+#include <memory>
namespace arm_compute
{
+class CLCompileContext;
class ICLTensor;
+class ITensorInfo;
-/** OpenCL kernel to perform a copy between two tensors */
-class CLCropKernel : public ICLKernel
+/** Basic function to run @ref opencl::kernels::ClCropKernel */
+class CLCrop : public IFunction
{
public:
- /** Default constructor */
- CLCropKernel();
- /** Prevent instances of this class from being copied (As this class contains pointers). */
- CLCropKernel(const CLCropKernel &) = delete;
- /** Prevent instances of this class from being copied (As this class contains pointers). */
- CLCropKernel &operator=(const CLCropKernel &) = delete;
- /** Allow instances of this class to be moved */
- CLCropKernel(CLCropKernel &&) = default;
- /** Allow instances of this class to be moved */
- CLCropKernel &operator=(CLCropKernel &&) = default;
- /** Configure kernel
+ /** Constructor */
+ CLCrop();
+ /** Destructor */
+ ~CLCrop();
+ /** Prevent instances of this class from being copied (As this class contains pointers) */
+ CLCrop(const CLCrop &) = delete;
+ /** Default move constructor */
+ CLCrop(CLCrop &&);
+ /** Prevent instances of this class from being copied (As this class contains pointers) */
+ CLCrop &operator=(const CLCrop &) = delete;
+ /** Default move assignment operator */
+ CLCrop &operator=(CLCrop &&);
+ /** Configure function
*
* @note Supported tensor rank: up to 4
*
@@ -58,7 +64,7 @@ public:
* @param[in] output_window Output window to be used in case cropped image is being copied into a tensor. Default is nullptr.
*/
void configure(const ICLTensor *input, ICLTensor *output, Coordinates2D start, Coordinates2D end, uint32_t batch_index, float extrapolation_value = 0, Window *output_window = nullptr);
- /** Configure kernel
+ /** Configure function
*
* @note Supported tensor rank: up to 4
*
@@ -90,14 +96,11 @@ public:
Window *output_window = nullptr);
// Inherited methods overridden:
- void run(const Window &window, cl::CommandQueue &queue) override;
+ void run() override;
private:
- const ICLTensor *_input;
- ICLTensor *_output;
- Coordinates2D _start;
- uint32_t _batch_index;
- float _extrapolation_value;
+ struct Impl;
+ std::unique_ptr<Impl> _impl;
};
} // namespace arm_compute
-#endif /*ARM_COMPUTE_CLCROPKERNEL_H */
+#endif /*ARM_COMPUTE_CL_CROP_H */
diff --git a/arm_compute/runtime/CL/functions/CLCropResize.h b/arm_compute/runtime/CL/functions/CLCropResize.h
index e781cfe61f..0dc3c48b32 100644
--- a/arm_compute/runtime/CL/functions/CLCropResize.h
+++ b/arm_compute/runtime/CL/functions/CLCropResize.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019-2020 Arm Limited.
+ * Copyright (c) 2019-2021 Arm Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -27,6 +27,9 @@
#include "arm_compute/core/CL/ICLTensor.h"
#include "arm_compute/runtime/CL/CLTensor.h"
+#include "arm_compute/runtime/CL/functions/CLCopy.h"
+#include "arm_compute/runtime/CL/functions/CLCrop.h"
+#include "arm_compute/runtime/CL/functions/CLFill.h"
#include "arm_compute/runtime/CL/functions/CLScale.h"
#include <cstdint>
@@ -36,8 +39,6 @@ namespace arm_compute
{
// Forward Declarations
class CLCompileContext;
-class CLCopyKernel;
-class CLCropKernel;
class ITensor;
class ITensorInfo;
@@ -125,12 +126,12 @@ public:
InterpolationPolicy _method;
float _extrapolation_value;
- std::vector<std::unique_ptr<CLScale>> _scale;
- std::vector<std::unique_ptr<CLCopyKernel>> _copy;
- std::vector<std::unique_ptr<CLTensor>> _crop_results;
- std::vector<std::unique_ptr<CLTensor>> _scaled_results;
+ std::vector<std::unique_ptr<CLScale>> _scale;
+ std::vector<std::unique_ptr<CLCopy>> _copy;
+ std::vector<std::unique_ptr<CLTensor>> _crop_results;
+ std::vector<std::unique_ptr<CLTensor>> _scaled_results;
- std::vector<std::unique_ptr<ICLKernel>> _internal_kernels;
+ std::vector<std::unique_ptr<IFunction>> _internal_functions;
};
} // namespace arm_compute
#endif /* ARM_COMPUTE_CL_CROP_RESIZE_H */
diff --git a/arm_compute/runtime/CL/functions/CLDeconvolutionLayerUpsample.h b/arm_compute/runtime/CL/functions/CLDeconvolutionLayerUpsample.h
index 3ebc858d32..6c1302fbf7 100644
--- a/arm_compute/runtime/CL/functions/CLDeconvolutionLayerUpsample.h
+++ b/arm_compute/runtime/CL/functions/CLDeconvolutionLayerUpsample.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017-2020 Arm Limited.
+ * Copyright (c) 2017-2021 Arm Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -25,7 +25,7 @@
#define ARM_COMPUTE_CLDECONVOLUTIONLAYERUPSAMPLE_H
#include "arm_compute/core/Types.h"
-#include "arm_compute/runtime/IFunction.h"
+#include "arm_compute/runtime/CL/functions/CLFill.h"
#include "arm_compute/runtime/IFunction.h"
#include <memory>
@@ -35,13 +35,12 @@ namespace arm_compute
// Forward declarations
class CLDeconvolutionLayerUpsampleKernel;
class CLCompileContext;
-class CLMemsetKernel;
class ICLTensor;
class ITensorInfo;
/** Basic function to execute deconvolution upsample on OpenCL. This function calls the following OpenCL kernels and functions:
*
- * -# @ref CLMemsetKernel
+ * -# @ref CLFill
* -# @ref CLDeconvolutionLayerUpsampleKernel
*/
class CLDeconvolutionLayerUpsample : public IFunction
@@ -90,7 +89,7 @@ public:
private:
std::unique_ptr<CLDeconvolutionLayerUpsampleKernel> _upsample;
- std::unique_ptr<CLMemsetKernel> _memset;
+ CLFill _fill;
ICLTensor *_output;
};
} // namespace arm_compute
diff --git a/arm_compute/runtime/CL/functions/CLFill.h b/arm_compute/runtime/CL/functions/CLFill.h
index fef8324432..9a27d158a6 100644
--- a/arm_compute/runtime/CL/functions/CLFill.h
+++ b/arm_compute/runtime/CL/functions/CLFill.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019-2020 Arm Limited.
+ * Copyright (c) 2019-2021 Arm Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -24,32 +24,63 @@
#ifndef ARM_COMPUTE_CLFILL_H
#define ARM_COMPUTE_CLFILL_H
-#include "arm_compute/core/PixelValue.h"
#include "arm_compute/core/Types.h"
-#include "arm_compute/runtime/CL/ICLSimpleFunction.h"
+#include "arm_compute/core/Window.h"
+#include "arm_compute/runtime/IFunction.h"
+#include <memory>
namespace arm_compute
{
class CLCompileContext;
class ICLTensor;
-/** Function to run @ref CLMemsetKernel to fill a tensor with a scalar value */
-class CLFill : public ICLSimpleFunction
+/** Basic function to run @ref opencl::kernels::ClFillKernel */
+class CLFill : public IFunction
{
public:
- /** Initialize the function
+ /** Constructor */
+ CLFill();
+ /** Destructor */
+ ~CLFill();
+ /** Prevent instances of this class from being copied (As this class contains pointers) */
+ CLFill(const CLFill &) = delete;
+ /** Default move constructor */
+ CLFill(CLFill &&);
+ /** Prevent instances of this class from being copied (As this class contains pointers) */
+ CLFill &operator=(const CLFill &) = delete;
+ /** Default move assignment operator */
+ CLFill &operator=(CLFill &&);
+ /** Initialize the kernel's tensor and filling value
*
- * @param[in,out] tensor Source tensor. Data types supported: All.
- * @param[in] constant_value Constant value to use to fill tensor.
+ * @param[in,out] tensor Input tensor to fill. Supported data types: All.
+ * @param[in] constant_value The value used to fill the planes of the tensor
+ * @param[in] window Window to be used in case setting only part of a tensor. Default is nullptr.
*/
- void configure(ICLTensor *tensor, PixelValue constant_value);
- /** Initialize the function
+ void configure(ICLTensor *tensor, const PixelValue &constant_value, Window *window = nullptr);
+ /** Initialise the kernel's tensor and filling value
*
* @param[in] compile_context The compile context to be used.
- * @param[in,out] tensor Source tensor. Data types supported: All.
- * @param[in] constant_value Constant value to use to fill tensor.
+ * @param[in,out] tensor Input tensor to fill. Supported data types: All.
+ * @param[in] constant_value The value used to fill the planes of the tensor
+ * @param[in] window Window to be used in case setting only part of a tensor. Default is nullptr.
*/
- void configure(const CLCompileContext &compile_context, ICLTensor *tensor, PixelValue constant_value);
+ void configure(const CLCompileContext &compile_context, ICLTensor *tensor, const PixelValue &constant_value, Window *window = nullptr);
+ /** Static function to check if given info will lead to a valid configuration of @ref CLFill
+ *
+ * @param[in] tensor Source tensor info. Data types supported: All.
+ * @param[in] constant_value The value used to fill the planes of the tensor
+ * @param[in] window Window to be used in case setting only part of a tensor. Default is nullptr.
+ *
+ * @return a status
+ */
+ static Status validate(const ITensorInfo *tensor, const PixelValue &constant_value, Window *window = nullptr);
+
+ // Inherited methods overridden:
+ void run() override;
+
+private:
+ struct Impl;
+ std::unique_ptr<Impl> _impl;
};
} // namespace arm_compute
#endif /*ARM_COMPUTE_CLFILL_H */
diff --git a/arm_compute/runtime/CL/functions/CLGenerateProposalsLayer.h b/arm_compute/runtime/CL/functions/CLGenerateProposalsLayer.h
index cf5fd500a0..4d6bc66487 100644
--- a/arm_compute/runtime/CL/functions/CLGenerateProposalsLayer.h
+++ b/arm_compute/runtime/CL/functions/CLGenerateProposalsLayer.h
@@ -27,6 +27,7 @@
#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/CLPermute.h"
#include "arm_compute/runtime/CL/functions/CLReshapeLayer.h"
#include "arm_compute/runtime/CPP/CPPScheduler.h"
#include "arm_compute/runtime/CPP/functions/CPPBoxWithNonMaximaSuppressionLimit.h"
@@ -42,7 +43,6 @@ class CLBoundingBoxTransformKernel;
class CLDequantizationLayerKernel;
class CLComputeAllAnchorsKernel;
class CLPadLayerKernel;
-class CLPermuteKernel;
class CLQuantizationLayerKernel;
class ICLTensor;
class ITensorInfo;
@@ -137,9 +137,9 @@ private:
MemoryGroup _memory_group;
// OpenCL kernels
- std::unique_ptr<CLPermuteKernel> _permute_deltas_kernel;
+ CLPermute _permute_deltas;
CLReshapeLayer _flatten_deltas;
- std::unique_ptr<CLPermuteKernel> _permute_scores_kernel;
+ CLPermute _permute_scores;
CLReshapeLayer _flatten_scores;
std::unique_ptr<CLComputeAllAnchorsKernel> _compute_anchors_kernel;
std::unique_ptr<CLBoundingBoxTransformKernel> _bounding_box_kernel;
diff --git a/arm_compute/runtime/CL/functions/CLLSTMLayer.h b/arm_compute/runtime/CL/functions/CLLSTMLayer.h
index 017f26aa1e..20b068316c 100644
--- a/arm_compute/runtime/CL/functions/CLLSTMLayer.h
+++ b/arm_compute/runtime/CL/functions/CLLSTMLayer.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018-2020 Arm Limited.
+ * Copyright (c) 2018-2021 Arm Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -30,7 +30,9 @@
#include "arm_compute/runtime/CL/CLTensor.h"
#include "arm_compute/runtime/CL/functions/CLActivationLayer.h"
#include "arm_compute/runtime/CL/functions/CLConcatenateLayer.h"
+#include "arm_compute/runtime/CL/functions/CLCopy.h"
#include "arm_compute/runtime/CL/functions/CLElementwiseOperations.h"
+#include "arm_compute/runtime/CL/functions/CLFill.h"
#include "arm_compute/runtime/CL/functions/CLFullyConnectedLayer.h"
#include "arm_compute/runtime/CL/functions/CLGEMM.h"
#include "arm_compute/runtime/CL/functions/CLMeanStdDevNormalizationLayer.h"
@@ -44,8 +46,6 @@
namespace arm_compute
{
class CLCompileContext;
-class CLCopyKernel;
-class CLMemsetKernel;
class CLTransposeKernel;
class ICLTensor;
@@ -239,14 +239,14 @@ private:
CLPixelWiseMultiplication _pixelwise_mul_output_state2;
CLFullyConnectedLayer _fully_connected_output_state;
CLActivationLayer _projection_clip;
- std::unique_ptr<CLCopyKernel> _copy_cell_state;
- std::unique_ptr<CLCopyKernel> _copy_output;
+ CLCopy _copy_cell_state;
+ CLCopy _copy_output;
CLConcatenateLayer _concat_scratch_buffer;
CLConcatenateLayer _concat_inputs_forget_gate;
CLConcatenateLayer _concat_weights_forget_gate;
CLConcatenateLayer _concat_weights_input_gate;
CLConcatenateLayer _concat_weights_output;
- std::unique_ptr<CLMemsetKernel> _ones_memset_kernel;
+ CLFill _ones_fill;
CLMeanStdDevNormalizationLayer _mean_std_norm_input_gate;
CLPixelWiseMultiplication _pixelwise_mul_input_gate_coeff;
CLArithmeticAddition _accum_input_gate_bias;
diff --git a/arm_compute/runtime/CL/functions/CLMaxUnpoolingLayer.h b/arm_compute/runtime/CL/functions/CLMaxUnpoolingLayer.h
index 693862fb89..24d620d372 100644
--- a/arm_compute/runtime/CL/functions/CLMaxUnpoolingLayer.h
+++ b/arm_compute/runtime/CL/functions/CLMaxUnpoolingLayer.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020 Arm Limited.
+ * Copyright (c) 2020-2021 Arm Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -25,6 +25,7 @@
#define ARM_COMPUTE_CLMAXUNPOOLINGLAYER_H
#include "arm_compute/core/Error.h"
+#include "arm_compute/runtime/CL/functions/CLFill.h"
#include "arm_compute/runtime/IFunction.h"
#include <memory>
@@ -35,12 +36,11 @@ class CLCompileContext;
class ICLTensor;
class ITensorInfo;
class CLMaxUnpoolingLayerKernel;
-class CLMemsetKernel;
struct PoolingLayerInfo;
/** Function to perform MaxUnpooling. This function calls the following OpenCL kernels:
*
- * -# @ref CLMemsetKernel
+ * -# @ref CLFill
* -# @ref CLMaxUnpoolingLayerKernel
*/
class CLMaxUnpoolingLayer : public IFunction
@@ -99,7 +99,7 @@ public:
void run() override;
private:
- std::unique_ptr<CLMemsetKernel> _memset_kernel;
+ CLFill _fill;
std::unique_ptr<CLMaxUnpoolingLayerKernel> _unpooling_layer_kernel;
};
}
diff --git a/arm_compute/runtime/CL/functions/CLPadLayer.h b/arm_compute/runtime/CL/functions/CLPadLayer.h
index 2bbde30fc2..dae95f63e6 100644
--- a/arm_compute/runtime/CL/functions/CLPadLayer.h
+++ b/arm_compute/runtime/CL/functions/CLPadLayer.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018-2020 Arm Limited.
+ * Copyright (c) 2018-2021 Arm Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -26,19 +26,20 @@
#include "arm_compute/core/Error.h"
#include "arm_compute/runtime/CL/CLTensor.h"
+#include "arm_compute/runtime/CL/functions/CLCopy.h"
+#include "arm_compute/runtime/CL/functions/CLPermute.h"
#include "arm_compute/runtime/IFunction.h"
namespace arm_compute
{
class CLCompileContext;
class CLPadLayerKernel;
-class CLCopyKernel;
class ICLTensor;
/** Basic function to pad a tensor. This function calls the following OpenCL functions/kernels:
*
* -# @ref CLPadLayerKernel if there is padding to be added
- * -# @ref CLCopyKernel otherwise
+ * -# @ref CLCopy otherwise
*/
class CLPadLayer : public IFunction
{
@@ -100,7 +101,7 @@ private:
void configure_reflect_mode(ICLTensor *input, ICLTensor *output);
std::unique_ptr<CLPadLayerKernel> _pad_kernel;
- std::unique_ptr<CLCopyKernel> _copy_kernel;
+ CLCopy _copy;
bool _perform_pad;
};
} // namespace arm_compute
diff --git a/arm_compute/runtime/CL/functions/CLPermute.h b/arm_compute/runtime/CL/functions/CLPermute.h
index 50e81da7c4..bcd9566fbf 100644
--- a/arm_compute/runtime/CL/functions/CLPermute.h
+++ b/arm_compute/runtime/CL/functions/CLPermute.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018-2020 Arm Limited.
+ * Copyright (c) 2018-2021 Arm Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -25,9 +25,9 @@
#define ARM_COMPUTE_CLPERMUTE_H
#include "arm_compute/core/Types.h"
-#include "arm_compute/runtime/CL/ICLSimpleFunction.h"
+#include "arm_compute/runtime/IFunction.h"
-#include <cstdint>
+#include <memory>
namespace arm_compute
{
@@ -35,10 +35,22 @@ class CLCompileContext;
class ICLTensor;
class ITensorInfo;
-/** Basic function to execute an @ref CLPermuteKernel. */
-class CLPermute : public ICLSimpleFunction
+/** Basic function to execute an @ref opencl::kernels::ClPermuteKernel. */
+class CLPermute : public IFunction
{
public:
+ /** Constructor */
+ CLPermute();
+ /** Destructor */
+ ~CLPermute();
+ /** Prevent instances of this class from being copied (As this class contains pointers) */
+ CLPermute(const CLPermute &) = delete;
+ /** Default move constructor */
+ CLPermute(CLPermute &&);
+ /** Prevent instances of this class from being copied (As this class contains pointers) */
+ CLPermute &operator=(const CLPermute &) = delete;
+ /** Default move assignment operator */
+ CLPermute &operator=(CLPermute &&);
/** Set the input and output tensors.
*
* @note Arbitrary permutation vectors are supported with rank not greater than 4
@@ -69,6 +81,13 @@ public:
* @return a status
*/
static Status validate(const ITensorInfo *input, const ITensorInfo *output, const PermutationVector &perm);
+
+ // Inherited methods overridden:
+ void run() override;
+
+private:
+ struct Impl;
+ std::unique_ptr<Impl> _impl;
};
} // namespace arm_compute
#endif /*ARM_COMPUTE_CLPERMUTE_H */
diff --git a/arm_compute/runtime/CL/functions/CLQLSTMLayer.h b/arm_compute/runtime/CL/functions/CLQLSTMLayer.h
index a8f9221b3d..954f224424 100644
--- a/arm_compute/runtime/CL/functions/CLQLSTMLayer.h
+++ b/arm_compute/runtime/CL/functions/CLQLSTMLayer.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020 Arm Limited.
+ * Copyright (c) 2020-2021 Arm Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -26,6 +26,7 @@
#include "arm_compute/core/Types.h"
#include "arm_compute/runtime/CL/functions/CLActivationLayer.h"
+#include "arm_compute/runtime/CL/functions/CLCopy.h"
#include "arm_compute/runtime/CL/functions/CLElementwiseOperations.h"
#include "arm_compute/runtime/CL/functions/CLGEMMLowpMatrixMultiplyCore.h"
#include "arm_compute/runtime/CL/functions/CLGEMMLowpOutputStage.h"
@@ -38,7 +39,6 @@ namespace arm_compute
{
// Forward declarations
class CLCompileContext;
-class CLCopyKernel;
class ICLTensor;
class CLGEMMLowpMatrixAReductionKernel;
class CLQLSTMLayerNormalizationKernel;
@@ -49,12 +49,12 @@ class ITensorInfo;
* This function calls the following CL functions/kernels:
*
* -# @ref CLActivationLayer Activation functions (tanh and logistic)
- * -# @ref CLCopyKernel Copy kernel for copying output_state_out to output
- * -# @ref CLArithmeticAddition Elementwise addition and subtraction
+ * -# @ref CLCopy Copy function for copying output_state_out to output
+ * -# @ref CLArithmeticAddition Elementwise addition and subtraction
* -# @ref CLGEMMLowpMatrixMultiplyCore Quantized matrix multiplication core. Accumulators are 32-bit integers
* -# @ref CLGEMMLowpQuantizeDownInt32ToInt16ScaleByFixedPoint Convert 32-bit integers into QSYMM16
* -# @ref CLGEMMLowpMatrixAReductionKernel For precomputing effective biases to use
- * -# @ref CLPixelWiseMultiplication Elementwise multiplication
+ * -# @ref CLPixelWiseMultiplication Elementwise multiplication
* -# @ref CLTranspose Transpose function for reshaping the weights
* */
class CLQLSTMLayer : public IFunction
@@ -354,7 +354,7 @@ private:
CLArithmeticAddition _accumulate_projection{};
CLActivationLayer _projection_clip{};
std::array<std::unique_ptr<CLQLSTMLayerNormalizationKernel>, _layer_norm_count> _layer_norms;
- std::unique_ptr<CLCopyKernel> _copy_output;
+ CLCopy _copy_output;
TensorCopyKernel _projection_bias_copy{};
TensorCopyKernel _projection_output_to_accumulate_copy{};
diff --git a/arm_compute/runtime/CL/functions/CLRNNLayer.h b/arm_compute/runtime/CL/functions/CLRNNLayer.h
index ff3fb5449b..50575daaa3 100644
--- a/arm_compute/runtime/CL/functions/CLRNNLayer.h
+++ b/arm_compute/runtime/CL/functions/CLRNNLayer.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018-2020 Arm Limited.
+ * Copyright (c) 2018-2021 Arm Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -26,6 +26,7 @@
#include "arm_compute/runtime/CL/ICLSimpleFunction.h"
#include "arm_compute/runtime/CL/functions/CLActivationLayer.h"
+#include "arm_compute/runtime/CL/functions/CLCopy.h"
#include "arm_compute/runtime/CL/functions/CLElementwiseOperations.h"
#include "arm_compute/runtime/CL/functions/CLFullyConnectedLayer.h"
#include "arm_compute/runtime/CL/functions/CLGEMM.h"
@@ -34,7 +35,6 @@
namespace arm_compute
{
-class CLCopyKernel;
class ICLTensor;
/** Basic function to run @ref CLRNNLayer */
@@ -93,16 +93,16 @@ public:
void prepare() override;
private:
- MemoryGroup _memory_group;
- CLGEMM _gemm_state_f;
- CLArithmeticAddition _add_kernel;
- CLActivationLayer _activation;
- CLFullyConnectedLayer _fully_connected_kernel;
- std::unique_ptr<CLCopyKernel> _copy_kernel;
- CLTensor _fully_connected_out;
- CLTensor _gemm_output;
- CLTensor _add_output;
- bool _is_prepared;
+ MemoryGroup _memory_group;
+ CLGEMM _gemm_state_f;
+ CLArithmeticAddition _add_kernel;
+ CLActivationLayer _activation;
+ CLFullyConnectedLayer _fully_connected_kernel;
+ CLCopy _copy;
+ CLTensor _fully_connected_out;
+ CLTensor _gemm_output;
+ CLTensor _add_output;
+ bool _is_prepared;
};
}
#endif /* ARM_COMPUTE_CLRNN_LAYER_H */
diff --git a/arm_compute/runtime/CL/functions/CLReshapeLayer.h b/arm_compute/runtime/CL/functions/CLReshapeLayer.h
index b4d52ec8cf..60ed81680e 100644
--- a/arm_compute/runtime/CL/functions/CLReshapeLayer.h
+++ b/arm_compute/runtime/CL/functions/CLReshapeLayer.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017-2020 Arm Limited.
+ * Copyright (c) 2017-2021 Arm Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -26,6 +26,7 @@
#include "arm_compute/runtime/CL/ICLOperator.h"
#include "arm_compute/runtime/CL/ICLSimpleFunction.h"
+#include <memory>
namespace arm_compute
{
@@ -33,7 +34,7 @@ class CLCompileContext;
class ICLTensor;
class ITensorInfo;
-/** Basic function to run @ref CLReshapeLayerKernel */
+/** Basic function to run @ref opencl::kernels::ClReshapeKernel */
class CLReshapeLayer : public IFunction
{
public:
@@ -79,30 +80,5 @@ private:
struct Impl;
std::unique_ptr<Impl> _impl;
};
-
-namespace experimental
-{
-/** Basic function to run @ref CLReshapeLayerKernel */
-class CLReshape : 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);
-};
-} // namespace experimental
} // namespace arm_compute
#endif /*ARM_COMPUTE_CLRESHAPELAYER_H */
diff --git a/arm_compute/runtime/CL/functions/CLSpaceToBatchLayer.h b/arm_compute/runtime/CL/functions/CLSpaceToBatchLayer.h
index 5c5e5bed9a..dc02fa1363 100644
--- a/arm_compute/runtime/CL/functions/CLSpaceToBatchLayer.h
+++ b/arm_compute/runtime/CL/functions/CLSpaceToBatchLayer.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018-2020 Arm Limited.
+ * Copyright (c) 2018-2021 Arm Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -26,6 +26,7 @@
#include "arm_compute/core/Types.h"
#include "arm_compute/runtime/CL/CLTensor.h"
+#include "arm_compute/runtime/CL/functions/CLFill.h"
#include "arm_compute/runtime/IFunction.h"
#include <memory>
@@ -33,14 +34,13 @@
namespace arm_compute
{
class CLCompileContext;
-class CLMemsetKernel;
class CLSpaceToBatchLayerKernel;
class ICLTensor;
class ITensorInfo;
/** Basic function to spatial divide a tensor. This function calls the following OpenCL kernels/functions:
*
- * -# @ref CLMemsetKernel
+ * -# @ref CLFill
* -# @ref CLSpaceToBatchLayerKernel
*/
class CLSpaceToBatchLayer : public IFunction
@@ -125,7 +125,7 @@ public:
private:
std::unique_ptr<CLSpaceToBatchLayerKernel> _space_to_batch_kernel; /**< SpaceToBatch kernel to run */
- std::unique_ptr<CLMemsetKernel> _memset_kernel; /**< Memset kernel to run */
+ CLFill _fill; /**< Fill function to run */
bool _has_padding; /**< Flag to check if the output has padding */
};
} // namespace arm_compute
diff --git a/docs/00_introduction.dox b/docs/00_introduction.dox
index ab2495dbff..2f239960c3 100644
--- a/docs/00_introduction.dox
+++ b/docs/00_introduction.dox
@@ -191,7 +191,7 @@ v20.11 Public major release
- @ref CLFuseBatchNormalizationKernel
- @ref CLDepthwiseConvolutionLayerNativeKernel
- @ref CLDepthConvertLayerKernel
- - @ref CLCopyKernel
+ - CLCopyKernel
- @ref CLDepthwiseConvolutionLayer3x3NHWCKernel
- CLActivationLayerKernel
- @ref CLWinogradFilterTransformKernel
@@ -434,7 +434,7 @@ v20.08 Public major release
- @ref CLArgMinMaxLayerKernel
- Added new data type U8 support for:
- @ref NECropKernel
- - @ref CLCropKernel
+ - CLCropKernel
- Added aligh_corner support for nearest neighbor interpolation in:
- @ref NEScaleKernel
- @ref CLScaleKernel
@@ -777,7 +777,7 @@ v19.05 Public major release
- @ref NEFFTConvolutionLayer
- New OpenCL kernels / functions:
- @ref CLComplexPixelWiseMultiplicationKernel / @ref CLComplexPixelWiseMultiplication
- - @ref CLCropKernel / @ref CLCropResize
+ - CLCropKernel / @ref CLCropResize
- @ref CLDeconvolutionReshapeOutputKernel
- @ref CLFFTDigitReverseKernel
- @ref CLFFTRadixStageKernel
@@ -1019,7 +1019,7 @@ v18.05 Public major release
- New OpenCL kernels / functions:
- @ref CLChannelShuffleLayer / @ref CLChannelShuffleLayerKernel
- @ref CLConvertFullyConnectedWeightsKernel / @ref CLConvertFullyConnectedWeights
- - @ref CLCopy / @ref CLCopyKernel
+ - @ref CLCopy / CLCopyKernel
- @ref CLLSTMLayer
- @ref CLRNNLayer
- CLWidthConcatenateLayer / CLWidthConcatenateLayerKernel
@@ -1103,7 +1103,7 @@ v18.01 Public maintenance release
- Various bug fixes
- Added some of the missing validate() methods
- Added @ref CLDeconvolutionLayerUpsampleKernel / @ref CLDeconvolutionLayer @ref CLDeconvolutionLayerUpsample
- - Added @ref CLPermuteKernel / @ref CLPermute
+ - Added CLPermuteKernel / @ref CLPermute
- Added method to clean the programs cache in the CL Kernel library.
- Added @ref GCArithmeticAdditionKernel / @ref GCArithmeticAddition
- Added @ref GCDepthwiseConvolutionLayer3x3Kernel / @ref GCDepthwiseConvolutionLayer3x3
@@ -1218,7 +1218,7 @@ v17.09 Public major release
- @ref CLQuantizationLayerKernel @ref CLMinMaxLayerKernel / @ref CLQuantizationLayer
- @ref CLROIPoolingLayerKernel / @ref CLROIPoolingLayer
- @ref CLReductionOperationKernel / @ref CLReductionOperation
- - @ref CLReshapeLayerKernel / @ref CLReshapeLayer
+ - CLReshapeLayerKernel / @ref CLReshapeLayer
v17.06 Public major release
- Various bug fixes
diff --git a/docs/04_adding_operator.dox b/docs/04_adding_operator.dox
index 9e6f3751b8..f311fb4d51 100644
--- a/docs/04_adding_operator.dox
+++ b/docs/04_adding_operator.dox
@@ -117,7 +117,7 @@ Each kernel will have to implement the method:
The structure of the kernel .cpp file should be similar to the next ones.
For OpenCL:
-@snippet src/core/CL/kernels/CLReshapeLayerKernel.cpp CLReshapeLayerKernel Kernel
+@snippet src/core/gpu/cl/kernels/ClReshapeKernel.cpp ClReshapeKernel Kernel
The run will call the function defined in the .cl file.
For the NEON backend case:
diff --git a/src/core/CL/CLKernels.h b/src/core/CL/CLKernels.h
index ac051684a1..7383dce40f 100644
--- a/src/core/CL/CLKernels.h
+++ b/src/core/CL/CLKernels.h
@@ -42,8 +42,6 @@
#include "src/core/CL/kernels/CLComparisonKernel.h"
#include "src/core/CL/kernels/CLConvertFullyConnectedWeightsKernel.h"
#include "src/core/CL/kernels/CLConvolutionKernel.h"
-#include "src/core/CL/kernels/CLCopyKernel.h"
-#include "src/core/CL/kernels/CLCropKernel.h"
#include "src/core/CL/kernels/CLDeconvolutionLayerUpsampleKernel.h"
#include "src/core/CL/kernels/CLDeconvolutionReshapeOutputKernel.h"
#include "src/core/CL/kernels/CLDepthConvertLayerKernel.h"
@@ -97,7 +95,6 @@
#include "src/core/CL/kernels/CLMeanStdDevKernel.h"
#include "src/core/CL/kernels/CLMeanStdDevNormalizationKernel.h"
#include "src/core/CL/kernels/CLMedian3x3Kernel.h"
-#include "src/core/CL/kernels/CLMemsetKernel.h"
#include "src/core/CL/kernels/CLMinMaxLayerKernel.h"
#include "src/core/CL/kernels/CLMinMaxLocationKernel.h"
#include "src/core/CL/kernels/CLNonLinearFilterKernel.h"
@@ -105,7 +102,6 @@
#include "src/core/CL/kernels/CLNormalizationLayerKernel.h"
#include "src/core/CL/kernels/CLNormalizePlanarYUVLayerKernel.h"
#include "src/core/CL/kernels/CLPadLayerKernel.h"
-#include "src/core/CL/kernels/CLPermuteKernel.h"
#include "src/core/CL/kernels/CLPixelWiseMultiplicationKernel.h"
#include "src/core/CL/kernels/CLPriorBoxLayerKernel.h"
#include "src/core/CL/kernels/CLQLSTMLayerNormalizationKernel.h"
@@ -116,7 +112,6 @@
#include "src/core/CL/kernels/CLReductionOperationKernel.h"
#include "src/core/CL/kernels/CLRemapKernel.h"
#include "src/core/CL/kernels/CLReorgLayerKernel.h"
-#include "src/core/CL/kernels/CLReshapeLayerKernel.h"
#include "src/core/CL/kernels/CLReverseKernel.h"
#include "src/core/CL/kernels/CLScaleKernel.h"
#include "src/core/CL/kernels/CLScharr3x3Kernel.h"
diff --git a/src/core/CL/kernels/CLCopyKernel.h b/src/core/CL/kernels/CLCopyKernel.h
deleted file mode 100644
index 9a20b88884..0000000000
--- a/src/core/CL/kernels/CLCopyKernel.h
+++ /dev/null
@@ -1,83 +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_CLCOPYKERNEL_H
-#define ARM_COMPUTE_CLCOPYKERNEL_H
-
-#include "arm_compute/core/Types.h"
-#include "src/core/CL/ICLKernel.h"
-
-namespace arm_compute
-{
-class ICLTensor;
-
-/** OpenCL kernel to perform a copy between two tensors */
-class CLCopyKernel : public ICLKernel
-{
-public:
- /** Default constructor */
- CLCopyKernel();
- /** Prevent instances of this class from being copied (As this class contains pointers). */
- CLCopyKernel(const CLCopyKernel &) = delete;
- /** Prevent instances of this class from being copied (As this class contains pointers). */
- CLCopyKernel &operator=(const CLCopyKernel &) = delete;
- /** Allow instances of this class to be moved */
- CLCopyKernel(CLCopyKernel &&) = default;
- /** Allow instances of this class to be moved */
- CLCopyKernel &operator=(CLCopyKernel &&) = default;
- /** Initialize the kernel's input, output.
- *
- * @param[in] input Source tensor. Data types supported: All.
- * @param[out] output Destination tensor. Data types supported: same as @p input.
- * @param[in] output_window (Optional) Window to be used in case only copying into part of a tensor. Default is nullptr.
- */
- void configure(const ICLTensor *input, ICLTensor *output, Window *output_window = nullptr);
- /** Initialize the kernel's input, output.
- *
- * @param[in] compile_context The compile context to be used.
- * @param[in] input Source tensor. Data types supported: All.
- * @param[out] output Destination tensor. Data types supported: same as @p input.
- * @param[in] output_window (Optional) Window to be used in case only copying into part of a tensor. Default is nullptr.
- */
- void configure(const CLCompileContext &compile_context, const ICLTensor *input, ICLTensor *output, Window *output_window = nullptr);
- /** Static function to check if given info will lead to a valid configuration of @ref CLCopyKernel
- *
- * @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] output_window (Optional) Window to be used in case only copying into part of a tensor. Default is nullptr.
- *
- * @return a status
- */
- static Status validate(const ITensorInfo *input, const ITensorInfo *output, Window *output_window = nullptr);
-
- // Inherited methods overridden:
- void run(const Window &window, cl::CommandQueue &queue) override;
-
-private:
- const ICLTensor *_input;
- ICLTensor *_output;
- Window _output_window;
- bool _has_output_window;
-};
-} // namespace arm_compute
-#endif /*ARM_COMPUTE_CLCOPYKERNEL_H */
diff --git a/src/core/CL/kernels/CLPermuteKernel.h b/src/core/CL/kernels/CLPermuteKernel.h
deleted file mode 100644
index d1bb875d7a..0000000000
--- a/src/core/CL/kernels/CLPermuteKernel.h
+++ /dev/null
@@ -1,90 +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_CLPERMUTEKERNEL_H
-#define ARM_COMPUTE_CLPERMUTEKERNEL_H
-
-#include "src/core/CL/ICLKernel.h"
-
-namespace arm_compute
-{
-class ICLTensor;
-
-/** OpenCL kernel to perform tensor permutation.
- *
- * Permutes given a permutation vector
- */
-class CLPermuteKernel : public ICLKernel
-{
-public:
- /** Default constructor */
- CLPermuteKernel();
- /** Prevent instances of this class from being copied (As this class contains pointers) */
- CLPermuteKernel(const CLPermuteKernel &) = delete;
- /** Prevent instances of this class from being copied (As this class contains pointers) */
- CLPermuteKernel &operator=(const CLPermuteKernel &) = delete;
- /** Allow instances of this class to be moved */
- CLPermuteKernel(CLPermuteKernel &&) = default;
- /** Allow instances of this class to be moved */
- CLPermuteKernel &operator=(CLPermuteKernel &&) = default;
- /** Set the input and output of the kernel.
- *
- * @note Arbitrary permutation vectors are supported with rank not greater than 4
- *
- * @param[in] input The input tensor to permute. Data types supported: All.
- * @param[in] output The output tensor. Data types supported: Same as @p input
- * @param[in] perm Permutation vector
- */
- void configure(const ICLTensor *input, ICLTensor *output, const PermutationVector &perm);
- /** Set the input and output of the kernel.
- *
- * @note Arbitrary permutation vectors are supported with rank not greater than 4
- *
- * @param[in] compile_context The compile context to be used.
- * @param[in] input The input tensor to permute. Data types supported: All.
- * @param[in] output The output tensor. Data types supported: Same as @p input
- * @param[in] perm Permutation vector
- */
- void configure(const CLCompileContext &compile_context, const ICLTensor *input, ICLTensor *output, const PermutationVector &perm);
- /** Static function to check if given info will lead to a valid configuration of @ref CLPermuteKernel
- *
- * @note Arbitrary permutation vectors are supported with rank not greater than 4
- *
- * @param[in] input First tensor input info. Data types supported: All.
- * @param[in] output Output tensor info. Data types supported: same as @p input.
- * @param[in] perm Permutation vector
- *
- * @return a status
- */
- static Status validate(const ITensorInfo *input, const ITensorInfo *output, const PermutationVector &perm);
-
- // Inherited methods overridden:
- void run(const Window &window, cl::CommandQueue &queue) override;
-
-private:
- const ICLTensor *_input;
- ICLTensor *_output;
- PermutationVector _perm;
-};
-} // arm_compute
-#endif /*ARM_COMPUTE_CLPERMUTEKERNEL_H */
diff --git a/src/core/CL/kernels/CLCopyKernel.cpp b/src/core/gpu/cl/kernels/ClCopyKernel.cpp
index ca38b65df4..d6c87f8fad 100644
--- a/src/core/CL/kernels/CLCopyKernel.cpp
+++ b/src/core/gpu/cl/kernels/ClCopyKernel.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018-2020 Arm Limited.
+ * Copyright (c) 2018-2021 Arm Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -21,36 +21,45 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
-#include "src/core/CL/kernels/CLCopyKernel.h"
+#include "src/core/gpu/cl/kernels/ClCopyKernel.h"
#include "arm_compute/core/CL/CLHelpers.h"
#include "arm_compute/core/CL/CLKernelLibrary.h"
#include "arm_compute/core/CL/ICLTensor.h"
+#include "arm_compute/core/Helpers.h"
+#include "arm_compute/core/TensorInfo.h"
#include "arm_compute/core/Utils.h"
+#include "arm_compute/core/Validate.h"
+#include "src/core/CL/CLValidate.h"
#include "src/core/helpers/AutoConfiguration.h"
#include "src/core/helpers/WindowHelpers.h"
+#include "support/Cast.h"
#include "support/StringSupport.h"
namespace arm_compute
{
+namespace opencl
+{
+namespace kernels
+{
namespace
{
-Status validate_arguments(const ITensorInfo *input, const ITensorInfo *output, Window *output_window = nullptr)
+Status validate_arguments(const ITensorInfo *src, const ITensorInfo *dst, Window *dst_window = nullptr)
{
- ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(input, output);
+ ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(src, dst);
- // Validate output if initialized
- if(output->total_size() != 0)
+ // Validate dst if initialized
+ if(dst->total_size() != 0)
{
- ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(input, output);
- ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_QUANTIZATION_INFO(input, output);
- if(output_window == nullptr)
+ ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(src, dst);
+ ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_QUANTIZATION_INFO(src, dst);
+ if(dst_window == nullptr)
{
- ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DIMENSIONS(input->tensor_shape(), output->tensor_shape());
+ ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DIMENSIONS(src->tensor_shape(), dst->tensor_shape());
}
else
{
- ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DIMENSIONS(input->tensor_shape(), output_window->shape());
+ ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DIMENSIONS(src->tensor_shape(), dst_window->shape());
}
}
@@ -59,56 +68,43 @@ Status validate_arguments(const ITensorInfo *input, const ITensorInfo *output, W
} // namespace
-CLCopyKernel::CLCopyKernel()
- : _input(nullptr), _output(nullptr), _output_window(), _has_output_window(false)
-{
-}
-
-void CLCopyKernel::configure(const ICLTensor *input, ICLTensor *output, Window *output_window)
+void ClCopyKernel::configure(const CLCompileContext &compile_context, const ITensorInfo *src, ITensorInfo *dst, Window *dst_window)
{
- configure(CLKernelLibrary::get().get_compile_context(), input, output, output_window);
-}
-
-void CLCopyKernel::configure(const CLCompileContext &compile_context, const ICLTensor *input, ICLTensor *output, Window *output_window)
-{
- ARM_COMPUTE_ERROR_ON_NULLPTR(input, output);
- ARM_COMPUTE_ERROR_THROW_ON(validate_arguments(input->info(), output->info(), output_window));
+ ARM_COMPUTE_ERROR_ON_NULLPTR(src, dst);
+ ARM_COMPUTE_ERROR_THROW_ON(validate_arguments(src, dst, dst_window));
- auto padding_info = get_padding_info({ input, output });
-
- _input = input;
- _output = output;
+ auto padding_info = get_padding_info({ src, dst });
// Create kernel
CLBuildOptions build_opts;
- build_opts.add_option("-DDATA_TYPE=" + get_cl_type_from_data_type(input->info()->data_type()));
+ build_opts.add_option("-DDATA_TYPE=" + get_cl_type_from_data_type(src->data_type()));
// Output auto inizialitation if not yet initialized
- auto_init_if_empty(*(output->info()), *(input->info()));
+ auto_init_if_empty(*dst, *src);
// Configure window
- const unsigned int vec_size_x = adjust_vec_size(16 / input->info()->element_size(), input->info()->dimension(0));
+ const unsigned int vec_size_x = adjust_vec_size(16 / src->element_size(), src->dimension(0));
- const Window win_config = calculate_max_window(*(input->info()), Steps(vec_size_x));
+ const Window win_config = calculate_max_window(*src, Steps(vec_size_x));
- if(output_window != nullptr)
+ if(dst_window != nullptr)
{
- _has_output_window = true;
- _output_window = Window(*output_window);
- const int width_x = output_window->num_iterations(0);
+ _has_dst_window = true;
+ _dst_window = Window(*dst_window);
+ const int width_x = dst_window->num_iterations(0);
const int vec_size_x_leftover = width_x % vec_size_x;
const bool multi_access_x = width_x >= static_cast<int32_t>(vec_size_x);
if(multi_access_x)
{
- _output_window.set(Window::DimX, Window::Dimension(output_window->x().start(), ceil_to_multiple(output_window->x().end(), vec_size_x), vec_size_x));
+ _dst_window.set(Window::DimX, Window::Dimension(dst_window->x().start(), ceil_to_multiple(dst_window->x().end(), vec_size_x), vec_size_x));
}
build_opts.add_option("-DVEC_SIZE_LEFTOVER=" + support::cpp11::to_string(vec_size_x_leftover));
}
else
{
- const int width_x = input->info()->tensor_shape().x();
+ const int width_x = src->tensor_shape().x();
const int vec_size_x_leftover = width_x % vec_size_x;
build_opts.add_option("-DVEC_SIZE_LEFTOVER=" + support::cpp11::to_string(vec_size_x_leftover));
@@ -125,32 +121,35 @@ void CLCopyKernel::configure(const CLCompileContext &compile_context, const ICLT
ARM_COMPUTE_ERROR_ON(has_padding_changed(padding_info));
}
-Status CLCopyKernel::validate(const arm_compute::ITensorInfo *input, const arm_compute::ITensorInfo *output, Window *output_window)
+Status ClCopyKernel::validate(const arm_compute::ITensorInfo *src, const arm_compute::ITensorInfo *dst, Window *dst_window)
{
- ARM_COMPUTE_RETURN_ON_ERROR(validate_arguments(input, output, output_window));
+ ARM_COMPUTE_RETURN_ON_ERROR(validate_arguments(src, dst, dst_window));
return Status{};
}
-void CLCopyKernel::run(const Window &window, cl::CommandQueue &queue)
+void ClCopyKernel::run_op(ITensorPack &tensors, const Window &window, cl::CommandQueue &queue)
{
ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(this);
ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(ICLKernel::window(), window);
+ const auto src = utils::cast::polymorphic_downcast<const ICLTensor *>(tensors.get_const_tensor(TensorType::ACL_SRC));
+ auto dst = utils::cast::polymorphic_downcast<ICLTensor *>(tensors.get_tensor(TensorType::ACL_DST));
+
Window slice;
- if(_has_output_window)
+ if(_has_dst_window)
{
slice = window.first_slice_window_3D();
- Window out_slice = _output_window.first_slice_window_3D();
+ Window out_slice = _dst_window.first_slice_window_3D();
do
{
unsigned int idx = 0;
- add_3D_tensor_argument(idx, _input, slice);
- add_3D_tensor_argument(idx, _output, out_slice);
+ add_3D_tensor_argument(idx, src, slice);
+ add_3D_tensor_argument(idx, dst, out_slice);
enqueue(queue, *this, slice, lws_hint());
}
- while(window.slide_window_slice_3D(slice) && _output_window.slide_window_slice_3D(out_slice));
+ while(window.slide_window_slice_3D(slice) && _dst_window.slide_window_slice_3D(out_slice));
}
else
{
@@ -159,11 +158,13 @@ void CLCopyKernel::run(const Window &window, cl::CommandQueue &queue)
do
{
unsigned int idx = 0;
- add_3D_tensor_argument(idx, _input, slice);
- add_3D_tensor_argument(idx, _output, slice);
+ add_3D_tensor_argument(idx, src, slice);
+ add_3D_tensor_argument(idx, dst, slice);
enqueue(queue, *this, slice, lws_hint());
}
while(collapsed.slide_window_slice_3D(slice));
}
}
+} // namespace kernels
+} // namespace opencl
} // namespace arm_compute
diff --git a/src/core/gpu/cl/kernels/ClCopyKernel.h b/src/core/gpu/cl/kernels/ClCopyKernel.h
new file mode 100644
index 0000000000..9d5457d72d
--- /dev/null
+++ b/src/core/gpu/cl/kernels/ClCopyKernel.h
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2018-2021 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_CL_COPY_KERNEL_H
+#define ARM_COMPUTE_CL_COPY_KERNEL_H
+
+#include "src/core/common/Macros.h"
+#include "src/core/gpu/cl/ClCompileContext.h"
+#include "src/core/gpu/cl/IClKernel.h"
+
+namespace arm_compute
+{
+namespace opencl
+{
+namespace kernels
+{
+/** OpenCL kernel to perform a copy between two tensors */
+class ClCopyKernel : public ICLKernel
+{
+public:
+ ClCopyKernel() = default;
+ ARM_COMPUTE_DISALLOW_COPY_ALLOW_MOVE(ClCopyKernel);
+ /** Initialize the kernel's src, dst.
+ *
+ * @param[in] compile_context The compile context to be used.
+ * @param[in] src Source tensor info. Data types supported: All.
+ * @param[out] dst Destination tensor info. Data types supported: same as @p src.
+ * @param[in] dst_window (Optional) Window to be used in case only copying into part of a tensor. Default is nullptr.
+ */
+ void configure(const CLCompileContext &compile_context, const ITensorInfo *src, ITensorInfo *dst, Window *dst_window = nullptr);
+ /** Static function to check if given info will lead to a valid configuration of @ref ClCopyKernel
+ *
+ * @param[in] src Source tensor info. Data types supported: All.
+ * @param[in] dst Destination tensor info. Data types supported: same as @p src.
+ * @param[in] dst_window (Optional) Window to be used in case only copying into part of a tensor. Default is nullptr.
+ *
+ * @return a status
+ */
+ static Status validate(const ITensorInfo *src, const ITensorInfo *dst, Window *dst_window = nullptr);
+
+ // Inherited methods overridden:
+ void run_op(ITensorPack &tensors, const Window &window, cl::CommandQueue &queue) override;
+
+private:
+ Window _dst_window{};
+ bool _has_dst_window{};
+};
+} // namespace kernels
+} // namespace opencl
+} // namespace arm_compute
+#endif /*ARM_COMPUTE_CL_COPY_KERNEL_H */
diff --git a/src/core/CL/kernels/CLCropKernel.cpp b/src/core/gpu/cl/kernels/ClCropKernel.cpp
index 9cf15ff93b..20e94b2876 100644
--- a/src/core/CL/kernels/CLCropKernel.cpp
+++ b/src/core/gpu/cl/kernels/ClCropKernel.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019-2020 Arm Limited.
+ * Copyright (c) 2019-2021 Arm Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -21,57 +21,55 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
-#include "src/core/CL/kernels/CLCropKernel.h"
+#include "src/core/gpu/cl/kernels/ClCropKernel.h"
#include "arm_compute/core/CL/CLHelpers.h"
#include "arm_compute/core/CL/CLKernelLibrary.h"
#include "arm_compute/core/CL/ICLTensor.h"
#include "arm_compute/core/IAccessWindow.h"
#include "arm_compute/core/TensorInfo.h"
+#include "arm_compute/core/Utils.h"
#include "src/core/CPP/Validate.h"
#include "src/core/helpers/WindowHelpers.h"
-
+#include "support/Cast.h"
#include "support/StringSupport.h"
#include <map>
namespace arm_compute
{
-CLCropKernel::CLCropKernel()
- : _input(nullptr), _output(nullptr), _start(), _batch_index(0), _extrapolation_value(0)
+namespace opencl
{
-}
-
-void CLCropKernel::configure(const ICLTensor *input, ICLTensor *output, Coordinates2D start, Coordinates2D end, uint32_t batch_index, float extrapolation_value, Window *output_window)
+namespace kernels
{
- configure(CLKernelLibrary::get().get_compile_context(), input, output, start, end, batch_index, extrapolation_value, output_window);
+void ClCropKernel::configure(const ITensorInfo *src, ITensorInfo *dst, Coordinates2D start, Coordinates2D end, uint32_t batch_index, float extrapolation_value, Window *dst_window)
+{
+ configure(CLKernelLibrary::get().get_compile_context(), src, dst, start, end, batch_index, extrapolation_value, dst_window);
}
-void CLCropKernel::configure(const CLCompileContext &compile_context, const ICLTensor *input, ICLTensor *output, Coordinates2D start, Coordinates2D end, uint32_t batch_index,
- float extrapolation_value, Window *output_window)
+void ClCropKernel::configure(const CLCompileContext &compile_context, const ITensorInfo *src, ITensorInfo *dst, Coordinates2D start, Coordinates2D end, uint32_t batch_index,
+ float extrapolation_value, Window *dst_window)
{
- ARM_COMPUTE_ERROR_ON_NULLPTR(input, output);
- ARM_COMPUTE_ERROR_THROW_ON(validate(input->info(), output->info(), start, end, batch_index, extrapolation_value, output_window));
+ ARM_COMPUTE_ERROR_ON_NULLPTR(src, dst);
+ ARM_COMPUTE_ERROR_THROW_ON(validate(src, dst, start, end, batch_index, extrapolation_value, dst_window));
- _input = input;
- _output = output;
_start = start;
_batch_index = batch_index;
_extrapolation_value = extrapolation_value;
const int vec_size_x = 4;
// Create and update the window (if needed)
- Window win = calculate_max_window(*output->info());
+ Window win = calculate_max_window(*dst);
- if(output_window != nullptr)
+ if(dst_window != nullptr)
{
- ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(win, *output_window);
- win = *output_window;
+ ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(win, *dst_window);
+ win = *dst_window;
}
- const int output_width_x = win.num_iterations(0);
- const bool multi_access_x = output_width_x >= vec_size_x;
- const bool remainder_x = output_width_x % vec_size_x > 0;
+ const int dst_width_x = win.num_iterations(0);
+ const bool multi_access_x = dst_width_x >= vec_size_x;
+ const bool remainder_x = dst_width_x % vec_size_x > 0;
if(multi_access_x)
{
@@ -82,53 +80,58 @@ void CLCropKernel::configure(const CLCompileContext &compile_context, const ICLT
// Create kernel
CLBuildOptions build_opts;
- build_opts.add_option("-DDATA_TYPE=" + get_cl_type_from_data_type(input->info()->data_type()));
+ build_opts.add_option("-DDATA_TYPE=" + get_cl_type_from_data_type(src->data_type()));
build_opts.add_option_if(multi_access_x, "-DVEC_SIZE=" + support::cpp11::to_string(vec_size_x));
- build_opts.add_option_if(multi_access_x && remainder_x, "-DLAST_ACCESSED_X=" + support::cpp11::to_string(std::max<int>(output_width_x - vec_size_x, 0)));
+ build_opts.add_option_if(multi_access_x && remainder_x, "-DLAST_ACCESSED_X=" + support::cpp11::to_string(std::max<int>(dst_width_x - vec_size_x, 0)));
build_opts.add_option_if(start.x > end.x, "-DWIDTH_FLIPPED=");
build_opts.add_option_if(start.y > end.y, "-DHEIGHT_FLIPPED=");
_kernel = create_kernel(compile_context, "crop_tensor", build_opts.options());
}
-Status CLCropKernel::validate(const ITensorInfo *input, const ITensorInfo *output, Coordinates2D start, Coordinates2D end, uint32_t batch_index, float extrapolation_value, Window *output_window)
+Status ClCropKernel::validate(const ITensorInfo *src, const ITensorInfo *dst, Coordinates2D start, Coordinates2D end, uint32_t batch_index, float extrapolation_value, Window *dst_window)
{
- ARM_COMPUTE_UNUSED(extrapolation_value, output_window);
- ARM_COMPUTE_RETURN_ERROR_ON_CPU_F16_UNSUPPORTED(input);
- ARM_COMPUTE_RETURN_ERROR_ON(input->data_type() == DataType::UNKNOWN);
- ARM_COMPUTE_RETURN_ERROR_ON_DATA_LAYOUT_NOT_IN(input, DataLayout::NHWC);
- ARM_COMPUTE_RETURN_ERROR_ON(input->tensor_shape().num_dimensions() > 4);
+ ARM_COMPUTE_UNUSED(extrapolation_value, dst_window);
+ ARM_COMPUTE_RETURN_ERROR_ON_CPU_F16_UNSUPPORTED(src);
+ ARM_COMPUTE_RETURN_ERROR_ON(src->data_type() == DataType::UNKNOWN);
+ ARM_COMPUTE_RETURN_ERROR_ON_DATA_LAYOUT_NOT_IN(src, DataLayout::NHWC);
+ ARM_COMPUTE_RETURN_ERROR_ON(src->tensor_shape().num_dimensions() > 4);
ARM_COMPUTE_RETURN_ERROR_ON(start.x < 0 || start.y < 0 || end.x < 0 || end.y < 0);
- ARM_COMPUTE_RETURN_ERROR_ON(start.x >= static_cast<int32_t>(input->dimension(1)) || start.y >= static_cast<int32_t>(input->dimension(2))
- || end.x >= static_cast<int32_t>(input->dimension(1)) || end.y >= static_cast<int32_t>(input->dimension(2)));
- ARM_COMPUTE_RETURN_ERROR_ON(batch_index >= input->dimension(3));
- if(output_window != nullptr)
+ ARM_COMPUTE_RETURN_ERROR_ON(start.x >= static_cast<int32_t>(src->dimension(1)) || start.y >= static_cast<int32_t>(src->dimension(2))
+ || end.x >= static_cast<int32_t>(src->dimension(1)) || end.y >= static_cast<int32_t>(src->dimension(2)));
+ ARM_COMPUTE_RETURN_ERROR_ON(batch_index >= src->dimension(3));
+ if(dst_window != nullptr)
{
- ARM_COMPUTE_RETURN_ERROR_ON(output_window->x().step() != 1);
+ ARM_COMPUTE_RETURN_ERROR_ON(dst_window->x().step() != 1);
}
- if(output->total_size() > 0)
+ if(dst->total_size() > 0)
{
- ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_NOT_IN(output, DataType::F32);
- ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_LAYOUT(input, output);
- ARM_COMPUTE_RETURN_ERROR_ON(output->num_dimensions() > 3);
+ ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_NOT_IN(dst, DataType::F32);
+ ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_LAYOUT(src, dst);
+ ARM_COMPUTE_RETURN_ERROR_ON(dst->num_dimensions() > 3);
}
return Status{};
}
-void CLCropKernel::run(const Window &window, cl::CommandQueue &queue)
+void ClCropKernel::run_op(ITensorPack &tensors, const Window &window, cl::CommandQueue &queue)
{
ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(this);
ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(ICLKernel::window(), window);
+ const auto src = utils::cast::polymorphic_downcast<const ICLTensor *>(tensors.get_const_tensor(TensorType::ACL_SRC));
+ auto dst = utils::cast::polymorphic_downcast<ICLTensor *>(tensors.get_tensor(TensorType::ACL_DST));
+
Window in_slice = Window();
- in_slice.use_tensor_dimensions(_input->info()->tensor_shape());
+ in_slice.use_tensor_dimensions(src->info()->tensor_shape());
in_slice.set(Window::DimX, Window::Dimension(in_slice.x().start(), ceil_to_multiple(in_slice.x().end(), window.x().step()), window.x().step()));
in_slice.set(3, Window::Dimension(_batch_index, _batch_index + 1, 1));
unsigned int idx = 0;
- add_3D_tensor_argument(idx, _input, in_slice);
- add_3D_tensor_argument(idx, _output, window);
+ add_3D_tensor_argument(idx, src, in_slice);
+ add_3D_tensor_argument(idx, dst, window);
add_argument(idx, _start.x);
add_argument(idx, _start.y);
enqueue(queue, *this, window, lws_hint());
}
+} // namespace kernels
+} // namespace opencl
} // namespace arm_compute
diff --git a/src/core/gpu/cl/kernels/ClCropKernel.h b/src/core/gpu/cl/kernels/ClCropKernel.h
new file mode 100644
index 0000000000..92f94d471b
--- /dev/null
+++ b/src/core/gpu/cl/kernels/ClCropKernel.h
@@ -0,0 +1,98 @@
+/*
+ * Copyright (c) 2019-2021 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_CLCROPKERNEL_H
+#define ARM_COMPUTE_CLCROPKERNEL_H
+
+#include "src/core/common/Macros.h"
+#include "src/core/gpu/cl/ClCompileContext.h"
+#include "src/core/gpu/cl/IClKernel.h"
+
+namespace arm_compute
+{
+namespace opencl
+{
+namespace kernels
+{
+/** OpenCL kernel to perform a copy between two tensors */
+class ClCropKernel : public ICLKernel
+{
+public:
+ ClCropKernel() = default;
+ ARM_COMPUTE_DISALLOW_COPY_ALLOW_MOVE(ClCropKernel);
+ /** Configure kernel
+ *
+ * @note Supported tensor rank: up to 4
+ *
+ * @param[in] src Source tensor info. Data type supported: All. Data layouts supported: NHWC.
+ * @param[out] dst Destination tensor info. Data type supported: F32
+ * @param[in] start Coordinates of where to start cropping the image.
+ * @param[in] end Coordinates of where to end cropping the image.
+ * @param[in] batch_index Fourth dimension index of the 3D image to crop in @p src.
+ * @param[in] extrapolation_value Value to be used for values outside of the image. Default is 0.
+ * @param[in] dst_window Output window to be used in case cropped image is being copied into a tensor. Default is nullptr.
+ */
+ void configure(const ITensorInfo *src, ITensorInfo *dst, Coordinates2D start, Coordinates2D end, uint32_t batch_index, float extrapolation_value = 0, Window *dst_window = nullptr);
+ /** Configure kernel
+ *
+ * @note Supported tensor rank: up to 4
+ *
+ * @param[in] compile_context The compile context to be used.
+ * @param[in] src Source tensor info. Data type supported: All. Data layouts supported: NHWC.
+ * @param[out] dst Destination tensor info. Data type supported: F32
+ * @param[in] start Coordinates of where to start cropping the image.
+ * @param[in] end Coordinates of where to end cropping the image.
+ * @param[in] batch_index Fourth dimension index of the 3D image to crop in @p src.
+ * @param[in] extrapolation_value Value to be used for values outside of the image. Default is 0.
+ * @param[in] dst_window Output window to be used in case cropped image is being copied into a tensor. Default is nullptr.
+ */
+ void configure(const CLCompileContext &compile_context, const ITensorInfo *src, ITensorInfo *dst, Coordinates2D start, Coordinates2D end, uint32_t batch_index, float extrapolation_value = 0,
+ Window *dst_window = nullptr);
+
+ /** Static function to check if given info will lead to a valid configuration of @ref CLStridedSliceKernel
+ *
+ * @note Supported tensor rank: up to 4
+ *
+ * @param[in] src Source tensor info. Data type supported: All. Data layouts supported: NHWC.
+ * @param[in] dst Destination tensor info. Data type supported: F32
+ * @param[in] start Coordinates of where to start cropping the image.
+ * @param[in] end Coordinates of where to end cropping the image.
+ * @param[in] batch_index Fourth dimension index of the 3D image to crop in @p src.
+ * @param[in] extrapolation_value Value to be used for values outside of the image. Default is 0.
+ * @param[in] dst_window Output window to be used in case cropped image is being copied into a tensor. Default is nullptr.
+ */
+ static Status validate(const ITensorInfo *src, const ITensorInfo *dst, Coordinates2D start, Coordinates2D end, uint32_t batch_index, float extrapolation_value = 0,
+ Window *dst_window = nullptr);
+
+ // Inherited methods overridden:
+ void run_op(ITensorPack &tensors, const Window &window, cl::CommandQueue &queue) override;
+
+private:
+ Coordinates2D _start{};
+ uint32_t _batch_index{};
+ float _extrapolation_value{};
+};
+} // namespace kernels
+} // namespace opencl
+} // namespace arm_compute
+#endif /*ARM_COMPUTE_CLCROPKERNEL_H */
diff --git a/src/core/CL/kernels/CLMemsetKernel.cpp b/src/core/gpu/cl/kernels/ClFillKernel.cpp
index 2543b07a1a..b194ee549b 100644
--- a/src/core/CL/kernels/CLMemsetKernel.cpp
+++ b/src/core/gpu/cl/kernels/ClFillKernel.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018-2020 Arm Limited.
+ * Copyright (c) 2018-2021 Arm Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -21,40 +21,46 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
-#include "src/core/CL/kernels/CLMemsetKernel.h"
+#include "src/core/gpu/cl/kernels/ClFillKernel.h"
+
+#include "arm_compute/core/CL/CLHelpers.h"
+#include "arm_compute/core/CL/CLKernelLibrary.h"
#include "arm_compute/core/CL/ICLTensor.h"
-#include "arm_compute/core/utils/misc/ShapeCalculator.h"
+#include "arm_compute/core/Helpers.h"
+#include "arm_compute/core/TensorInfo.h"
+#include "arm_compute/core/Utils.h"
+#include "arm_compute/core/Validate.h"
+#include "src/core/CL/CLValidate.h"
+#include "src/core/helpers/AutoConfiguration.h"
#include "src/core/helpers/WindowHelpers.h"
+#include "support/Cast.h"
#include "support/StringSupport.h"
namespace arm_compute
{
-CLMemsetKernel::CLMemsetKernel()
- : ICLKernel(), _tensor(nullptr), _full_window()
+namespace opencl
{
-}
-
-void CLMemsetKernel::configure(ICLTensor *tensor,
- const PixelValue &constant_value,
- Window *window)
+namespace kernels
+{
+void ClFillKernel::configure(ITensorInfo *tensor,
+ const PixelValue &constant_value,
+ Window *window)
{
configure(CLKernelLibrary::get().get_compile_context(), tensor, constant_value, window);
}
-void CLMemsetKernel::configure(const CLCompileContext &compile_context, ICLTensor *tensor,
- const PixelValue &constant_value,
- Window *window)
+void ClFillKernel::configure(const CLCompileContext &compile_context, ITensorInfo *tensor,
+ const PixelValue &constant_value,
+ Window *window)
{
ARM_COMPUTE_ERROR_ON_NULLPTR(tensor);
- ARM_COMPUTE_ERROR_THROW_ON(validate(tensor->info(), constant_value, window));
-
- _tensor = tensor;
+ ARM_COMPUTE_ERROR_THROW_ON(validate(tensor, constant_value, window));
- const DataType data_type = tensor->info()->data_type();
- const int vec_size_x = 16 / tensor->info()->element_size();
+ const DataType data_type = tensor->data_type();
+ const int vec_size_x = 16 / tensor->element_size();
// Create and update the window (if needed)
- _full_window = calculate_max_window(*tensor->info());
+ _full_window = calculate_max_window(*tensor);
Window win = _full_window;
if(window != nullptr)
{
@@ -81,7 +87,7 @@ void CLMemsetKernel::configure(const CLCompileContext &compile_context, ICLTenso
_kernel = create_kernel(compile_context, "memset", build_opts.options());
}
-Status CLMemsetKernel::validate(const ITensorInfo *tensor, const PixelValue &constant_value, Window *window)
+Status ClFillKernel::validate(const ITensorInfo *tensor, const PixelValue &constant_value, Window *window)
{
ARM_COMPUTE_UNUSED(tensor);
ARM_COMPUTE_UNUSED(constant_value);
@@ -92,11 +98,13 @@ Status CLMemsetKernel::validate(const ITensorInfo *tensor, const PixelValue &con
return Status{};
}
-void CLMemsetKernel::run(const Window &window, cl::CommandQueue &queue)
+void ClFillKernel::run_op(ITensorPack &tensors, const Window &window, cl::CommandQueue &queue)
{
ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(this);
ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(ICLKernel::window(), window);
+ const auto tensor = utils::cast::polymorphic_downcast<const ICLTensor *>(tensors.get_const_tensor(TensorType::ACL_SRC));
+
// Collapse all the batches on the third
Window collapsed = window.collapse_if_possible(_full_window, Window::DimZ);
Window slice = collapsed.first_slice_window_3D();
@@ -104,9 +112,11 @@ void CLMemsetKernel::run(const Window &window, cl::CommandQueue &queue)
do
{
unsigned int idx = 0;
- add_3D_tensor_argument(idx, _tensor, slice);
+ add_3D_tensor_argument(idx, tensor, slice);
enqueue(queue, *this, slice, lws_hint());
}
while(collapsed.slide_window_slice_3D(slice));
}
+} // namespace kernels
+} // namespace opencl
} // namespace arm_compute
diff --git a/src/core/CL/kernels/CLMemsetKernel.h b/src/core/gpu/cl/kernels/ClFillKernel.h
index dc103f580f..136c1243fe 100644
--- a/src/core/CL/kernels/CLMemsetKernel.h
+++ b/src/core/gpu/cl/kernels/ClFillKernel.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018-2020 Arm Limited.
+ * Copyright (c) 2018-2021 Arm Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -21,50 +21,41 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
-#ifndef ARM_COMPUTE_CLMEMSETKERNEL_H
-#define ARM_COMPUTE_CLMEMSETKERNEL_H
+#ifndef ARM_COMPUTE_CL_FILL_KERNEL_H
+#define ARM_COMPUTE_CL_FILL_KERNEL_H
-#include "arm_compute/core/PixelValue.h"
-#include "arm_compute/core/Types.h"
-#include "src/core/CL/ICLKernel.h"
+#include "src/core/common/Macros.h"
+#include "src/core/gpu/cl/ClCompileContext.h"
+#include "src/core/gpu/cl/IClKernel.h"
namespace arm_compute
{
-class ICLTensor;
-
+namespace opencl
+{
+namespace kernels
+{
/** Interface for filling the planes of a tensor */
-class CLMemsetKernel : public ICLKernel
+class ClFillKernel : public ICLKernel
{
public:
- /** Default constructor */
- CLMemsetKernel();
- /** Prevent instances of this class from being copied (As this class contains pointers) */
- CLMemsetKernel(const CLMemsetKernel &) = delete;
- /** Prevent instances of this class from being copied (As this class contains pointers) */
- CLMemsetKernel &operator=(const CLMemsetKernel &) = delete;
- /** Allow instances of this class to be moved */
- CLMemsetKernel(CLMemsetKernel &&) = default;
- /** Allow instances of this class to be moved */
- CLMemsetKernel &operator=(CLMemsetKernel &&) = default;
- /** Default destructor */
- ~CLMemsetKernel() = default;
-
+ ClFillKernel() = default;
+ ARM_COMPUTE_DISALLOW_COPY_ALLOW_MOVE(ClFillKernel);
/** Initialise the kernel's tensor and filling value
*
- * @param[in,out] tensor Input tensor to fill. Supported data types: All.
+ * @param[in,out] tensor Input tensor info. Supported data types: All.
* @param[in] constant_value The value used to fill the planes of the tensor
* @param[in] window Window to be used in case setting only part of a tensor. Default is nullptr.
*/
- void configure(ICLTensor *tensor, const PixelValue &constant_value, Window *window = nullptr);
+ void configure(ITensorInfo *tensor, const PixelValue &constant_value, Window *window = nullptr);
/** Initialise the kernel's tensor and filling value
*
* @param[in] compile_context The compile context to be used.
- * @param[in,out] tensor Input tensor to fill. Supported data types: All.
+ * @param[in,out] tensor Input tensor info. Supported data types: All.
* @param[in] constant_value The value used to fill the planes of the tensor
* @param[in] window Window to be used in case setting only part of a tensor. Default is nullptr.
*/
- void configure(const CLCompileContext &compile_context, ICLTensor *tensor, const PixelValue &constant_value, Window *window = nullptr);
- /** Static function to check if given info will lead to a valid configuration of @ref CLMemsetKernel
+ void configure(const CLCompileContext &compile_context, ITensorInfo *tensor, const PixelValue &constant_value, Window *window = nullptr);
+ /** Static function to check if given info will lead to a valid configuration of @ref ClFillKernel
*
* @param[in] tensor Source tensor info. Data types supported: All.
* @param[in] constant_value The value used to fill the planes of the tensor
@@ -75,11 +66,12 @@ public:
static Status validate(const ITensorInfo *tensor, const PixelValue &constant_value, Window *window = nullptr);
// Inherited methods overridden:
- void run(const Window &window, cl::CommandQueue &queue) override;
+ void run_op(ITensorPack &tensors, const Window &window, cl::CommandQueue &queue) override;
private:
- ICLTensor *_tensor;
- Window _full_window;
+ Window _full_window{};
};
+} // namespace kernels
+} // namespace opencl
} // namespace arm_compute
#endif /*ARM_COMPUTE_CLMEMSETRKERNEL_H */
diff --git a/src/core/CL/kernels/CLPermuteKernel.cpp b/src/core/gpu/cl/kernels/ClPermuteKernel.cpp
index 07d83bddc2..992c2a89d3 100644
--- a/src/core/CL/kernels/CLPermuteKernel.cpp
+++ b/src/core/gpu/cl/kernels/ClPermuteKernel.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018-2020 Arm Limited.
+ * Copyright (c) 2018-2021 Arm Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -21,34 +21,43 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
-#include "src/core/CL/kernels/CLPermuteKernel.h"
+#include "src/core/gpu/cl/kernels/ClPermuteKernel.h"
+
+#include "arm_compute/core/CL/CLHelpers.h"
+#include "arm_compute/core/CL/CLKernelLibrary.h"
#include "arm_compute/core/CL/ICLTensor.h"
+#include "arm_compute/core/Helpers.h"
+#include "arm_compute/core/TensorInfo.h"
+#include "arm_compute/core/Utils.h"
+#include "arm_compute/core/Validate.h"
#include "arm_compute/core/utils/misc/ShapeCalculator.h"
+#include "src/core/CL/CLValidate.h"
#include "src/core/helpers/AutoConfiguration.h"
#include "src/core/helpers/WindowHelpers.h"
+#include "support/Cast.h"
#include "support/StringSupport.h"
namespace arm_compute
{
-CLPermuteKernel::CLPermuteKernel()
- : _input(nullptr), _output(nullptr), _perm()
+namespace opencl
+{
+namespace kernels
{
-}
namespace
{
-TensorShape get_output_shape(const ITensorInfo *input, const PermutationVector &perm)
+TensorShape get_dst_shape(const ITensorInfo *src, const PermutationVector &perm)
{
- TensorShape output_shape = input->tensor_shape();
- permute(output_shape, perm);
- return output_shape;
+ TensorShape dst_shape = src->tensor_shape();
+ permute(dst_shape, perm);
+ return dst_shape;
}
-Status validate_arguments(const ITensorInfo *input, const ITensorInfo *output, const PermutationVector &perm)
+Status validate_arguments(const ITensorInfo *src, const ITensorInfo *dst, const PermutationVector &perm)
{
- ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(input, output);
- ARM_COMPUTE_RETURN_ERROR_ON(input->data_type() == DataType::UNKNOWN);
- ARM_COMPUTE_RETURN_ERROR_ON_MSG(input->num_dimensions() < 1 || input->num_dimensions() > 4,
- "Permutation upto 4-D input tensor is supported");
+ ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(src, dst);
+ ARM_COMPUTE_RETURN_ERROR_ON(src->data_type() == DataType::UNKNOWN);
+ ARM_COMPUTE_RETURN_ERROR_ON_MSG(src->num_dimensions() < 1 || src->num_dimensions() > 4,
+ "Permutation upto 4-D src tensor is supported");
ARM_COMPUTE_RETURN_ERROR_ON_MSG(perm.num_dimensions() < 1 || perm.num_dimensions() > 4,
"Permutation vector size should be less than or equal to 4");
for(const auto &p : perm)
@@ -56,41 +65,39 @@ Status validate_arguments(const ITensorInfo *input, const ITensorInfo *output, c
ARM_COMPUTE_RETURN_ERROR_ON_MSG(p >= perm.num_dimensions(), "Permutation vector has invalid values");
}
- // Validate configured output
- if(output->total_size() != 0)
+ // Validate configured dst
+ if(dst->total_size() != 0)
{
- const TensorShape output_shape = misc::shape_calculator::compute_permutation_output_shape(*input, perm);
- ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DIMENSIONS(output->tensor_shape(), output_shape);
- ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_QUANTIZATION_INFO(input, output);
- ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(input, output);
+ const TensorShape dst_shape = misc::shape_calculator::compute_permutation_output_shape(*src, perm);
+ ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DIMENSIONS(dst->tensor_shape(), dst_shape);
+ ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_QUANTIZATION_INFO(src, dst);
+ ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(src, dst);
}
return Status{};
}
} // namespace
-void CLPermuteKernel::configure(const ICLTensor *input, ICLTensor *output, const PermutationVector &perm)
+void ClPermuteKernel::configure(const ITensorInfo *src, ITensorInfo *dst, const PermutationVector &perm)
{
- configure(CLKernelLibrary::get().get_compile_context(), input, output, perm);
+ configure(CLKernelLibrary::get().get_compile_context(), src, dst, perm);
}
-void CLPermuteKernel::configure(const CLCompileContext &compile_context, const ICLTensor *input, ICLTensor *output, const PermutationVector &perm)
+void ClPermuteKernel::configure(const CLCompileContext &compile_context, const ITensorInfo *src, ITensorInfo *dst, const PermutationVector &perm)
{
- ARM_COMPUTE_ERROR_ON_NULLPTR(input, output);
- auto padding_info = get_padding_info({ input, output });
- const TensorShape output_shape = get_output_shape(input->info(), perm);
+ ARM_COMPUTE_ERROR_ON_NULLPTR(src, dst);
+ auto padding_info = get_padding_info({ src, dst });
+ const TensorShape dst_shape = get_dst_shape(src, perm);
// Output auto inizialitation if not yet initialized
- auto_init_if_empty(*output->info(), input->info()->clone()->set_tensor_shape(output_shape));
+ auto_init_if_empty(*dst, src->clone()->set_tensor_shape(dst_shape));
- ARM_COMPUTE_ERROR_THROW_ON(validate_arguments(input->info(), output->info(), perm));
+ ARM_COMPUTE_ERROR_THROW_ON(validate_arguments(src, dst, perm));
- _input = input;
- _output = output;
- _perm = perm;
+ _perm = perm;
// Create kernel
CLBuildOptions build_opts;
- build_opts.add_option("-DDATA_TYPE=" + get_cl_unsigned_type_from_element_size(data_size_from_type(input->info()->data_type())));
- build_opts.add_option("-DDEPTH_IN=" + support::cpp11::to_string(input->info()->dimension(2)));
+ build_opts.add_option("-DDATA_TYPE=" + get_cl_unsigned_type_from_element_size(data_size_from_type(src->data_type())));
+ build_opts.add_option("-DDEPTH_IN=" + support::cpp11::to_string(src->dimension(2)));
// New positions of width(W), height(H), channel(C) and batch(D) based on permutation vector
build_opts.add_option("-DP1=" + support::cpp11::to_string((_perm.num_dimensions() >= 1) ? perm[0] : 0));
build_opts.add_option("-DP2=" + support::cpp11::to_string((_perm.num_dimensions() >= 2) ? perm[1] : 1));
@@ -100,33 +107,36 @@ void CLPermuteKernel::configure(const CLCompileContext &compile_context, const I
_kernel = create_kernel(compile_context, "permute", build_opts.options());
// Configure kernel window
- Window win = calculate_max_window(*input->info(), Steps());
+ Window win = calculate_max_window(*src, Steps());
// The CLPermute doesn't need padding so update_window_and_padding() can be skipped
Coordinates coord;
- coord.set_num_dimensions(output->info()->num_dimensions());
- output->info()->set_valid_region(ValidRegion(coord, output->info()->tensor_shape()));
+ coord.set_num_dimensions(dst->num_dimensions());
+ dst->set_valid_region(ValidRegion(coord, dst->tensor_shape()));
ICLKernel::configure_internal(win);
ARM_COMPUTE_ERROR_ON(has_padding_changed(padding_info));
}
-Status CLPermuteKernel::validate(const ITensorInfo *input, const ITensorInfo *output, const PermutationVector &perm)
+Status ClPermuteKernel::validate(const ITensorInfo *src, const ITensorInfo *dst, const PermutationVector &perm)
{
- ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(input, output);
- ARM_COMPUTE_RETURN_ON_ERROR(validate_arguments(input, output, perm));
+ ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(src, dst);
+ ARM_COMPUTE_RETURN_ON_ERROR(validate_arguments(src, dst, perm));
return Status{};
}
-void CLPermuteKernel::run(const Window &window, cl::CommandQueue &queue)
+void ClPermuteKernel::run_op(ITensorPack &tensors, const Window &window, cl::CommandQueue &queue)
{
ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(this);
ARM_COMPUTE_ERROR_ON_MISMATCHING_WINDOWS(ICLKernel::window(), window);
+ const auto src = utils::cast::polymorphic_downcast<const ICLTensor *>(tensors.get_const_tensor(TensorType::ACL_SRC));
+ auto dst = utils::cast::polymorphic_downcast<ICLTensor *>(tensors.get_tensor(TensorType::ACL_DST));
+
Window slice_in = window.first_slice_window_4D().collapse(ICLKernel::window(), 2, 4);
- // Setup output slice
+ // Setup dst slice
Window slice_out(slice_in);
slice_out.set(Window::DimX, Window::Dimension(0, 0, 0));
slice_out.set(Window::DimY, Window::Dimension(0, 0, 0));
@@ -136,10 +146,12 @@ void CLPermuteKernel::run(const Window &window, cl::CommandQueue &queue)
do
{
unsigned int idx = 0;
- add_4D_tensor_argument(idx, _input, slice_in);
- add_4D_tensor_argument(idx, _output, slice_out);
+ add_4D_tensor_argument(idx, src, slice_in);
+ add_4D_tensor_argument(idx, dst, slice_out);
enqueue(queue, *this, slice_in, lws_hint());
}
while(window.slide_window_slice_4D(slice_in) && window.slide_window_slice_4D(slice_out));
}
+} // namespace kernels
+} // namespace opencl
} // namespace arm_compute \ No newline at end of file
diff --git a/src/core/gpu/cl/kernels/ClPermuteKernel.h b/src/core/gpu/cl/kernels/ClPermuteKernel.h
new file mode 100644
index 0000000000..4cc72491bd
--- /dev/null
+++ b/src/core/gpu/cl/kernels/ClPermuteKernel.h
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 2018-2021 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_CL_PERMUTE_KERNEL_H
+#define ARM_COMPUTE_CL_PERMUTE_KERNEL_H
+
+#include "src/core/common/Macros.h"
+#include "src/core/gpu/cl/ClCompileContext.h"
+#include "src/core/gpu/cl/IClKernel.h"
+
+namespace arm_compute
+{
+namespace opencl
+{
+namespace kernels
+{
+/** OpenCL kernel to perform tensor permutation.
+ *
+ * Permutes given a permutation vector
+ */
+class ClPermuteKernel : public ICLKernel
+{
+public:
+ ClPermuteKernel() = default;
+ ARM_COMPUTE_DISALLOW_COPY_ALLOW_MOVE(ClPermuteKernel);
+ /** Set the src and dst of the kernel.
+ *
+ * @note Arbitrary permutation vectors are supported with rank not greater than 4
+ *
+ * @param[in] src The src tensor info. Data types supported: All.
+ * @param[in] dst The dst tensor info. Data types supported: Same as @p src
+ * @param[in] perm Permutation vector
+ */
+ void configure(const ITensorInfo *src, ITensorInfo *dst, const PermutationVector &perm);
+ /** Set the src and dst of the kernel.
+ *
+ * @note Arbitrary permutation vectors are supported with rank not greater than 4
+ *
+ * @param[in] compile_context The compile context to be used.
+ * @param[in] src The src tensor info. Data types supported: All.
+ * @param[in] dst The dst tensor info. Data types supported: Same as @p src
+ * @param[in] perm Permutation vector
+ */
+ void configure(const CLCompileContext &compile_context, const ITensorInfo *src, ITensorInfo *dst, const PermutationVector &perm);
+ /** Static function to check if given info will lead to a valid configuration of @ref ClPermuteKernel
+ *
+ * @note Arbitrary permutation vectors are supported with rank not greater than 4
+ *
+ * @param[in] src The src tensor info. Data types supported: All.
+ * @param[in] dst The dst tensor info. Data types supported: same as @p src.
+ * @param[in] perm Permutation vector
+ *
+ * @return a status
+ */
+ static Status validate(const ITensorInfo *src, const ITensorInfo *dst, const PermutationVector &perm);
+
+ // Inherited methods overridden:
+ void run_op(ITensorPack &tensors, const Window &window, cl::CommandQueue &queue) override;
+
+private:
+ PermutationVector _perm{};
+};
+} // namespace kernels
+} // namespace opencl
+} // namespace arm_compute
+#endif /*ARM_COMPUTE_CL_PERMUTE_KERNEL_H */
diff --git a/src/core/CL/kernels/CLReshapeLayerKernel.cpp b/src/core/gpu/cl/kernels/ClReshapeKernel.cpp
index 58d7843624..4da3fa0e03 100644
--- a/src/core/CL/kernels/CLReshapeLayerKernel.cpp
+++ b/src/core/gpu/cl/kernels/ClReshapeKernel.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017-2020 Arm Limited.
+ * Copyright (c) 2017-2021 Arm Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -21,7 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
-#include "src/core/CL/kernels/CLReshapeLayerKernel.h"
+#include "src/core/gpu/cl/kernels/ClReshapeKernel.h"
#include "arm_compute/core/CL/CLHelpers.h"
#include "arm_compute/core/CL/CLKernelLibrary.h"
@@ -38,73 +38,77 @@
#include <string>
-/** [CLReshapeLayerKernel Kernel] **/
+/** [ClReshapeKernel Kernel] **/
namespace arm_compute
{
+namespace opencl
+{
+namespace kernels
+{
namespace
{
-Status validate_arguments(const ITensorInfo *input, const ITensorInfo *output)
+Status validate_arguments(const ITensorInfo *src, const ITensorInfo *dst)
{
- ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(input, output);
- ARM_COMPUTE_RETURN_ERROR_ON_F16_UNSUPPORTED(input);
- ARM_COMPUTE_RETURN_ERROR_ON(input->data_type() == DataType::UNKNOWN);
+ ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(src, dst);
+ ARM_COMPUTE_RETURN_ERROR_ON_F16_UNSUPPORTED(src);
+ ARM_COMPUTE_RETURN_ERROR_ON(src->data_type() == DataType::UNKNOWN);
- ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(input, output);
- ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_QUANTIZATION_INFO(input, output);
- ARM_COMPUTE_RETURN_ERROR_ON(input->tensor_shape().total_size() != output->tensor_shape().total_size());
+ ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(src, dst);
+ ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_QUANTIZATION_INFO(src, dst);
+ ARM_COMPUTE_RETURN_ERROR_ON(src->tensor_shape().total_size() != dst->tensor_shape().total_size());
return Status{};
}
} // namespace
-void CLReshapeLayerKernel::configure(const CLCompileContext &compile_context, const ITensorInfo *input, ITensorInfo *output)
+void ClReshapeKernel::configure(const CLCompileContext &compile_context, const ITensorInfo *src, ITensorInfo *dst)
{
- ARM_COMPUTE_ERROR_ON_NULLPTR(input, output);
- ARM_COMPUTE_ERROR_THROW_ON(validate_arguments(input, output));
+ ARM_COMPUTE_ERROR_ON_NULLPTR(src, dst);
+ ARM_COMPUTE_ERROR_THROW_ON(validate_arguments(src, dst));
- auto padding_info = get_padding_info({ input, output });
+ auto padding_info = get_padding_info({ src, dst });
// Create kernel
- std::set<std::string> build_opts = { "-DDATA_TYPE=" + get_cl_unsigned_type_from_element_size(input->element_size()) };
+ std::set<std::string> build_opts = { "-DDATA_TYPE=" + get_cl_unsigned_type_from_element_size(src->element_size()) };
_kernel = create_kernel(compile_context, "reshape_layer", build_opts);
// Add static arguments
- const cl_int2 input_shape =
+ const cl_int2 src_shape =
{
{
- static_cast<cl_int>(input->tensor_shape()[0]),
- static_cast<cl_int>(input->tensor_shape()[1])
+ static_cast<cl_int>(src->tensor_shape()[0]),
+ static_cast<cl_int>(src->tensor_shape()[1])
}
};
- const cl_int2 output_shape =
+ const cl_int2 dst_shape =
{
{
- static_cast<cl_int>(output->tensor_shape()[0]),
- static_cast<cl_int>(output->tensor_shape()[1])
+ static_cast<cl_int>(dst->tensor_shape()[0]),
+ static_cast<cl_int>(dst->tensor_shape()[1])
}
};
- unsigned int idx = 2 * num_arguments_per_3D_tensor(); // Skip the input and output parameters
- _kernel.setArg<cl_int2>(idx++, input_shape);
- _kernel.setArg<cl_int2>(idx++, output_shape);
+ unsigned int idx = 2 * num_arguments_per_3D_tensor(); // Skip the src and dst parameters
+ _kernel.setArg<cl_int2>(idx++, src_shape);
+ _kernel.setArg<cl_int2>(idx++, dst_shape);
// Configure kernel window
- Window win = calculate_max_window(*input);
+ Window win = calculate_max_window(*src);
- // Set the output valid region
- output->set_valid_region(ValidRegion(Coordinates(), output->tensor_shape()));
+ // Set the dst valid region
+ dst->set_valid_region(ValidRegion(Coordinates(), dst->tensor_shape()));
ICLKernel::configure_internal(win);
ARM_COMPUTE_ERROR_ON(has_padding_changed(padding_info));
}
-Status CLReshapeLayerKernel::validate(const ITensorInfo *input, const ITensorInfo *output)
+Status ClReshapeKernel::validate(const ITensorInfo *src, const ITensorInfo *dst)
{
- ARM_COMPUTE_RETURN_ON_ERROR(validate_arguments(input, output));
+ ARM_COMPUTE_RETURN_ON_ERROR(validate_arguments(src, dst));
return Status{};
}
-void CLReshapeLayerKernel::run_op(ITensorPack &tensors, const Window &window, cl::CommandQueue &queue)
+void ClReshapeKernel::run_op(ITensorPack &tensors, const Window &window, cl::CommandQueue &queue)
{
ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(this);
ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(IKernel::window(), window);
@@ -115,11 +119,13 @@ void CLReshapeLayerKernel::run_op(ITensorPack &tensors, const Window &window, cl
const auto src = utils::cast::polymorphic_downcast<const ICLTensor *>(tensors.get_const_tensor(TensorType::ACL_SRC));
auto dst = utils::cast::polymorphic_downcast<ICLTensor *>(tensors.get_tensor(TensorType::ACL_DST));
- // Set inputs
+ // Set srcs
unsigned int idx = 0;
add_3D_tensor_argument(idx, src, window_collapsed);
add_3D_tensor_argument(idx, dst, window_collapsed);
enqueue(queue, *this, slice, lws_hint());
}
+} // namespace kernels
+} // namespace opencl
} // namespace arm_compute
-/** [CLReshapeLayerKernel Kernel] **/
+/** [ClReshapeKernel Kernel] **/
diff --git a/src/core/gpu/cl/kernels/ClReshapeKernel.h b/src/core/gpu/cl/kernels/ClReshapeKernel.h
new file mode 100644
index 0000000000..ee835c0fd3
--- /dev/null
+++ b/src/core/gpu/cl/kernels/ClReshapeKernel.h
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2017-2021 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_CL_RESHAPE_KERNEL_H
+#define ARM_COMPUTE_CL_RESHAPE_KERNEL_H
+
+#include "src/core/common/Macros.h"
+#include "src/core/gpu/cl/ClCompileContext.h"
+#include "src/core/gpu/cl/IClKernel.h"
+
+namespace arm_compute
+{
+namespace opencl
+{
+namespace kernels
+{
+/** Interface for the kernel to perform tensor reshaping */
+class ClReshapeKernel : public ICLKernel
+{
+public:
+ ClReshapeKernel() = default;
+ ARM_COMPUTE_DISALLOW_COPY_ALLOW_MOVE(ClReshapeKernel);
+ /** Set the src and dst of the kernel
+ *
+ * @param[in] compile_context The compile context to be used.
+ * @param[in] src Source tensor info. Data type supported: All.
+ * @param[out] dst Destination tensor info. Data type supported: Same as @p src
+ */
+ void configure(const CLCompileContext &compile_context, const ITensorInfo *src, ITensorInfo *dst);
+
+ /** Static function to check if given info will lead to a valid configuration of @ref ClReshapeKernel
+ *
+ * @param[in] src Source tensor info. Data type supported: All
+ * @param[in] dst Destination tensor info. Data type supported: Same as @p src
+ *
+ * @return a status
+ */
+ static Status validate(const ITensorInfo *src, const ITensorInfo *dst);
+
+ // Inherited methods overridden:
+ void run_op(ITensorPack &tensors, const Window &window, cl::CommandQueue &queue) override;
+};
+} // namespace opencl
+} // namespace kernels
+} // namespace arm_compute
+#endif /*ARM_COMPUTE_CL_RESHAPE_KERNEL_H */
diff --git a/src/runtime/CL/functions/CLCopy.cpp b/src/runtime/CL/functions/CLCopy.cpp
index c3e30ada6e..98916bf38a 100644
--- a/src/runtime/CL/functions/CLCopy.cpp
+++ b/src/runtime/CL/functions/CLCopy.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018-2020 Arm Limited.
+ * Copyright (c) 2018-2021 Arm Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -23,30 +23,58 @@
*/
#include "arm_compute/runtime/CL/functions/CLCopy.h"
+#include "arm_compute/core/CL/CLKernelLibrary.h"
#include "arm_compute/core/CL/ICLTensor.h"
-#include "arm_compute/core/Error.h"
-#include "arm_compute/core/PixelValue.h"
-#include "arm_compute/core/TensorInfo.h"
+#include "arm_compute/core/Types.h"
#include "arm_compute/core/Validate.h"
-#include "src/core/CL/kernels/CLCopyKernel.h"
+#include "src/core/CL/ICLKernel.h"
+#include "src/runtime/gpu/cl/operators/ClCopy.h"
#include <utility>
-using namespace arm_compute;
+namespace arm_compute
+{
+struct CLCopy::Impl
+{
+ const ICLTensor *src{ nullptr };
+ ICLTensor *dst{ nullptr };
+ std::unique_ptr<opencl::ClCopy> op{ nullptr };
+};
+
+CLCopy::CLCopy()
+ : _impl(std::make_unique<Impl>())
+{
+}
+CLCopy::CLCopy(CLCopy &&) = default;
+CLCopy &CLCopy::operator=(CLCopy &&) = default;
+CLCopy::~CLCopy() = default;
-void CLCopy::configure(ICLTensor *input, ICLTensor *output)
+void CLCopy::configure(ICLTensor *input, ICLTensor *output, Window *dst_window)
{
- configure(CLKernelLibrary::get().get_compile_context(), input, output);
+ configure(CLKernelLibrary::get().get_compile_context(), input, output, dst_window);
+}
+
+void CLCopy::configure(const CLCompileContext &compile_context, ICLTensor *input, ICLTensor *output, Window *dst_window)
+{
+ ARM_COMPUTE_ERROR_ON_NULLPTR(input);
+
+ _impl->src = input;
+ _impl->dst = output;
+
+ _impl->op = std::make_unique<opencl::ClCopy>();
+ _impl->op->configure(compile_context, _impl->src->info(), _impl->dst->info(), dst_window);
}
-void CLCopy::configure(const CLCompileContext &compile_context, ICLTensor *input, ICLTensor *output)
+Status CLCopy::validate(const ITensorInfo *input, const ITensorInfo *output, Window *dst_window)
{
- auto k = std::make_unique<CLCopyKernel>();
- k->configure(compile_context, input, output);
- _kernel = std::move(k);
+ return opencl::ClCopy::validate(input, output, dst_window);
}
-Status CLCopy::validate(const arm_compute::ITensorInfo *input, const arm_compute::ITensorInfo *output)
+void CLCopy::run()
{
- return CLCopyKernel::validate(input, output);
+ ITensorPack pack;
+ pack.add_tensor(TensorType::ACL_SRC, _impl->src);
+ pack.add_tensor(TensorType::ACL_DST, _impl->dst);
+ _impl->op->run(pack);
}
+} // namespace arm_compute
diff --git a/src/runtime/CL/functions/CLCrop.cpp b/src/runtime/CL/functions/CLCrop.cpp
new file mode 100644
index 0000000000..20cab4df5f
--- /dev/null
+++ b/src/runtime/CL/functions/CLCrop.cpp
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2018-2021 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.
+ */
+#include "arm_compute/runtime/CL/functions/CLCrop.h"
+
+#include "arm_compute/core/CL/CLKernelLibrary.h"
+#include "arm_compute/core/CL/ICLTensor.h"
+#include "arm_compute/core/Types.h"
+#include "arm_compute/core/Validate.h"
+#include "src/core/CL/ICLKernel.h"
+#include "src/runtime/gpu/cl/operators/ClCrop.h"
+
+#include <utility>
+
+namespace arm_compute
+{
+struct CLCrop::Impl
+{
+ const ICLTensor *src{ nullptr };
+ ICLTensor *dst{ nullptr };
+ std::unique_ptr<opencl::ClCrop> op{ nullptr };
+};
+
+CLCrop::CLCrop()
+ : _impl(std::make_unique<Impl>())
+{
+}
+CLCrop::CLCrop(CLCrop &&) = default;
+CLCrop &CLCrop::operator=(CLCrop &&) = default;
+CLCrop::~CLCrop() = default;
+
+void CLCrop::configure(const ICLTensor *src, ICLTensor *dst, Coordinates2D start, Coordinates2D end, uint32_t batch_index, float extrapolation_value,
+ Window *dst_window)
+{
+ configure(CLKernelLibrary::get().get_compile_context(), src, dst, start, end, batch_index, extrapolation_value, dst_window);
+}
+
+void CLCrop::configure(const CLCompileContext &compile_context, const ICLTensor *src, ICLTensor *dst, Coordinates2D start, Coordinates2D end, uint32_t batch_index, float extrapolation_value,
+ Window *dst_window)
+{
+ ARM_COMPUTE_ERROR_ON_NULLPTR(src, dst);
+
+ _impl->src = src;
+ _impl->dst = dst;
+
+ _impl->op = std::make_unique<opencl::ClCrop>();
+ _impl->op->configure(compile_context, _impl->src->info(), _impl->dst->info(), start, end, batch_index, extrapolation_value, dst_window);
+}
+
+Status CLCrop::validate(const ITensorInfo *input, const ITensorInfo *output, Coordinates2D start, Coordinates2D end, uint32_t batch_index, float extrapolation_value, Window *dst_window)
+{
+ return opencl::ClCrop::validate(input, output, start, end, batch_index, extrapolation_value, dst_window);
+}
+
+void CLCrop::run()
+{
+ ITensorPack pack;
+ pack.add_tensor(TensorType::ACL_SRC, _impl->src);
+ pack.add_tensor(TensorType::ACL_DST, _impl->dst);
+ _impl->op->run(pack);
+}
+} // namespace arm_compute
diff --git a/src/runtime/CL/functions/CLCropResize.cpp b/src/runtime/CL/functions/CLCropResize.cpp
index ed31446cf9..77c44d539b 100644
--- a/src/runtime/CL/functions/CLCropResize.cpp
+++ b/src/runtime/CL/functions/CLCropResize.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019-2020 Arm Limited.
+ * Copyright (c) 2019-2021 Arm Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -25,10 +25,7 @@
#include "arm_compute/core/CL/CLHelpers.h"
#include "arm_compute/runtime/CL/CLScheduler.h"
-#include "src/core/CL/kernels/CLCopyKernel.h"
-#include "src/core/CL/kernels/CLCropKernel.h"
#include "src/core/CL/kernels/CLFillBorderKernel.h"
-#include "src/core/CL/kernels/CLMemsetKernel.h"
#include "src/core/helpers/AutoConfiguration.h"
#include "src/core/helpers/WindowHelpers.h"
@@ -59,7 +56,7 @@ inline void configure_crop(const ICLTensor *input, ICLTensor *crop_boxes, ICLTen
} // namespace
CLCropResize::CLCropResize()
- : _input(nullptr), _boxes(nullptr), _box_ind(nullptr), _output(nullptr), _num_boxes(0), _method(), _extrapolation_value(0), _scale(), _copy(), _crop_results(), _scaled_results(), _internal_kernels()
+ : _input(nullptr), _boxes(nullptr), _box_ind(nullptr), _output(nullptr), _num_boxes(0), _method(), _extrapolation_value(0), _scale(), _copy(), _crop_results(), _scaled_results(), _internal_functions()
{
}
@@ -73,7 +70,7 @@ Status CLCropResize::validate(const ITensorInfo *input, ITensorInfo *boxes, ITen
ARM_COMPUTE_RETURN_ERROR_ON(boxes->tensor_shape()[0] != 4);
ARM_COMPUTE_RETURN_ERROR_ON(boxes->tensor_shape()[1] != box_ind->tensor_shape()[0]);
TensorInfo temp_info;
- ARM_COMPUTE_RETURN_ON_ERROR(CLCropKernel::validate(input->clone().get(), &temp_info, { 0, 0 }, { 1, 1 }, input->dimension(3) - 1, extrapolation_value));
+ ARM_COMPUTE_RETURN_ON_ERROR(CLCrop::validate(input->clone().get(), &temp_info, { 0, 0 }, { 1, 1 }, input->dimension(3) - 1, extrapolation_value));
if(output->total_size() > 0)
{
ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_NOT_IN(output, DataType::F32);
@@ -111,11 +108,11 @@ void CLCropResize::configure(const CLCompileContext &compile_context, const ICLT
// For each crop box:
// - The initial cropped image is produced as specified by boxes[i] from the 3D image input[box_ind[i]].
- // Possibly using a CLCropKernel and up to four CLMemsetKernels.
+ // Possibly using a CLCrop and up to four CLFills.
// - A tensor is required to hold this initial cropped image.
// - A scale function is used to resize the cropped image to the size specified by crop_size.
// - A tensor is required to hold the final scaled image before it is copied into the 4D output
- // that will hold all final cropped and scaled 3D images using CLCopyKernel.
+ // that will hold all final cropped and scaled 3D images using CLCopy.
// The contents of _boxes and _box_ind are required to calculate the shape
// of the initial cropped image and thus are required to configure the
@@ -149,7 +146,7 @@ void CLCropResize::configure(const CLCompileContext &compile_context, const ICLT
Window win = calculate_max_window(*_output->info());
win.set(3, Window::Dimension(num_box, num_box + 1, 1));
- auto copy_kernel = std::make_unique<CLCopyKernel>();
+ auto copy_kernel = std::make_unique<CLCopy>();
copy_kernel->configure(compile_context, _scaled_results[num_box].get(), _output, &win);
_copy.emplace_back(std::move(copy_kernel));
@@ -207,9 +204,10 @@ void CLCropResize::configure(const CLCompileContext &compile_context, const ICLT
{
Window slice_fill_rows_before(full_window);
slice_fill_rows_before.set(2, Window::Dimension(0, rows_out_of_bounds[0], 1));
- auto kernel = std::make_unique<CLMemsetKernel>();
+ auto kernel = std::make_unique<CLFill>();
kernel->configure(compile_context, _crop_results[num_box].get(), extrapolation_value, &slice_fill_rows_before);
- _internal_kernels.push_back(std::move(kernel));
+ //_internal_functions.emplace_back(std::move(kernel));
+ _internal_functions.push_back(std::move(kernel));
}
Window slice_in(full_window);
@@ -224,18 +222,20 @@ void CLCropResize::configure(const CLCompileContext &compile_context, const ICLT
{
Window slice_fill_cols_before(slice_in);
slice_fill_cols_before.set(1, Window::Dimension(0, cols_out_of_bounds[0], 1));
- auto kernel = std::make_unique<CLMemsetKernel>();
+ auto kernel = std::make_unique<CLFill>();
kernel->configure(compile_context, _crop_results[num_box].get(), extrapolation_value, &slice_fill_cols_before);
- _internal_kernels.push_back(std::move(kernel));
+ //_internal_functions.emplace_back(std::move(kernel));
+ _internal_functions.push_back(std::move(kernel));
}
if(cols_out_of_bounds[1] > 0)
{
Window slice_fill_cols_after(slice_in);
slice_fill_cols_after.set(1, Window::Dimension(_crop_results[num_box].get()->info()->dimension(1) - cols_out_of_bounds[1], _crop_results[num_box].get()->info()->dimension(1), 1));
- auto kernel = std::make_unique<CLMemsetKernel>();
+ auto kernel = std::make_unique<CLFill>();
kernel->configure(compile_context, _crop_results[num_box].get(), extrapolation_value, &slice_fill_cols_after);
- _internal_kernels.push_back(std::move(kernel));
+ //_internal_functions.emplace_back(std::move(kernel));
+ _internal_functions.push_back(std::move(kernel));
}
// Copy all elements within the input bounds from the input tensor.
@@ -246,10 +246,11 @@ void CLCropResize::configure(const CLCompileContext &compile_context, const ICLT
is_height_flipped ? start[1] - rows_out_of_bounds[0] : start[1] + rows_out_of_bounds[0] };
Coordinates2D end_in{ is_width_flipped ? start_in.x - cols_in_bounds + 1 : start_in.x + cols_in_bounds - 1,
is_height_flipped ? start_in.y - rows_in_bounds + 1 : start_in.y + rows_in_bounds - 1 };
- auto kernel = std::make_unique<CLCropKernel>();
+ auto kernel = std::make_unique<CLCrop>();
kernel->configure(compile_context, _input, _crop_results[num_box].get(), start_in, end_in, batch_index, extrapolation_value, &slice_in);
- _internal_kernels.push_back(std::move(kernel));
+ //_internal_functions.emplace_back(std::move(kernel));
+ _internal_functions.push_back(std::move(kernel));
}
}
@@ -258,9 +259,10 @@ void CLCropResize::configure(const CLCompileContext &compile_context, const ICLT
{
Window slice_fill_rows_after(full_window);
slice_fill_rows_after.set(2, Window::Dimension(_crop_results[num_box].get()->info()->dimension(2) - rows_out_of_bounds[1], _crop_results[num_box].get()->info()->dimension(2), 1));
- auto kernel = std::make_unique<CLMemsetKernel>();
+ auto kernel = std::make_unique<CLFill>();
kernel->configure(compile_context, _crop_results[num_box].get(), extrapolation_value, &slice_fill_rows_after);
- _internal_kernels.push_back(std::move(kernel));
+ //_internal_functions.emplace_back(std::move(kernel));
+ _internal_functions.push_back(std::move(kernel));
}
}
_boxes->unmap(CLScheduler::get().queue());
@@ -272,9 +274,9 @@ void CLCropResize::run()
{
ARM_COMPUTE_ERROR_ON_MSG(_output == nullptr, "Unconfigured function");
- for(unsigned int i = 0; i < _internal_kernels.size(); ++i)
+ for(unsigned int i = 0; i < _internal_functions.size(); ++i)
{
- CLScheduler::get().enqueue(*(_internal_kernels[i]));
+ _internal_functions[i]->run();
}
CLScheduler::get().sync();
@@ -285,7 +287,7 @@ void CLCropResize::run()
CLScheduler::get().sync();
for(auto &kernel : _copy)
{
- CLScheduler::get().enqueue(*kernel, true);
+ kernel->run();
}
CLScheduler::get().sync();
}
diff --git a/src/runtime/CL/functions/CLDeconvolutionLayerUpsample.cpp b/src/runtime/CL/functions/CLDeconvolutionLayerUpsample.cpp
index 4989f6460d..c371558f30 100644
--- a/src/runtime/CL/functions/CLDeconvolutionLayerUpsample.cpp
+++ b/src/runtime/CL/functions/CLDeconvolutionLayerUpsample.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017-2020 Arm Limited.
+ * Copyright (c) 2017-2021 Arm Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -28,13 +28,12 @@
#include "arm_compute/runtime/CL/CLScheduler.h"
#include "arm_compute/runtime/CL/CLTensor.h"
#include "src/core/CL/kernels/CLDeconvolutionLayerUpsampleKernel.h"
-#include "src/core/CL/kernels/CLMemsetKernel.h"
namespace arm_compute
{
CLDeconvolutionLayerUpsample::CLDeconvolutionLayerUpsample() // NOLINT
: _upsample(std::make_unique<CLDeconvolutionLayerUpsampleKernel>()),
- _memset(std::make_unique<CLMemsetKernel>()),
+ _fill(),
_output(nullptr)
{
}
@@ -56,13 +55,13 @@ void CLDeconvolutionLayerUpsample::configure(const CLCompileContext &compile_con
ARM_COMPUTE_ERROR_ON_NULLPTR(input, output);
_output = output;
- _memset->configure(compile_context, _output, PixelValue(0, _output->info()->data_type(), _output->info()->quantization_info()));
+ _fill.configure(compile_context, _output, PixelValue(0, _output->info()->data_type(), _output->info()->quantization_info()));
_upsample->configure(compile_context, input, _output, info);
}
void CLDeconvolutionLayerUpsample::run()
{
- CLScheduler::get().enqueue(*_memset, false);
+ _fill.run();
CLScheduler::get().enqueue(*_upsample, true);
}
} // namespace arm_compute
diff --git a/src/runtime/CL/functions/CLDirectDeconvolutionLayer.cpp b/src/runtime/CL/functions/CLDirectDeconvolutionLayer.cpp
index 0e3109439e..d802ef2dc9 100644
--- a/src/runtime/CL/functions/CLDirectDeconvolutionLayer.cpp
+++ b/src/runtime/CL/functions/CLDirectDeconvolutionLayer.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019-2020 Arm Limited.
+ * Copyright (c) 2019-2021 Arm Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -32,7 +32,6 @@
#include "src/core/CL/kernels/CLDeconvolutionLayerUpsampleKernel.h"
#include "src/core/CL/kernels/CLFillBorderKernel.h"
#include "src/core/CL/kernels/CLGEMMReshapeRHSMatrixKernel.h"
-#include "src/core/CL/kernels/CLMemsetKernel.h"
#include "src/core/CL/kernels/CLWeightsReshapeKernel.h"
#include "src/core/helpers/AutoConfiguration.h"
diff --git a/src/runtime/CL/functions/CLFFTConvolutionLayer.cpp b/src/runtime/CL/functions/CLFFTConvolutionLayer.cpp
index 45e74df703..41b02d03f2 100644
--- a/src/runtime/CL/functions/CLFFTConvolutionLayer.cpp
+++ b/src/runtime/CL/functions/CLFFTConvolutionLayer.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019-2020 Arm Limited.
+ * Copyright (c) 2019-2021 Arm Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -29,7 +29,6 @@
#include "arm_compute/core/utils/misc/ShapeCalculator.h"
#include "arm_compute/runtime/CL/CLScheduler.h"
#include "arm_compute/runtime/CPP/CPPScheduler.h"
-#include "src/core/CL/kernels/CLCopyKernel.h"
#include "src/core/CL/kernels/CLFFTDigitReverseKernel.h"
#include "src/core/CL/kernels/CLFFTRadixStageKernel.h"
#include "src/core/CL/kernels/CLFFTScaleKernel.h"
diff --git a/src/runtime/CL/functions/CLFill.cpp b/src/runtime/CL/functions/CLFill.cpp
index 30843d8cc0..b22d79fea4 100644
--- a/src/runtime/CL/functions/CLFill.cpp
+++ b/src/runtime/CL/functions/CLFill.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019-2020 Arm Limited.
+ * Copyright (c) 2019-2021 Arm Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -23,22 +23,56 @@
*/
#include "arm_compute/runtime/CL/functions/CLFill.h"
+#include "arm_compute/core/CL/CLKernelLibrary.h"
+#include "arm_compute/core/CL/ICLTensor.h"
#include "arm_compute/core/Types.h"
-#include "src/core/CL/kernels/CLMemsetKernel.h"
+#include "arm_compute/core/Validate.h"
+#include "src/core/CL/ICLKernel.h"
+#include "src/runtime/gpu/cl/operators/ClFill.h"
#include <utility>
namespace arm_compute
{
-void CLFill::configure(ICLTensor *tensor, PixelValue constant_value)
+struct CLFill::Impl
{
- configure(CLKernelLibrary::get().get_compile_context(), tensor, constant_value);
+ const ICLTensor *src{ nullptr };
+ ICLTensor *dst{ nullptr };
+ std::unique_ptr<opencl::ClFill> op{ nullptr };
+};
+
+CLFill::CLFill()
+ : _impl(std::make_unique<Impl>())
+{
+}
+CLFill::CLFill(CLFill &&) = default;
+CLFill &CLFill::operator=(CLFill &&) = default;
+CLFill::~CLFill() = default;
+
+void CLFill::configure(ICLTensor *tensor, const PixelValue &constant_value, Window *dst_window)
+{
+ configure(CLKernelLibrary::get().get_compile_context(), tensor, constant_value, dst_window);
+}
+
+void CLFill::configure(const CLCompileContext &compile_context, ICLTensor *tensor, const PixelValue &constant_value, Window *dst_window)
+{
+ ARM_COMPUTE_ERROR_ON_NULLPTR(tensor);
+
+ _impl->src = tensor;
+
+ _impl->op = std::make_unique<opencl::ClFill>();
+ _impl->op->configure(compile_context, _impl->src->info(), constant_value, dst_window);
+}
+
+Status CLFill::validate(const ITensorInfo *tensor, const PixelValue &constant_value, Window *dst_window)
+{
+ return opencl::ClFill::validate(tensor, constant_value, dst_window);
}
-void CLFill::configure(const CLCompileContext &compile_context, ICLTensor *tensor, PixelValue constant_value)
+void CLFill::run()
{
- auto k = std::make_unique<CLMemsetKernel>();
- k->configure(compile_context, tensor, constant_value);
- _kernel = std::move(k);
+ ITensorPack pack;
+ pack.add_tensor(TensorType::ACL_SRC, _impl->src);
+ _impl->op->run(pack);
}
} // namespace arm_compute
diff --git a/src/runtime/CL/functions/CLGenerateProposalsLayer.cpp b/src/runtime/CL/functions/CLGenerateProposalsLayer.cpp
index e536816f97..365f95243f 100644
--- a/src/runtime/CL/functions/CLGenerateProposalsLayer.cpp
+++ b/src/runtime/CL/functions/CLGenerateProposalsLayer.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019-2020 Arm Limited.
+ * Copyright (c) 2019-2021 Arm Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -29,7 +29,6 @@
#include "src/core/CL/kernels/CLDequantizationLayerKernel.h"
#include "src/core/CL/kernels/CLGenerateProposalsLayerKernel.h"
#include "src/core/CL/kernels/CLPadLayerKernel.h"
-#include "src/core/CL/kernels/CLPermuteKernel.h"
#include "src/core/CL/kernels/CLQuantizationLayerKernel.h"
#include "src/core/helpers/AutoConfiguration.h"
@@ -37,9 +36,9 @@ namespace arm_compute
{
CLGenerateProposalsLayer::CLGenerateProposalsLayer(std::shared_ptr<IMemoryManager> memory_manager)
: _memory_group(memory_manager),
- _permute_deltas_kernel(std::make_unique<CLPermuteKernel>()),
+ _permute_deltas(),
_flatten_deltas(),
- _permute_scores_kernel(std::make_unique<CLPermuteKernel>()),
+ _permute_scores(),
_flatten_scores(),
_compute_anchors_kernel(std::make_unique<CLComputeAllAnchorsKernel>()),
_bounding_box_kernel(std::make_unique<CLBoundingBoxTransformKernel>()),
@@ -110,7 +109,7 @@ void CLGenerateProposalsLayer::configure(const CLCompileContext &compile_context
if(!_is_nhwc)
{
_memory_group.manage(&_deltas_permuted);
- _permute_deltas_kernel->configure(compile_context, deltas, &_deltas_permuted, PermutationVector{ 2, 0, 1 });
+ _permute_deltas.configure(compile_context, deltas, &_deltas_permuted, PermutationVector{ 2, 0, 1 });
_flatten_deltas.configure(compile_context, &_deltas_permuted, &_deltas_flattened);
_deltas_permuted.allocator()->allocate();
}
@@ -127,7 +126,7 @@ void CLGenerateProposalsLayer::configure(const CLCompileContext &compile_context
if(!_is_nhwc)
{
_memory_group.manage(&_scores_permuted);
- _permute_scores_kernel->configure(compile_context, scores, &_scores_permuted, PermutationVector{ 2, 0, 1 });
+ _permute_scores.configure(compile_context, scores, &_scores_permuted, PermutationVector{ 2, 0, 1 });
_flatten_scores.configure(compile_context, &_scores_permuted, &_scores_flattened);
_scores_permuted.allocator()->allocate();
}
@@ -244,8 +243,8 @@ Status CLGenerateProposalsLayer::validate(const ITensorInfo *scores, const ITens
}
else
{
- ARM_COMPUTE_RETURN_ON_ERROR(CLPermuteKernel::validate(deltas, &deltas_permuted_info, PermutationVector{ 2, 0, 1 }));
- ARM_COMPUTE_RETURN_ON_ERROR(CLPermuteKernel::validate(scores, &scores_permuted_info, PermutationVector{ 2, 0, 1 }));
+ ARM_COMPUTE_RETURN_ON_ERROR(CLPermute::validate(deltas, &deltas_permuted_info, PermutationVector{ 2, 0, 1 }));
+ ARM_COMPUTE_RETURN_ON_ERROR(CLPermute::validate(scores, &scores_permuted_info, PermutationVector{ 2, 0, 1 }));
}
TensorInfo deltas_flattened_info(deltas->clone()->set_tensor_shape(TensorShape(values_per_roi, total_num_anchors)).set_is_resizable(true));
@@ -356,8 +355,8 @@ void CLGenerateProposalsLayer::run()
// Transpose and reshape the inputs
if(!_is_nhwc)
{
- CLScheduler::get().enqueue(*_permute_deltas_kernel, false);
- CLScheduler::get().enqueue(*_permute_scores_kernel, false);
+ _permute_deltas.run();
+ _permute_scores.run();
}
_flatten_deltas.run();
_flatten_scores.run();
diff --git a/src/runtime/CL/functions/CLLSTMLayer.cpp b/src/runtime/CL/functions/CLLSTMLayer.cpp
index 77df917119..5036126aea 100644
--- a/src/runtime/CL/functions/CLLSTMLayer.cpp
+++ b/src/runtime/CL/functions/CLLSTMLayer.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018-2020 Arm Limited.
+ * Copyright (c) 2018-2021 Arm Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -29,7 +29,6 @@
#include "arm_compute/core/utils/misc/ShapeCalculator.h"
#include "arm_compute/core/utils/quantization/AsymmHelpers.h"
#include "arm_compute/runtime/CL/CLScheduler.h"
-#include "src/core/CL/kernels/CLCopyKernel.h"
#include "src/core/CL/kernels/CLDepthConvertLayerKernel.h"
#include "src/core/CL/kernels/CLFillBorderKernel.h"
#include "src/core/CL/kernels/CLGEMMLowpMatrixMultiplyNativeKernel.h"
@@ -42,7 +41,6 @@
#include "src/core/CL/kernels/CLGEMMMatrixMultiplyReshapedOnlyRHSKernel.h"
#include "src/core/CL/kernels/CLGEMMReshapeLHSMatrixKernel.h"
#include "src/core/CL/kernels/CLGEMMReshapeRHSMatrixKernel.h"
-#include "src/core/CL/kernels/CLMemsetKernel.h"
#include "src/core/CL/kernels/CLTransposeKernel.h"
namespace arm_compute
@@ -55,15 +53,14 @@ CLLSTMLayer::CLLSTMLayer(std::shared_ptr<IMemoryManager> memory_manager)
_fully_connected_forget_gate(), _accum_forget_gate1(), _pixelwise_mul_forget_gate(), _activation_forget_gate(), _fully_connected_cell_state(), _gemm_cell_state1(),
_transpose_cell_state(std::make_unique<CLTransposeKernel>()), _accum_cell_state1(), _accum_cell_state2(), _pixelwise_mul_cell_state1(), _activation_cell_state(), _cell_clip(),
_pixelwise_mul_cell_state2(), _fully_connected_output(), _pixelwise_mul_output_state1(), _accum_output1(), _activation_output(), _activation_output_state(), _pixelwise_mul_output_state2(),
- _fully_connected_output_state(), _projection_clip(), _copy_cell_state(std::make_unique<CLCopyKernel>()), _copy_output(std::make_unique<CLCopyKernel>()), _concat_scratch_buffer(),
- _concat_inputs_forget_gate(), _concat_weights_forget_gate(), _concat_weights_input_gate(), _concat_weights_output(), _ones_memset_kernel(std::make_unique<CLMemsetKernel>()),
- _mean_std_norm_input_gate(), _pixelwise_mul_input_gate_coeff(), _accum_input_gate_bias(), _mean_std_norm_forget_gate(), _pixelwise_mul_forget_gate_coeff(), _accum_forget_gate_bias(),
- _mean_std_norm_cell_gate(), _pixelwise_mul_cell_gate_coeff(), _accum_cell_gate_bias(), _mean_std_norm_output_gate(), _pixelwise_mul_output_gate_coeff(), _accum_output_gate_bias(), _input_gate_out1(),
- _input_gate_out2(), _input_gate_out3(), _input_gate_out4(), _forget_gate_out1(), _forget_gate_out2(), _forget_gate_out3(), _forget_gate_out4(), _forget_gate_out5(), _forget_gate_out6(),
- _cell_state_out1(), _cell_state_out2(), _cell_state_out3(), _cell_state_out4(), _cell_state_out5(), _output1(), _output2(), _output3(), _output4(), _cell_state_activation(), _output_state1(), _ones(),
- _input_layer_norm_out1(), _input_layer_norm_out2(), _forget_layer_norm_out1(), _forget_layer_norm_out2(), _cell_layer_norm_out1(), _cell_layer_norm_out2(), _output_layer_norm_out1(),
- _output_layer_norm_out2(), _run_peephole_opt(false), _run_cifg_opt(false), _perform_cell_clipping(false), _has_projection_weights(false), _perform_projection_clipping(false), _is_prepared(false),
- _is_layer_norm_lstm(false)
+ _fully_connected_output_state(), _projection_clip(), _copy_cell_state(), _copy_output(), _concat_scratch_buffer(), _concat_inputs_forget_gate(), _concat_weights_forget_gate(),
+ _concat_weights_input_gate(), _concat_weights_output(), _ones_fill(), _mean_std_norm_input_gate(), _pixelwise_mul_input_gate_coeff(), _accum_input_gate_bias(), _mean_std_norm_forget_gate(),
+ _pixelwise_mul_forget_gate_coeff(), _accum_forget_gate_bias(), _mean_std_norm_cell_gate(), _pixelwise_mul_cell_gate_coeff(), _accum_cell_gate_bias(), _mean_std_norm_output_gate(),
+ _pixelwise_mul_output_gate_coeff(), _accum_output_gate_bias(), _input_gate_out1(), _input_gate_out2(), _input_gate_out3(), _input_gate_out4(), _forget_gate_out1(), _forget_gate_out2(),
+ _forget_gate_out3(), _forget_gate_out4(), _forget_gate_out5(), _forget_gate_out6(), _cell_state_out1(), _cell_state_out2(), _cell_state_out3(), _cell_state_out4(), _cell_state_out5(), _output1(),
+ _output2(), _output3(), _output4(), _cell_state_activation(), _output_state1(), _ones(), _input_layer_norm_out1(), _input_layer_norm_out2(), _forget_layer_norm_out1(), _forget_layer_norm_out2(),
+ _cell_layer_norm_out1(), _cell_layer_norm_out2(), _output_layer_norm_out1(), _output_layer_norm_out2(), _run_peephole_opt(false), _run_cifg_opt(false), _perform_cell_clipping(false),
+ _has_projection_weights(false), _perform_projection_clipping(false), _is_prepared(false), _is_layer_norm_lstm(false)
{
}
@@ -190,7 +187,7 @@ void CLLSTMLayer::configure(const CLCompileContext &compile_context, const ICLTe
{
_memory_group.manage(&_input_gate_out1);
_ones.allocator()->init(TensorInfo(cell_state_shape, 1, input->info()->data_type()));
- _ones_memset_kernel->configure(compile_context, &_ones, PixelValue(1, _ones.info()->data_type()));
+ _ones_fill.configure(compile_context, &_ones, PixelValue(1, _ones.info()->data_type()));
_subtract_input_gate.configure(compile_context, &_ones, forget_gate_out, &_input_gate_out1, ConvertPolicy::SATURATE);
_ones.allocator()->allocate();
_run_cifg_opt = true;
@@ -385,8 +382,8 @@ void CLLSTMLayer::configure(const CLCompileContext &compile_context, const ICLTe
}
// Copy cell state and output
- _copy_cell_state->configure(compile_context, &_cell_state_out1, cell_state_out);
- _copy_output->configure(compile_context, output_state_out, output);
+ _copy_cell_state.configure(compile_context, &_cell_state_out1, cell_state_out);
+ _copy_output.configure(compile_context, output_state_out, output);
// Vector for holding the tensors to store in scratch buffer
std::vector<const ICLTensor *> scratch_inputs;
@@ -618,8 +615,8 @@ Status CLLSTMLayer::validate(const ITensorInfo *input,
}
// Validate copy kernel
- ARM_COMPUTE_RETURN_ON_ERROR(CLCopyKernel::validate(&cell_state_tmp, cell_state_out));
- ARM_COMPUTE_RETURN_ON_ERROR(CLCopyKernel::validate(output_state_out, output));
+ ARM_COMPUTE_RETURN_ON_ERROR(CLCopy::validate(&cell_state_tmp, cell_state_out));
+ ARM_COMPUTE_RETURN_ON_ERROR(CLCopy::validate(output_state_out, output));
// Validate scratch concatenation
std::vector<const ITensorInfo *> inputs_vector_info_raw;
@@ -660,7 +657,7 @@ void CLLSTMLayer::run()
if(_run_cifg_opt)
{
- CLScheduler::get().enqueue(*_ones_memset_kernel);
+ _ones_fill.run();
_subtract_input_gate.run();
}
else
@@ -729,8 +726,8 @@ void CLLSTMLayer::run()
}
}
- CLScheduler::get().enqueue(*_copy_cell_state);
- CLScheduler::get().enqueue(*_copy_output);
+ _copy_cell_state.run();
+ _copy_output.run();
_concat_scratch_buffer.run();
}
diff --git a/src/runtime/CL/functions/CLMaxUnpoolingLayer.cpp b/src/runtime/CL/functions/CLMaxUnpoolingLayer.cpp
index c9deb301ef..52151cdfe1 100644
--- a/src/runtime/CL/functions/CLMaxUnpoolingLayer.cpp
+++ b/src/runtime/CL/functions/CLMaxUnpoolingLayer.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020 Arm Limited.
+ * Copyright (c) 2020-2021 Arm Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -28,12 +28,11 @@
#include "arm_compute/core/Validate.h"
#include "arm_compute/runtime/CL/CLScheduler.h"
#include "src/core/CL/kernels/CLMaxUnpoolingLayerKernel.h"
-#include "src/core/CL/kernels/CLMemsetKernel.h"
namespace arm_compute
{
CLMaxUnpoolingLayer::CLMaxUnpoolingLayer()
- : _memset_kernel(std::make_unique<CLMemsetKernel>()),
+ : _fill(),
_unpooling_layer_kernel(std::make_unique<CLMaxUnpoolingLayerKernel>())
{
}
@@ -48,7 +47,7 @@ void CLMaxUnpoolingLayer::configure(ICLTensor *input, ICLTensor *indices, ICLTen
void CLMaxUnpoolingLayer::configure(const CLCompileContext &compile_context, ICLTensor *input, ICLTensor *indices, ICLTensor *output, const PoolingLayerInfo &pool_info)
{
const PixelValue zero_value(0.f);
- _memset_kernel->configure(output, zero_value);
+ _fill.configure(output, zero_value);
_unpooling_layer_kernel->configure(compile_context, input, indices, output, pool_info);
}
@@ -60,8 +59,8 @@ Status CLMaxUnpoolingLayer::validate(const ITensorInfo *input, const ITensorInfo
void CLMaxUnpoolingLayer::run()
{
- // Run memset
- CLScheduler::get().enqueue(*_memset_kernel, false);
+ // Run fill
+ _fill.run();
// Run max unpooling layer
CLScheduler::get().enqueue(*_unpooling_layer_kernel);
diff --git a/src/runtime/CL/functions/CLPadLayer.cpp b/src/runtime/CL/functions/CLPadLayer.cpp
index 8c5d529117..d105c0597c 100644
--- a/src/runtime/CL/functions/CLPadLayer.cpp
+++ b/src/runtime/CL/functions/CLPadLayer.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019-2020 Arm Limited.
+ * Copyright (c) 2019-2021 Arm Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -22,14 +22,13 @@
* SOFTWARE.
*/
#include "arm_compute/runtime/CL/functions/CLPadLayer.h"
-#include "src/core/CL/kernels/CLCopyKernel.h"
#include "src/core/CL/kernels/CLPadLayerKernel.h"
namespace arm_compute
{
CLPadLayer::CLPadLayer()
: _pad_kernel(std::make_unique<CLPadLayerKernel>()),
- _copy_kernel(std::make_unique<CLCopyKernel>()),
+ _copy(),
_perform_pad(false)
{
}
@@ -57,7 +56,7 @@ void CLPadLayer::configure(const CLCompileContext &compile_context, ICLTensor *i
else
{
// Copy the input to the whole output if no padding is applied
- _copy_kernel->configure(compile_context, input, output);
+ _copy.configure(compile_context, input, output);
}
}
Status CLPadLayer::validate(const ITensorInfo *input, const ITensorInfo *output, const PaddingList &padding, PixelValue constant_value, PaddingMode mode)
@@ -73,7 +72,7 @@ Status CLPadLayer::validate(const ITensorInfo *input, const ITensorInfo *output,
}
else
{
- ARM_COMPUTE_RETURN_ON_ERROR(CLCopyKernel::validate(input, output));
+ ARM_COMPUTE_RETURN_ON_ERROR(CLCopy::validate(input, output));
}
return Status{};
}
@@ -85,7 +84,7 @@ void CLPadLayer::run()
}
else
{
- CLScheduler::get().enqueue(*_copy_kernel);
+ _copy.run();
}
}
} // namespace arm_compute \ No newline at end of file
diff --git a/src/runtime/CL/functions/CLPermute.cpp b/src/runtime/CL/functions/CLPermute.cpp
index 31b152c553..eeb0169241 100644
--- a/src/runtime/CL/functions/CLPermute.cpp
+++ b/src/runtime/CL/functions/CLPermute.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018-2020 Arm Limited.
+ * Copyright (c) 2018-2021 Arm Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -23,12 +23,30 @@
*/
#include "arm_compute/runtime/CL/functions/CLPermute.h"
+#include "arm_compute/core/CL/CLKernelLibrary.h"
#include "arm_compute/core/CL/ICLTensor.h"
-#include "arm_compute/core/Error.h"
-#include "src/core/CL/kernels/CLPermuteKernel.h"
+#include "arm_compute/core/Types.h"
+#include "arm_compute/core/Validate.h"
+#include "src/core/CL/ICLKernel.h"
+#include "src/runtime/gpu/cl/operators/ClPermute.h"
namespace arm_compute
{
+struct CLPermute::Impl
+{
+ const ICLTensor *src{ nullptr };
+ ICLTensor *dst{ nullptr };
+ std::unique_ptr<opencl::ClPermute> op{ nullptr };
+};
+
+CLPermute::CLPermute()
+ : _impl(std::make_unique<Impl>())
+{
+}
+CLPermute::CLPermute(CLPermute &&) = default;
+CLPermute &CLPermute::operator=(CLPermute &&) = default;
+CLPermute::~CLPermute() = default;
+
void CLPermute::configure(const ICLTensor *input, ICLTensor *output, const PermutationVector &perm)
{
configure(CLKernelLibrary::get().get_compile_context(), input, output, perm);
@@ -36,14 +54,25 @@ void CLPermute::configure(const ICLTensor *input, ICLTensor *output, const Permu
void CLPermute::configure(const CLCompileContext &compile_context, const ICLTensor *input, ICLTensor *output, const PermutationVector &perm)
{
- auto k = std::make_unique<CLPermuteKernel>();
- k->configure(compile_context, input, output, perm);
- _kernel = std::move(k);
+ ARM_COMPUTE_ERROR_ON_NULLPTR(input, output);
+
+ _impl->src = input;
+ _impl->dst = output;
+
+ _impl->op = std::make_unique<opencl::ClPermute>();
+ _impl->op->configure(compile_context, _impl->src->info(), _impl->dst->info(), perm);
}
Status CLPermute::validate(const ITensorInfo *input, const ITensorInfo *output, const PermutationVector &perm)
{
- ARM_COMPUTE_RETURN_ON_ERROR(CLPermuteKernel::validate(input, output, perm));
- return Status{};
+ return opencl::ClPermute::validate(input, output, perm);
+}
+
+void CLPermute::run()
+{
+ ITensorPack pack;
+ pack.add_tensor(TensorType::ACL_SRC, _impl->src);
+ pack.add_tensor(TensorType::ACL_DST, _impl->dst);
+ _impl->op->run(pack);
}
-} // namespace arm_compute
+} // namespace arm_compute \ No newline at end of file
diff --git a/src/runtime/CL/functions/CLQLSTMLayer.cpp b/src/runtime/CL/functions/CLQLSTMLayer.cpp
index 4395a39060..e7a0e5765e 100644
--- a/src/runtime/CL/functions/CLQLSTMLayer.cpp
+++ b/src/runtime/CL/functions/CLQLSTMLayer.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020 Arm Limited.
+ * Copyright (c) 2020-2021 Arm Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -30,7 +30,6 @@
#include "arm_compute/core/utils/misc/InfoHelpers.h"
#include "arm_compute/core/utils/quantization/AsymmHelpers.h"
#include "arm_compute/runtime/CL/CLScheduler.h"
-#include "src/core/CL/kernels/CLCopyKernel.h"
#include "src/core/CL/kernels/CLDepthConvertLayerKernel.h"
#include "src/core/CL/kernels/CLFillBorderKernel.h"
#include "src/core/CL/kernels/CLGEMMLowpMatrixMultiplyNativeKernel.h"
@@ -106,7 +105,7 @@ CLQLSTMLayer::CLQLSTMLayer(std::shared_ptr<IMemoryManager> memory_manager)
_recurrent_to_output_reduction(std::make_unique<CLGEMMLowpMatrixAReductionKernel>()),
_projection_reduction(std::make_unique<CLGEMMLowpMatrixAReductionKernel>()),
_layer_norms(),
- _copy_output(std::make_unique<CLCopyKernel>())
+ _copy_output()
{
for(auto &norm : _layer_norms)
{
@@ -593,7 +592,7 @@ void CLQLSTMLayer::configure(const CLCompileContext &compile_context, const ICLT
}
// Copy output_state_out to output
- _copy_output->configure(compile_context, output_state_out, output);
+ _copy_output.configure(compile_context, output_state_out, output);
}
Status CLQLSTMLayer::validate(const ITensorInfo *input,
@@ -957,7 +956,7 @@ Status CLQLSTMLayer::validate(const ITensorInfo *input,
ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_SHAPES(output_state_in, output_state_out);
}
- ARM_COMPUTE_RETURN_ON_ERROR(CLCopyKernel::validate(output_state_out, output));
+ ARM_COMPUTE_RETURN_ON_ERROR(CLCopy::validate(output_state_out, output));
return Status{};
}
@@ -1099,7 +1098,7 @@ void CLQLSTMLayer::run()
}
// Copy output_state_out to output
- CLScheduler::get().enqueue(*_copy_output);
+ _copy_output.run();
}
void CLQLSTMLayer::prepare()
diff --git a/src/runtime/CL/functions/CLRNNLayer.cpp b/src/runtime/CL/functions/CLRNNLayer.cpp
index 2a99ece388..967f4aa41b 100644
--- a/src/runtime/CL/functions/CLRNNLayer.cpp
+++ b/src/runtime/CL/functions/CLRNNLayer.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018-2020 Arm Limited.
+ * Copyright (c) 2018-2021 Arm Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -28,7 +28,6 @@
#include "arm_compute/core/Utils.h"
#include "arm_compute/core/utils/misc/ShapeCalculator.h"
#include "arm_compute/runtime/CL/CLScheduler.h"
-#include "src/core/CL/kernels/CLCopyKernel.h"
#include "src/core/CL/kernels/CLDepthConvertLayerKernel.h"
#include "src/core/CL/kernels/CLFillBorderKernel.h"
#include "src/core/CL/kernels/CLGEMMLowpMatrixMultiplyNativeKernel.h"
@@ -47,8 +46,8 @@ namespace arm_compute
using namespace arm_compute::misc::shape_calculator;
CLRNNLayer::CLRNNLayer(std::shared_ptr<IMemoryManager> memory_manager)
- : _memory_group(std::move(memory_manager)), _gemm_state_f(), _add_kernel(), _activation(), _fully_connected_kernel(), _copy_kernel(std::make_unique<CLCopyKernel>()), _fully_connected_out(),
- _gemm_output(), _add_output(), _is_prepared(false)
+ : _memory_group(std::move(memory_manager)), _gemm_state_f(), _add_kernel(), _activation(), _fully_connected_kernel(), _copy(), _fully_connected_out(), _gemm_output(), _add_output(),
+ _is_prepared(false)
{
}
@@ -122,7 +121,7 @@ void CLRNNLayer::configure(const CLCompileContext &compile_context, const ICLTen
_activation.configure(compile_context, &_add_output, hidden_state, info);
_add_output.allocator()->allocate();
- _copy_kernel->configure(compile_context, hidden_state, output);
+ _copy.configure(compile_context, hidden_state, output);
}
void CLRNNLayer::run()
@@ -137,7 +136,7 @@ void CLRNNLayer::run()
_activation.run();
// copy hidden out to output
- CLScheduler::get().enqueue(*_copy_kernel);
+ _copy.run();
}
void CLRNNLayer::prepare()
diff --git a/src/runtime/CL/functions/CLReshapeLayer.cpp b/src/runtime/CL/functions/CLReshapeLayer.cpp
index 9abaa1b4e1..060eddb96c 100644
--- a/src/runtime/CL/functions/CLReshapeLayer.cpp
+++ b/src/runtime/CL/functions/CLReshapeLayer.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017-2020 Arm Limited.
+ * Copyright (c) 2017-2021 Arm Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -23,32 +23,21 @@
*/
#include "arm_compute/runtime/CL/functions/CLReshapeLayer.h"
+#include "arm_compute/core/CL/CLKernelLibrary.h"
#include "arm_compute/core/CL/ICLTensor.h"
-#include "src/core/CL/kernels/CLReshapeLayerKernel.h"
+#include "arm_compute/core/Types.h"
+#include "arm_compute/core/Validate.h"
+#include "src/core/CL/ICLKernel.h"
+#include "src/runtime/gpu/cl/operators/ClReshape.h"
/** [CLReshapeLayer snippet] **/
namespace arm_compute
{
-namespace experimental
-{
-void CLReshape::configure(const CLCompileContext &compile_context, const ITensorInfo *input, ITensorInfo *output)
-{
- auto k = std::make_unique<CLReshapeLayerKernel>();
- k->configure(compile_context, input, output);
- _kernel = std::move(k);
-}
-
-Status CLReshape::validate(const ITensorInfo *input, const ITensorInfo *output)
-{
- return arm_compute::CLReshapeLayerKernel::validate(input, output);
-}
-} // namespace experimental
-
struct CLReshapeLayer::Impl
{
- const ICLTensor *src{ nullptr };
- ICLTensor *dst{ nullptr };
- std::unique_ptr<experimental::CLReshape> op{ nullptr };
+ const ICLTensor *src{ nullptr };
+ ICLTensor *dst{ nullptr };
+ std::unique_ptr<opencl::ClReshape> op{ nullptr };
};
CLReshapeLayer::CLReshapeLayer()
@@ -69,14 +58,14 @@ void CLReshapeLayer::configure(const CLCompileContext &compile_context, const IC
{
_impl->src = input;
_impl->dst = output;
- _impl->op = std::make_unique<experimental::CLReshape>();
+ _impl->op = std::make_unique<opencl::ClReshape>();
_impl->op->configure(compile_context, input->info(), output->info());
}
Status CLReshapeLayer::validate(const ITensorInfo *input, const ITensorInfo *output)
{
ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(input, output);
- ARM_COMPUTE_RETURN_ON_ERROR(experimental::CLReshape::validate(input, output));
+ ARM_COMPUTE_RETURN_ON_ERROR(opencl::ClReshape::validate(input, output));
return Status{};
}
@@ -89,4 +78,4 @@ void CLReshapeLayer::run()
_impl->op->run(pack);
}
} // namespace arm_compute
-/** [CLReshapeLayer snippet] **/
+/** [CLReshapeLayer snippet] **/ \ No newline at end of file
diff --git a/src/runtime/CL/functions/CLSpaceToBatchLayer.cpp b/src/runtime/CL/functions/CLSpaceToBatchLayer.cpp
index 2db064af44..6180f4de07 100644
--- a/src/runtime/CL/functions/CLSpaceToBatchLayer.cpp
+++ b/src/runtime/CL/functions/CLSpaceToBatchLayer.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018-2020 Arm Limited.
+ * Copyright (c) 2018-2021 Arm Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -29,14 +29,13 @@
#include "arm_compute/core/Types.h"
#include "arm_compute/core/Validate.h"
#include "arm_compute/runtime/CL/CLScheduler.h"
-#include "src/core/CL/kernels/CLMemsetKernel.h"
#include "src/core/CL/kernels/CLSpaceToBatchLayerKernel.h"
namespace arm_compute
{
CLSpaceToBatchLayer::CLSpaceToBatchLayer()
: _space_to_batch_kernel(std::make_unique<CLSpaceToBatchLayerKernel>()),
- _memset_kernel(std::make_unique<CLMemsetKernel>()),
+ _fill(),
_has_padding(false)
{
}
@@ -55,7 +54,7 @@ void CLSpaceToBatchLayer::configure(const CLCompileContext &compile_context, con
if(input->info()->tensor_shape().total_size() != output->info()->tensor_shape().total_size())
{
_has_padding = true;
- _memset_kernel->configure(compile_context, output, PixelValue(0, input->info()->data_type(), input->info()->quantization_info()));
+ _fill.configure(compile_context, output, PixelValue(0, input->info()->data_type(), input->info()->quantization_info()));
}
_space_to_batch_kernel->configure(compile_context, input, block_shape, paddings, output);
}
@@ -73,14 +72,14 @@ void CLSpaceToBatchLayer::configure(const CLCompileContext &compile_context, con
if(input->info()->tensor_shape().total_size() != output->info()->tensor_shape().total_size())
{
_has_padding = true;
- _memset_kernel->configure(compile_context, output, PixelValue(0, input->info()->data_type(), input->info()->quantization_info()));
+ _fill.configure(compile_context, output, PixelValue(0, input->info()->data_type(), input->info()->quantization_info()));
}
_space_to_batch_kernel->configure(compile_context, input, block_shape_x, block_shape_y, padding_left, padding_right, output);
}
Status CLSpaceToBatchLayer::validate(const ITensorInfo *input, const ITensorInfo *block_shape, const ITensorInfo *paddings, const ITensorInfo *output)
{
- ARM_COMPUTE_RETURN_ON_ERROR(CLMemsetKernel::validate(output, PixelValue(0, input->data_type(), input->quantization_info())));
+ ARM_COMPUTE_RETURN_ON_ERROR(CLFill::validate(output, PixelValue(0, input->data_type(), input->quantization_info())));
ARM_COMPUTE_RETURN_ON_ERROR(CLSpaceToBatchLayerKernel::validate(input, block_shape, paddings, output));
return Status{};
@@ -89,7 +88,7 @@ Status CLSpaceToBatchLayer::validate(const ITensorInfo *input, const ITensorInfo
Status CLSpaceToBatchLayer::validate(const ITensorInfo *input, const int block_shape_x, const int block_shape_y, const Size2D &padding_left, const Size2D &padding_right,
const ITensorInfo *output)
{
- ARM_COMPUTE_RETURN_ON_ERROR(CLMemsetKernel::validate(output, PixelValue(0, input->data_type(), input->quantization_info())));
+ ARM_COMPUTE_RETURN_ON_ERROR(CLFill::validate(output, PixelValue(0, input->data_type(), input->quantization_info())));
ARM_COMPUTE_RETURN_ON_ERROR(CLSpaceToBatchLayerKernel::validate(input, block_shape_x, block_shape_y, padding_left, padding_right, output));
return Status{};
@@ -100,7 +99,8 @@ void CLSpaceToBatchLayer::run()
// Zero out output only if we have paddings
if(_has_padding)
{
- CLScheduler::get().enqueue(*_memset_kernel, true);
+ //CLScheduler::get().enqueue(*_fill, true);
+ _fill.run();
}
CLScheduler::get().enqueue(*_space_to_batch_kernel, true);
}
diff --git a/src/runtime/gpu/cl/operators/ClCopy.cpp b/src/runtime/gpu/cl/operators/ClCopy.cpp
new file mode 100644
index 0000000000..2bdb1f5ba1
--- /dev/null
+++ b/src/runtime/gpu/cl/operators/ClCopy.cpp
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2021 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.
+ */
+#include "src/runtime/gpu/cl/operators/ClCopy.h"
+
+#include "src/core/gpu/cl/ClCompileContext.h"
+#include "src/core/gpu/cl/kernels/ClCopyKernel.h"
+
+namespace arm_compute
+{
+namespace opencl
+{
+void ClCopy::configure(const ClCompileContext &compile_context, ITensorInfo *src, ITensorInfo *dst, Window *dst_window)
+{
+ auto k = std::make_unique<kernels::ClCopyKernel>();
+ k->configure(compile_context, src, dst, dst_window);
+ _kernel = std::move(k);
+}
+
+Status ClCopy::validate(const ITensorInfo *src, const ITensorInfo *dst, Window *dst_window)
+{
+ return kernels::ClCopyKernel::validate(src, dst, dst_window);
+}
+} // namespace opencl
+} // namespace arm_compute \ No newline at end of file
diff --git a/src/runtime/gpu/cl/operators/ClCopy.h b/src/runtime/gpu/cl/operators/ClCopy.h
new file mode 100644
index 0000000000..0b99676f65
--- /dev/null
+++ b/src/runtime/gpu/cl/operators/ClCopy.h
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2021 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_CL_COPY_H
+#define ARM_COMPUTE_CL_COPY_H
+
+#include "arm_compute/core/Window.h"
+#include "src/core/gpu/cl/ClCompileContext.h"
+#include "src/runtime/gpu/cl/IClOperator.h"
+
+namespace arm_compute
+{
+namespace opencl
+{
+/** Basic function to run @ref kernels::ClCopyKernel */
+class ClCopy : public IClOperator
+{
+public:
+ /** Constructor */
+ ClCopy() = default;
+ /** Initialise the function's source and destination.
+ *
+ * @param[in] compile_context The compile context to be used.
+ * @param[in] src Source tensor info. Data types supported: All.
+ * @param[out] dst Output tensor info. Data types supported: Same as @p src.
+ * @param[in] dst_window (Optional) Window to be used in case only copying into part of a tensor. Default is nullptr.
+ *
+ */
+ void configure(const CLCompileContext &compile_context, ITensorInfo *src, ITensorInfo *dst, Window *dst_window = nullptr);
+ /** Static function to check if given info will lead to a valid configuration of @ref kernels::ClCopyKernel
+ *
+ * @param[in] src Source tensor info. Data types supported: All.
+ * @param[in] dst Output tensor info. Data types supported: Same as @p src.
+ * @param[in] dst_window (Optional) Window to be used in case only copying into part of a tensor. Default is nullptr.
+ *
+ * @return a status
+ */
+ static Status validate(const ITensorInfo *src, const ITensorInfo *dst, Window *dst_window = nullptr);
+};
+} // namespace opencl
+} // namespace arm_compute
+#endif /* ARM_COMPUTE_CL_COPY_H */
diff --git a/src/runtime/gpu/cl/operators/ClCrop.cpp b/src/runtime/gpu/cl/operators/ClCrop.cpp
new file mode 100644
index 0000000000..17bb11912f
--- /dev/null
+++ b/src/runtime/gpu/cl/operators/ClCrop.cpp
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2021 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.
+ */
+#include "src/runtime/gpu/cl/operators/ClCrop.h"
+
+#include "src/core/gpu/cl/ClCompileContext.h"
+#include "src/core/gpu/cl/kernels/ClCropKernel.h"
+
+namespace arm_compute
+{
+namespace opencl
+{
+void ClCrop::configure(const ClCompileContext &compile_context, const ITensorInfo *src, ITensorInfo *dst, Coordinates2D start, Coordinates2D end, uint32_t batch_index, float extrapolation_value,
+ Window *dst_window)
+{
+ auto k = std::make_unique<kernels::ClCropKernel>();
+ k->configure(compile_context, src, dst, start, end, batch_index, extrapolation_value, dst_window);
+ _kernel = std::move(k);
+}
+
+Status ClCrop::validate(const ITensorInfo *src, const ITensorInfo *dst, Coordinates2D start, Coordinates2D end, uint32_t batch_index, float extrapolation_value, Window *dst_window)
+{
+ return kernels::ClCropKernel::validate(src, dst, start, end, batch_index, extrapolation_value, dst_window);
+}
+} // namespace opencl
+} // namespace arm_compute \ No newline at end of file
diff --git a/src/runtime/gpu/cl/operators/ClCrop.h b/src/runtime/gpu/cl/operators/ClCrop.h
new file mode 100644
index 0000000000..acfbf14742
--- /dev/null
+++ b/src/runtime/gpu/cl/operators/ClCrop.h
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2021 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_CL_COPY_H
+#define ARM_COMPUTE_CL_COPY_H
+
+#include "arm_compute/core/Window.h"
+#include "src/core/gpu/cl/ClCompileContext.h"
+#include "src/runtime/gpu/cl/IClOperator.h"
+
+namespace arm_compute
+{
+namespace opencl
+{
+/** Basic function to run @ref kernels::ClCropKernel */
+class ClCrop : public IClOperator
+{
+public:
+ /** Constructor */
+ ClCrop() = default;
+ /** Initialise the function's source and destination.
+ *
+ * @note Supported tensor rank: up to 4
+ *
+ * @param[in] compile_context The compile context to be used.
+ * @param[in] src Source tensor info. Data type supported: All. Data layouts supported: NHWC.
+ * @param[out] dst Destination tensor info. Data type supported: F32
+ * @param[in] start Coordinates of where to start cropping the image.
+ * @param[in] end Coordinates of where to end cropping the image.
+ * @param[in] batch_index Fourth dimension index of the 3D image to crop in @p src.
+ * @param[in] extrapolation_value Value to be used for values outside of the image. Default is 0.
+ * @param[in] dst_window Output window to be used in case cropped image is being copied into a tensor. Default is nullptr.
+ */
+ void configure(const CLCompileContext &compile_context, const ITensorInfo *src, ITensorInfo *dst, Coordinates2D start, Coordinates2D end, uint32_t batch_index, float extrapolation_value = 0,
+ Window *dst_window = nullptr);
+
+ /** Static function to check if given info will lead to a valid configuration of @ref kernels::ClCropKernel
+ *
+ * @note Supported tensor rank: up to 4
+ *
+ * @param[in] src Source tensor info. Data type supported: All. Data layouts supported: NHWC.
+ * @param[in] dst Destination tensor info. Data type supported: F32
+ * @param[in] start Coordinates of where to start cropping the image.
+ * @param[in] end Coordinates of where to end cropping the image.
+ * @param[in] batch_index Fourth dimension index of the 3D image to crop in @p src.
+ * @param[in] extrapolation_value Value to be used for values outside of the image. Default is 0.
+ * @param[in] dst_window Output window to be used in case cropped image is being copied into a tensor. Default is nullptr.
+ */
+ static Status validate(const ITensorInfo *src, const ITensorInfo *dst, Coordinates2D start, Coordinates2D end, uint32_t batch_index, float extrapolation_value = 0,
+ Window *dst_window = nullptr);
+};
+} // namespace opencl
+} // namespace arm_compute
+#endif /* ARM_COMPUTE_CL_COPY_H */
diff --git a/src/runtime/gpu/cl/operators/ClFill.cpp b/src/runtime/gpu/cl/operators/ClFill.cpp
new file mode 100644
index 0000000000..4d0afaef24
--- /dev/null
+++ b/src/runtime/gpu/cl/operators/ClFill.cpp
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2021 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.
+ */
+#include "src/runtime/gpu/cl/operators/ClFill.h"
+
+#include "src/core/gpu/cl/ClCompileContext.h"
+#include "src/core/gpu/cl/kernels/ClFillKernel.h"
+
+namespace arm_compute
+{
+namespace opencl
+{
+void ClFill::configure(const ClCompileContext &compile_context, ITensorInfo *tensor, const PixelValue &constant_value, Window *dst_window)
+{
+ auto k = std::make_unique<kernels::ClFillKernel>();
+ k->configure(compile_context, tensor, constant_value, dst_window);
+ _kernel = std::move(k);
+}
+
+Status ClFill::validate(const ITensorInfo *tensor, const PixelValue &constant_value, Window *dst_window)
+{
+ return kernels::ClFillKernel::validate(tensor, constant_value, dst_window);
+}
+} // namespace opencl
+} // namespace arm_compute \ No newline at end of file
diff --git a/src/runtime/gpu/cl/operators/ClFill.h b/src/runtime/gpu/cl/operators/ClFill.h
new file mode 100644
index 0000000000..e632d88546
--- /dev/null
+++ b/src/runtime/gpu/cl/operators/ClFill.h
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2021 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_CL_FILL_H
+#define ARM_COMPUTE_CL_FILL_H
+
+#include "arm_compute/core/Window.h"
+#include "src/core/gpu/cl/ClCompileContext.h"
+#include "src/runtime/gpu/cl/IClOperator.h"
+
+namespace arm_compute
+{
+namespace opencl
+{
+/** Basic function to run @ref kernels::ClFillKernel */
+class ClFill : public IClOperator
+{
+public:
+ /** Constructor */
+ ClFill() = default;
+ /** Initialise the kernel's tensor and filling value
+ *
+ * @param[in] compile_context The compile context to be used.
+ * @param[in,out] tensor Source tensor info. Supported data types: All.
+ * @param[in] constant_value The value used to fill the planes of the tensor
+ * @param[in] window Window to be used in case setting only part of a tensor. Default is nullptr.
+ */
+ void configure(const CLCompileContext &compile_context, ITensorInfo *tensor, const PixelValue &constant_value, Window *window = nullptr);
+ /** Static function to check if given info will lead to a valid configuration of @ref kernels::ClFillKernel
+ *
+ * @param[in] tensor Source tensor info. Data types supported: All.
+ * @param[in] constant_value The value used to fill the planes of the tensor.
+ * @param[in] window Window to be used in case setting only part of a tensor. Default is nullptr.
+ *
+ * @return a status
+ */
+ static Status validate(const ITensorInfo *tensor, const PixelValue &constant_value, Window *window = nullptr);
+};
+} // namespace opencl
+} // namespace arm_compute
+#endif /* ARM_COMPUTE_CL_FILL_H */
diff --git a/src/runtime/gpu/cl/operators/ClPermute.cpp b/src/runtime/gpu/cl/operators/ClPermute.cpp
new file mode 100644
index 0000000000..719bb6dac6
--- /dev/null
+++ b/src/runtime/gpu/cl/operators/ClPermute.cpp
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2021 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.
+ */
+#include "src/runtime/gpu/cl/operators/ClPermute.h"
+
+#include "src/core/gpu/cl/ClCompileContext.h"
+#include "src/core/gpu/cl/kernels/ClPermuteKernel.h"
+
+namespace arm_compute
+{
+namespace opencl
+{
+void ClPermute::configure(const ClCompileContext &compile_context, const ITensorInfo *src, ITensorInfo *dst, const PermutationVector &perm)
+{
+ auto k = std::make_unique<kernels::ClPermuteKernel>();
+ k->configure(compile_context, src, dst, perm);
+ _kernel = std::move(k);
+}
+
+Status ClPermute::validate(const ITensorInfo *src, const ITensorInfo *dst, const PermutationVector &perm)
+{
+ return kernels::ClPermuteKernel::validate(src, dst, perm);
+}
+} // namespace opencl
+} // namespace arm_compute \ No newline at end of file
diff --git a/src/runtime/gpu/cl/operators/ClPermute.h b/src/runtime/gpu/cl/operators/ClPermute.h
new file mode 100644
index 0000000000..65648c1434
--- /dev/null
+++ b/src/runtime/gpu/cl/operators/ClPermute.h
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2021 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_CL_RESHAPE_H
+#define ARM_COMPUTE_CL_RESHAPE_H
+
+#include "src/core/gpu/cl/ClCompileContext.h"
+#include "src/runtime/gpu/cl/IClOperator.h"
+
+namespace arm_compute
+{
+namespace opencl
+{
+/** Basic function to run @ref kernels::ClPermuteKernel */
+class ClPermute : public IClOperator
+{
+public:
+ /** Constructor */
+ ClPermute() = default;
+ /** Initialise the kernel's inputs and outputs and permute vector
+ *
+ * @note Arbitrary permutation vectors are supported with rank not greater than 4
+ *
+ * @param[in] compile_context The compile context to be used.
+ * @param[in] src The src tensor info. Data types supported: All.
+ * @param[in] dst The dst tensor info. Data types supported: Same as @p src
+ * @param[in] perm Permutation vector
+ */
+ void configure(const CLCompileContext &compile_context, const ITensorInfo *src, ITensorInfo *dst, const PermutationVector &perm);
+ /** Static function to check if given info will lead to a valid configuration of @ref kernels::ClPermuteKernel.
+ *
+ * @note Arbitrary permutation vectors are supported with rank not greater than 4
+ *
+ * @param[in] src First tensor src info. Data types supported: All.
+ * @param[in] dst Output tensor info. Data types supported: same as @p src.
+ * @param[in] perm Permutation vector
+ *
+ * @return a status
+ */
+ static Status validate(const ITensorInfo *src, const ITensorInfo *dst, const PermutationVector &perm);
+};
+} // namespace opencl
+} // namespace arm_compute
+#endif /* ARM_COMPUTE_CL_RESHAPE_H */ \ No newline at end of file
diff --git a/src/runtime/gpu/cl/operators/ClReshape.cpp b/src/runtime/gpu/cl/operators/ClReshape.cpp
new file mode 100644
index 0000000000..d3fa9f10ab
--- /dev/null
+++ b/src/runtime/gpu/cl/operators/ClReshape.cpp
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2021 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.
+ */
+#include "src/runtime/gpu/cl/operators/ClReshape.h"
+
+#include "src/core/gpu/cl/ClCompileContext.h"
+#include "src/core/gpu/cl/kernels/ClReshapeKernel.h"
+
+namespace arm_compute
+{
+namespace opencl
+{
+void ClReshape::configure(const ClCompileContext &compile_context, const ITensorInfo *src, ITensorInfo *dst)
+{
+ auto k = std::make_unique<kernels::ClReshapeKernel>();
+ k->configure(compile_context, src, dst);
+ _kernel = std::move(k);
+}
+
+Status ClReshape::validate(const ITensorInfo *src, const ITensorInfo *dst)
+{
+ return kernels::ClReshapeKernel::validate(src, dst);
+}
+} // namespace opencl
+} // namespace arm_compute \ No newline at end of file
diff --git a/src/core/CL/kernels/CLReshapeLayerKernel.h b/src/runtime/gpu/cl/operators/ClReshape.h
index 902c44649b..8cccc5776c 100644
--- a/src/core/CL/kernels/CLReshapeLayerKernel.h
+++ b/src/runtime/gpu/cl/operators/ClReshape.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017-2020 Arm Limited.
+ * Copyright (c) 2021 Arm Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -21,39 +21,39 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
-#ifndef ARM_COMPUTE_CLRESHAPELAYERKERNEL_H
-#define ARM_COMPUTE_CLRESHAPELAYERKERNEL_H
+#ifndef ARM_COMPUTE_CL_RESHAPE_H
+#define ARM_COMPUTE_CL_RESHAPE_H
-#include "arm_compute/core/Types.h"
-#include "src/core/CL/ICLKernel.h"
+#include "src/core/gpu/cl/ClCompileContext.h"
+#include "src/runtime/gpu/cl/IClOperator.h"
namespace arm_compute
{
-class ICLTensor;
-
-/** Interface for the kernel to perform tensor reshaping */
-class CLReshapeLayerKernel : public ICLKernel
+namespace opencl
+{
+/** Basic function to run @ref kernels::ClReshapeKernel */
+class ClReshape : public IClOperator
{
public:
- /** Set the input and output of the kernel
+ /** Constructor */
+ ClReshape() = default;
+ /** Initialise the kernel's inputs and outputs
*
* @param[in] compile_context The compile context to be used.
- * @param[in] input Source tensor info. Data type supported: All.
- * @param[out] output Destination tensor info. Data type supported: Same as @p input
+ * @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 CLReshapeLayerKernel
+ /** Static function to check if given info will lead to a valid configuration of @ref kernels::ClReshapeKernel
*
- * @param[in] input Source tensor info. Data type supported: All
- * @param[in] output Destination tensor info. Data type supported: Same as @p input
+ * @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:
- void run_op(ITensorPack &tensors, const Window &window, cl::CommandQueue &queue) override;
};
+} // namespace opencl
} // namespace arm_compute
-#endif /*ARM_COMPUTE_CLRESHAPELAYERKERNEL_H */
+#endif /* ARM_COMPUTE_CL_RESHAPE_H */ \ No newline at end of file
diff --git a/tests/CL/Helper.h b/tests/CL/Helper.h
index d217af6e18..5153e98add 100644
--- a/tests/CL/Helper.h
+++ b/tests/CL/Helper.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017-2020 Arm Limited.
+ * Copyright (c) 2017-2021 Arm Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -24,12 +24,11 @@
#ifndef ARM_COMPUTE_TEST_CL_HELPER_H
#define ARM_COMPUTE_TEST_CL_HELPER_H
-#include "src/core/CL/kernels/CLFillBorderKernel.h"
-#include "src/core/CL/kernels/CLMemsetKernel.h"
-
#include "arm_compute/runtime/CL/CLScheduler.h"
#include "arm_compute/runtime/CL/ICLSimpleFunction.h"
+#include "arm_compute/runtime/CL/functions/CLFill.h"
#include "arm_compute/runtime/IFunction.h"
+#include "src/core/CL/kernels/CLFillBorderKernel.h"
#include "src/core/CL/ICLKernel.h"
@@ -118,7 +117,7 @@ public:
k->configure(first, second, std::forward<Args>(args)...);
_kernel = std::move(k);
_border_handler.configure(first, BorderSize(bordersize), BorderMode::CONSTANT, PixelValue());
- _memset_kernel.configure(second, PixelValue());
+ _fill.configure(second, PixelValue());
}
// Inherited method overridden:
@@ -126,13 +125,13 @@ public:
{
ARM_COMPUTE_ERROR_ON_MSG(!_kernel, "The CL kernel or function isn't configured");
- CLScheduler::get().enqueue(_memset_kernel, false);
+ _fill.run();
CLScheduler::get().enqueue(_border_handler, false);
CLScheduler::get().enqueue(*_kernel);
}
private:
- CLMemsetKernel _memset_kernel{}; /**< Kernel to initialize the tensor */
+ CLFill _fill{}; /**< Kernel to initialize the tensor */
CLFillBorderKernel _border_handler{}; /**< Kernel to handle borders */
std::unique_ptr<ICLKernel> _kernel{}; /**< Kernel to run */
};