22.11
AclOperators.h File Reference
#include "arm_compute/AclDescriptors.h"
#include "arm_compute/AclTypes.h"

Go to the source code of this file.

Macros

#define ARM_COMPUTE_VALIDATE_OPERATOR_SUPPORT   ((AclOperator *)(size_t)-1)
Used during an operator creation to validate its support. More...

Functions

AclStatus AclActivation (AclOperator *op, AclContext ctx, const AclTensorDescriptor *src, const AclTensorDescriptor *dst, const AclActivationDescriptor info)
__cplusplus More...

◆ ARM_COMPUTE_VALIDATE_OPERATOR_SUPPORT

 #define ARM_COMPUTE_VALIDATE_OPERATOR_SUPPORT   ((AclOperator *)(size_t)-1)

Used during an operator creation to validate its support.

Definition at line 31 of file AclOperators.h.

Referenced by AclActivation().

◆ AclActivation()

 AclStatus AclActivation ( AclOperator * op, AclContext ctx, const AclTensorDescriptor * src, const AclTensorDescriptor * dst, const AclActivationDescriptor info )

__cplusplus

Create an activation operator

Applies an activation function to a given tensor . Compute Library supports a wide list of activation functions AclActivationType.

A summarized table is the following:

Activation Function Mathematical Expression
Identity $$f(x)= x$$
Logistic $$f(x) = \frac{1}{1 + e^{-x}}$$
Tanh $$f(x) = a \cdot tanh(b \cdot x)$$
Relu $$f(x) = max(0,x)$$
Bounded Relu $$f(x) = min(a, max(0,x))$$
Lower-Upper Bounded Relu $$f(x) = min(a, max(b,x))$$
Leaky Relu $$f(x) = \begin{cases} \alpha x & \quad \text{if } x \text{ < 0}\\ x & \quad \text{if } x \geq \text{ 0 } \end{cases}$$
Soft Relu $$f(x)= log(1+e^x)$$
Soft Elu $$f(x) = \begin{cases} \alpha (exp(x) - 1) & \quad \text{if } x \text{ < 0}\\ x & \quad \text{if } x \geq \text{ 0 } \end{cases}$$
Abs $$f(x)= |x|$$
Square $$f(x)= x^2$$
Sqrt $$f(x) = \sqrt{x}$$
Linear $$f(x)= ax + b$$
Hard Swish $$f(x) = (x * relu6(x+3))/6$$

Backends:

• OpenCL: ClActivationLayer
• Cpu : CpuActivationLayer
Parameters
 [in,out] op Operator construct to be created if creation was successful [in] ctx Context to be used for the creation of the operator [in] src Source tensor descriptor. Slot id: ACL_SRC [in] dst Destination tensor descriptor. Slot id: ACL_DST [in] info Activation meta-data
Returns
Status code

Returns:

Definition at line 30 of file AclActivation.cpp.

Referenced by Activation::Activation().

35 {
36  using namespace arm_compute;
37
38  // Extract internal context
39  auto ctx = get_internal(external_ctx);
42
43  bool is_validate = (external_op == ARM_COMPUTE_VALIDATE_OPERATOR_SUPPORT);
44
45  std::tie(*external_op, status) = ctx->create_activation(*src, *dst, info, is_validate);
47
48  return AclSuccess;
49 }
#define ARM_COMPUTE_RETURN_CENUM_ON_FAILURE(status)
Definition: Macros.h:29
#define ARM_COMPUTE_VALIDATE_OPERATOR_SUPPORT
Used during an operator creation to validate its support.
Definition: AclOperators.h:31
StatusCode validate_internal_context(const IContext *ctx)
Check if an internal context is valid.
Definition: IContext.h:140