Compute Library
 22.11
AclOperators.h File Reference

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...
 

Macro Definition Documentation

◆ 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().

Function Documentation

◆ 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]opOperator construct to be created if creation was successful
[in]ctxContext to be used for the creation of the operator
[in]srcSource tensor descriptor. Slot id: ACL_SRC
[in]dstDestination tensor descriptor. Slot id: ACL_DST
[in]infoActivation meta-data
Returns
Status code

Returns:

Definition at line 30 of file AclActivation.cpp.

References AclSuccess, ARM_COMPUTE_RETURN_CENUM_ON_FAILURE, ARM_COMPUTE_VALIDATE_OPERATOR_SUPPORT, arm_compute::get_internal(), and arm_compute::detail::validate_internal_context().

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
Copyright (c) 2017-2022 Arm Limited.
Call succeeded, leading to valid state for all involved objects/data.
Definition: AclTypes.h:51
StatusCode
Definition: Types.h:32
IContext * get_internal(AclContext ctx)
Extract internal representation of a Context.
Definition: IContext.h:127