aboutsummaryrefslogtreecommitdiff
path: root/arm_compute
diff options
context:
space:
mode:
authorMichalis Spyrou <michalis.spyrou@arm.com>2020-07-15 18:10:17 +0100
committerMichalis Spyrou <michalis.spyrou@arm.com>2020-07-16 13:17:30 +0000
commitf738fe6b6e059916294c48b942952c261569df18 (patch)
treed21afcfa2f5c8db50a1debb8702d25b7be581f4c /arm_compute
parent85b7599eb1dd5c9f5a61ac70a7b18e908b4ac536 (diff)
downloadComputeLibrary-f738fe6b6e059916294c48b942952c261569df18.tar.gz
COMPMID-3389: Async support to CLElementwiseUnaryLayerKernel kernels/functions
Signed-off-by: Michalis Spyrou <michalis.spyrou@arm.com> Change-Id: I2ce75a4705cfd75e30aefa0a2ea31e751b975469 Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/3579 Tested-by: Arm Jenkins <bsgcomp@arm.com> Reviewed-by: Michele Di Giorgio <michele.digiorgio@arm.com> Comments-Addressed: Arm Jenkins <bsgcomp@arm.com>
Diffstat (limited to 'arm_compute')
-rw-r--r--arm_compute/core/CL/kernels/CLElementWiseUnaryLayerKernel.h19
-rw-r--r--arm_compute/runtime/CL/functions/CLElementWiseUnaryLayer.h361
2 files changed, 363 insertions, 17 deletions
diff --git a/arm_compute/core/CL/kernels/CLElementWiseUnaryLayerKernel.h b/arm_compute/core/CL/kernels/CLElementWiseUnaryLayerKernel.h
index ae358b02e3..f8f158c5bc 100644
--- a/arm_compute/core/CL/kernels/CLElementWiseUnaryLayerKernel.h
+++ b/arm_compute/core/CL/kernels/CLElementWiseUnaryLayerKernel.h
@@ -30,27 +30,25 @@
namespace arm_compute
{
-class ICLTensor;
-
/** Interface for the elementwise unary operator */
-class CLElementWiseUnaryLayerKernel : public ICLSimpleKernel
+class CLElementWiseUnaryLayerKernel : public ICLKernel
{
public:
/** Initialise the kernel's inputs, output.
*
- * @param[in] input First tensor input. Data types supported: F16/F32.
- * @param[out] output Output tensor. Data types supported: Same as @p input.
+ * @param[in] input First tensor input info. Data types supported: F16/F32.
+ * @param[out] output Output tensor info. Data types supported: Same as @p input.
* @param[in] op Element wise unary operation to perform.
*/
- void configure(const ICLTensor *input, ICLTensor *output, const ElementWiseUnary &op);
+ void configure(const ITensorInfo *input, ITensorInfo *output, const ElementWiseUnary &op);
/** Initialise the kernel's inputs, output.
*
* @param[in] compile_context The compile context to be used.
- * @param[in] input First tensor input. Data types supported: F16/F32.
- * @param[out] output Output tensor. Data types supported: Same as @p input.
+ * @param[in] input First tensor input info. Data types supported: F16/F32.
+ * @param[out] output Output tensor info. Data types supported: Same as @p input.
* @param[in] op Element wise unary operation to perform.
*/
- void configure(const CLCompileContext &compile_context, const ICLTensor *input, ICLTensor *output, const ElementWiseUnary &op);
+ void configure(const CLCompileContext &compile_context, const ITensorInfo *input, ITensorInfo *output, const ElementWiseUnary &op);
/** Static function to check if given info will lead to a valid configuration of @ref CLElementWiseUnaryLayerKernel
*
* @param[in] input First tensor input info. Data types supported: F16/F32.
@@ -62,7 +60,8 @@ public:
static Status validate(const ITensorInfo *input, const ITensorInfo *output, const ElementWiseUnary &op);
// Inherited methods overridden:
- void run(const Window &window, cl::CommandQueue &queue) override;
+ void run_op(const InputTensorMap &inputs, const OutputTensorMap &outputs,
+ const Window &window, cl::CommandQueue &queue) override;
};
} // namespace arm_compute
#endif /* ARM_COMPUTE_CLELEMENTWISEUNARYLAYERKERNEL_H */
diff --git a/arm_compute/runtime/CL/functions/CLElementWiseUnaryLayer.h b/arm_compute/runtime/CL/functions/CLElementWiseUnaryLayer.h
index de8b8f7843..e4268c1592 100644
--- a/arm_compute/runtime/CL/functions/CLElementWiseUnaryLayer.h
+++ b/arm_compute/runtime/CL/functions/CLElementWiseUnaryLayer.h
@@ -24,6 +24,7 @@
#ifndef ARM_COMPUTE_CLELEMENTWISEUNARYLAYER_H
#define ARM_COMPUTE_CLELEMENTWISEUNARYLAYER_H
+#include "arm_compute/runtime/CL/ICLOperator.h"
#include "arm_compute/runtime/CL/ICLSimpleFunction.h"
namespace arm_compute
@@ -31,9 +32,21 @@ namespace arm_compute
class ICLTensor;
/** Basic function to perform inverse square root on an input tensor. */
-class CLRsqrtLayer : public ICLSimpleFunction
+class CLRsqrtLayer : public IFunction
{
public:
+ /** Default Constructor */
+ CLRsqrtLayer();
+ /** Default Destructor */
+ ~CLRsqrtLayer();
+ /** Prevent instances of this class from being copied (As this class contains pointers) */
+ CLRsqrtLayer(const CLRsqrtLayer &) = delete;
+ /** Default move constructor */
+ CLRsqrtLayer(CLRsqrtLayer &&);
+ /** Prevent instances of this class from being copied (As this class contains pointers) */
+ CLRsqrtLayer &operator=(const CLRsqrtLayer &) = delete;
+ /** Default move assignment operator */
+ CLRsqrtLayer &operator=(CLRsqrtLayer &&);
/** Initialize the function
*
* @param[in] input Input tensor. Data types supported: F16/F32.
@@ -55,12 +68,31 @@ public:
* @return a status
*/
static Status validate(const ITensorInfo *input, const ITensorInfo *output);
+
+ // Inherited methods overridden:
+ void run() override;
+
+private:
+ struct Impl;
+ std::unique_ptr<Impl> _impl;
};
/** Basic function to perform exponential on an input tensor. */
-class CLExpLayer : public ICLSimpleFunction
+class CLExpLayer : public IFunction
{
public:
+ /** Default Constructor */
+ CLExpLayer();
+ /** Default Destructor */
+ ~CLExpLayer();
+ /** Prevent instances of this class from being copied (As this class contains pointers) */
+ CLExpLayer(const CLExpLayer &) = delete;
+ /** Default move constructor */
+ CLExpLayer(CLExpLayer &&);
+ /** Prevent instances of this class from being copied (As this class contains pointers) */
+ CLExpLayer &operator=(const CLExpLayer &) = delete;
+ /** Default move assignment operator */
+ CLExpLayer &operator=(CLExpLayer &&);
/** Initialize the function
*
* @param[in] input Input tensor. Data types supported: F16/F32.
@@ -82,12 +114,31 @@ public:
* @return a status
*/
static Status validate(const ITensorInfo *input, const ITensorInfo *output);
+
+ // Inherited methods overridden:
+ void run() override;
+
+private:
+ struct Impl;
+ std::unique_ptr<Impl> _impl;
};
/** Basic function to negate an input tensor. */
-class CLNegLayer : public ICLSimpleFunction
+class CLNegLayer : public IFunction
{
public:
+ /** Default Constructor */
+ CLNegLayer();
+ /** Default Destructor */
+ ~CLNegLayer();
+ /** Prevent instances of this class from being copied (As this class contains pointers) */
+ CLNegLayer(const CLNegLayer &) = delete;
+ /** Default move constructor */
+ CLNegLayer(CLNegLayer &&);
+ /** Prevent instances of this class from being copied (As this class contains pointers) */
+ CLNegLayer &operator=(const CLNegLayer &) = delete;
+ /** Default move assignment operator */
+ CLNegLayer &operator=(CLNegLayer &&);
/** Initialize the function
*
* @param[in] input Input tensor. Data types supported: F16/F32.
@@ -109,12 +160,31 @@ public:
* @return a status
*/
static Status validate(const ITensorInfo *input, const ITensorInfo *output);
+
+ // Inherited methods overridden:
+ void run() override;
+
+private:
+ struct Impl;
+ std::unique_ptr<Impl> _impl;
};
/** Basic function to calculate sine of an input tensor. */
-class CLSinLayer : public ICLSimpleFunction
+class CLSinLayer : public IFunction
{
public:
+ /** Default Constructor */
+ CLSinLayer();
+ /** Default Destructor */
+ ~CLSinLayer();
+ /** Prevent instances of this class from being copied (As this class contains pointers) */
+ CLSinLayer(const CLSinLayer &) = delete;
+ /** Default move constructor */
+ CLSinLayer(CLSinLayer &&);
+ /** Prevent instances of this class from being copied (As this class contains pointers) */
+ CLSinLayer &operator=(const CLSinLayer &) = delete;
+ /** Default move assignment operator */
+ CLSinLayer &operator=(CLSinLayer &&);
/** Initialize the function
*
* @param[in] input Input tensor. Data types supported: F16/F32.
@@ -136,12 +206,31 @@ public:
* @return a status
*/
static Status validate(const ITensorInfo *input, const ITensorInfo *output);
+
+ // Inherited methods overridden:
+ void run() override;
+
+private:
+ struct Impl;
+ std::unique_ptr<Impl> _impl;
};
/** Basic function to perform elementwise log on an input tensor. */
-class CLLogLayer : public ICLSimpleFunction
+class CLLogLayer : public IFunction
{
public:
+ /** Default Constructor */
+ CLLogLayer();
+ /** Default Destructor */
+ ~CLLogLayer();
+ /** Prevent instances of this class from being copied (As this class contains pointers) */
+ CLLogLayer(const CLLogLayer &) = delete;
+ /** Default move constructor */
+ CLLogLayer(CLLogLayer &&);
+ /** Prevent instances of this class from being copied (As this class contains pointers) */
+ CLLogLayer &operator=(const CLLogLayer &) = delete;
+ /** Default move assignment operator */
+ CLLogLayer &operator=(CLLogLayer &&);
/** Initialize the function
*
* @param[in] input Input tensor. Data types supported: F16/F32.
@@ -163,12 +252,31 @@ public:
* @return a status
*/
static Status validate(const ITensorInfo *input, const ITensorInfo *output);
+
+ // Inherited methods overridden:
+ void run() override;
+
+private:
+ struct Impl;
+ std::unique_ptr<Impl> _impl;
};
/** Basic function to get the absolute value of an input tensor. */
-class CLAbsLayer : public ICLSimpleFunction
+class CLAbsLayer : public IFunction
{
public:
+ /** Default Constructor */
+ CLAbsLayer();
+ /** Default Destructor */
+ ~CLAbsLayer();
+ /** Prevent instances of this class from being copied (As this class contains pointers) */
+ CLAbsLayer(const CLAbsLayer &) = delete;
+ /** Default move constructor */
+ CLAbsLayer(CLAbsLayer &&);
+ /** Prevent instances of this class from being copied (As this class contains pointers) */
+ CLAbsLayer &operator=(const CLAbsLayer &) = delete;
+ /** Default move assignment operator */
+ CLAbsLayer &operator=(CLAbsLayer &&);
/** Initialize the function
*
* @param[in] input Input tensor. Data types supported: F16/F32.
@@ -190,12 +298,31 @@ public:
* @return a status
*/
static Status validate(const ITensorInfo *input, const ITensorInfo *output);
+
+ // Inherited methods overridden:
+ void run() override;
+
+private:
+ struct Impl;
+ std::unique_ptr<Impl> _impl;
};
/** Basic function to get the round (to the nearest even) value of an input tensor. */
-class CLRoundLayer : public ICLSimpleFunction
+class CLRoundLayer : public IFunction
{
public:
+ /** Default Constructor */
+ CLRoundLayer();
+ /** Default Destructor */
+ ~CLRoundLayer();
+ /** Prevent instances of this class from being copied (As this class contains pointers) */
+ CLRoundLayer(const CLRoundLayer &) = delete;
+ /** Default move constructor */
+ CLRoundLayer(CLRoundLayer &&);
+ /** Prevent instances of this class from being copied (As this class contains pointers) */
+ CLRoundLayer &operator=(const CLRoundLayer &) = delete;
+ /** Default move assignment operator */
+ CLRoundLayer &operator=(CLRoundLayer &&);
/** Initialize the function
*
* @param[in] input Input tensor. Data types supported: F16/F32.
@@ -217,6 +344,226 @@ public:
* @return a status
*/
static Status validate(const ITensorInfo *input, const ITensorInfo *output);
+
+ // Inherited methods overridden:
+ void run() override;
+
+private:
+ struct Impl;
+ std::unique_ptr<Impl> _impl;
+};
+
+namespace experimental
+{
+/** Basic function to perform inverse square root on an input tensor. */
+class CLRsqrtLayer : public ICLOperator
+{
+public:
+ /** Initialize the function
+ *
+ * @param[in] input Input tensor info. Data types supported: F16/F32.
+ * @param[out] output Output tensor info. Data types supported: same as @p input.
+ */
+ void configure(const ITensorInfo *input, ITensorInfo *output);
+ /** Initialize the function
+ *
+ * @param[in] compile_context The compile context to be used.
+ * @param[in] input Input tensor info. Data types supported: F16/F32.
+ * @param[out] output Output tensor info. Data types 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 CLRsqrtLayer
+ *
+ * @param[in] input First tensor input info. Data types supported: F16/F32.
+ * @param[in] output Output tensor info. Data types supported: Same as @p input.
+ *
+ * @return a status
+ */
+ static Status validate(const ITensorInfo *input, const ITensorInfo *output);
+
+ // Inherited methods overridden:
+ MemoryRequirements workspace() const override;
+};
+
+/** Basic function to perform exponential on an input tensor. */
+class CLExpLayer : public ICLOperator
+{
+public:
+ /** Initialize the function
+ *
+ * @param[in] input Input tensor info. Data types supported: F16/F32.
+ * @param[out] output Output tensor info. Data types supported: same as @p input.
+ */
+ void configure(const ITensorInfo *input, ITensorInfo *output);
+ /** Initialize the function
+ *
+ * @param[in] compile_context The compile context to be used.
+ * @param[in] input Input tensor info. Data types supported: F16/F32.
+ * @param[out] output Output tensor info. Data types 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 CLExpLayer
+ *
+ * @param[in] input First tensor input info. Data types supported: F16/F32.
+ * @param[in] output Output tensor info. Data types supported: Same as @p input.
+ *
+ * @return a status
+ */
+ static Status validate(const ITensorInfo *input, const ITensorInfo *output);
+
+ // Inherited methods overridden:
+ MemoryRequirements workspace() const override;
+};
+
+/** Basic function to negate an input tensor. */
+class CLNegLayer : public ICLOperator
+{
+public:
+ /** Initialize the function
+ *
+ * @param[in] input Input tensor info. Data types supported: F16/F32.
+ * @param[out] output Output tensor info. Data types supported: same as @p input.
+ */
+ void configure(const ITensorInfo *input, ITensorInfo *output);
+ /** Initialize the function
+ *
+ * @param[in] compile_context The compile context to be used.
+ * @param[in] input Input tensor info. Data types supported: F16/F32.
+ * @param[out] output Output tensor info. Data types 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 CLNegLayer
+ *
+ * @param[in] input First tensor input info. Data types supported: F16/F32.
+ * @param[in] output Output tensor info. Data types supported: Same as @p input.
+ *
+ * @return a status
+ */
+ static Status validate(const ITensorInfo *input, const ITensorInfo *output);
+
+ // Inherited methods overridden:
+ MemoryRequirements workspace() const override;
+};
+
+/** Basic function to calculate sine of an input tensor. */
+class CLSinLayer : public ICLOperator
+{
+public:
+ /** Initialize the function
+ *
+ * @param[in] input Input tensor info. Data types supported: F16/F32.
+ * @param[out] output Output tensor info. Data types supported: same as @p input.
+ */
+ void configure(const ITensorInfo *input, ITensorInfo *output);
+ /** Initialize the function
+ *
+ * @param[in] compile_context The compile context to be used.
+ * @param[in] input Input tensor info. Data types supported: F16/F32.
+ * @param[out] output Output tensor info. Data types 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 CLSinLayer
+ *
+ * @param[in] input First tensor input info. Data types supported: F16/F32.
+ * @param[in] output Output tensor info. Data types supported: Same as @p input.
+ *
+ * @return a status
+ */
+ static Status validate(const ITensorInfo *input, const ITensorInfo *output);
+
+ // Inherited methods overridden:
+ MemoryRequirements workspace() const override;
+};
+
+/** Basic function to perform elementwise log on an input tensor. */
+class CLLogLayer : public ICLOperator
+{
+public:
+ /** Initialize the function
+ *
+ * @param[in] input Input tensor info. Data types supported: F16/F32.
+ * @param[out] output Output tensor info. Data types supported: same as @p input.
+ */
+ void configure(const ITensorInfo *input, ITensorInfo *output);
+ /** Initialize the function
+ *
+ * @param[in] compile_context The compile context to be used.
+ * @param[in] input Input tensor info. Data types supported: F16/F32.
+ * @param[out] output Output tensor info. Data types 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 CLLogLayer
+ *
+ * @param[in] input First tensor input info. Data types supported: F16/F32.
+ * @param[in] output Output tensor info. Data types supported: Same as @p input.
+ *
+ * @return a status
+ */
+ static Status validate(const ITensorInfo *input, const ITensorInfo *output);
+
+ // Inherited methods overridden:
+ MemoryRequirements workspace() const override;
+};
+
+/** Basic function to get the absolute value of an input tensor. */
+class CLAbsLayer : public ICLOperator
+{
+public:
+ /** Initialize the function
+ *
+ * @param[in] input Input tensor info. Data types supported: F16/F32.
+ * @param[out] output Output tensor info. Data types supported: same as @p input.
+ */
+ void configure(const ITensorInfo *input, ITensorInfo *output);
+ /** Initialize the function
+ *
+ * @param[in] compile_context The compile context to be used.
+ * @param[in] input Input tensor info. Data types supported: F16/F32.
+ * @param[out] output Output tensor info. Data types 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 CLAbsLayer
+ *
+ * @param[in] input First tensor input info. Data types supported: F16/F32.
+ * @param[in] output Output tensor info. Data types supported: Same as @p input.
+ *
+ * @return a status
+ */
+ static Status validate(const ITensorInfo *input, const ITensorInfo *output);
+
+ // Inherited methods overridden:
+ MemoryRequirements workspace() const override;
+};
+
+/** Basic function to get the round (to the nearest even) value of an input tensor. */
+class CLRoundLayer : public ICLOperator
+{
+public:
+ /** Initialize the function
+ *
+ * @param[in] input Input tensor info. Data types supported: F16/F32.
+ * @param[out] output Output tensor info. Data types supported: same as @p input.
+ */
+ void configure(const ITensorInfo *input, ITensorInfo *output);
+ /** Initialize the function
+ *
+ * @param[in] compile_context The compile context to be used.
+ * @param[in] input Input tensor info. Data types supported: F16/F32.
+ * @param[out] output Output tensor info. Data types 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 CLRoundLayer
+ *
+ * @param[in] input First tensor input info. Data types supported: F16/F32.
+ * @param[in] output Output tensor info. Data types supported: Same as @p input.
+ *
+ * @return a status
+ */
+ static Status validate(const ITensorInfo *input, const ITensorInfo *output);
+
+ // Inherited methods overridden:
+ MemoryRequirements workspace() const override;
};
+} // namespace experimental
} // namespace arm_compute
#endif /* ARM_COMPUTE_CLELEMENTWISEUNARYLAYER_H */