Compute Library  18.05
activation_layer.cl File Reference
#include "helpers.h"

Go to the source code of this file.

Macros

#define TYPE   VEC_DATA_TYPE(DATA_TYPE, VEC_SIZE)
 
#define CONST_ONE   1.f
 
#define ABS_OP(a)   fabs((a))
 
#define ADD_OP(a, b)   ((a) + (b))
 
#define SUB_OP(a, b)   ((a) - (b))
 
#define MUL_OP(a, b)   ((a) * (b))
 
#define MLA_OP(a, b, c)   ((b) * (c) + (a))
 
#define DIV_OP(a, b)   ((a) / (b))
 
#define EXP_OP(a)   exp((a))
 
#define LOG_OP(a)   log((a))
 
#define SQRT_OP(a)   sqrt((a))
 
#define TANH_OP(a)   tanh((a))
 
#define ACTIVATION_OP2(op, x)   op##_op(x)
 
#define ACTIVATION_OP(op, x)   ACTIVATION_OP2(op, x)
 

Functions

DATA_TYPEVEC_SIZE logistic_op (DATA_TYPEVEC_SIZE x)
 
DATA_TYPEVEC_SIZE tanh_op (DATA_TYPEVEC_SIZE x)
 
DATA_TYPEVEC_SIZE relu_op (DATA_TYPEVEC_SIZE x)
 
DATA_TYPEVEC_SIZE brelu_op (DATA_TYPEVEC_SIZE x)
 
DATA_TYPEVEC_SIZE lu_brelu_op (DATA_TYPEVEC_SIZE x)
 
DATA_TYPEVEC_SIZE lrelu_op (DATA_TYPEVEC_SIZE x)
 
DATA_TYPEVEC_SIZE srelu_op (DATA_TYPEVEC_SIZE x)
 
DATA_TYPEVEC_SIZE abs_op (DATA_TYPEVEC_SIZE x)
 
DATA_TYPEVEC_SIZE square_op (DATA_TYPEVEC_SIZE x)
 
DATA_TYPEVEC_SIZE sqrt_op (DATA_TYPEVEC_SIZE x)
 
DATA_TYPEVEC_SIZE linear_op (DATA_TYPEVEC_SIZE x)
 

Macro Definition Documentation

#define ABS_OP (   a)    fabs((a))

Definition at line 46 of file activation_layer.cl.

Referenced by abs_op().

#define ACTIVATION_OP (   op,
 
)    ACTIVATION_OP2(op, x)

Definition at line 116 of file activation_layer.cl.

#define ACTIVATION_OP2 (   op,
 
)    op##_op(x)

Definition at line 115 of file activation_layer.cl.

#define ADD_OP (   a,
 
)    ((a) + (b))

Definition at line 47 of file activation_layer.cl.

Referenced by logistic_op(), and srelu_op().

#define CONST_ONE   1.f

Definition at line 45 of file activation_layer.cl.

Referenced by logistic_op(), and srelu_op().

#define DIV_OP (   a,
 
)    ((a) / (b))

Definition at line 51 of file activation_layer.cl.

Referenced by logistic_op().

#define EXP_OP (   a)    exp((a))

Definition at line 52 of file activation_layer.cl.

Referenced by logistic_op(), and srelu_op().

#define LOG_OP (   a)    log((a))

Definition at line 53 of file activation_layer.cl.

Referenced by srelu_op().

#define MLA_OP (   a,
  b,
 
)    ((b) * (c) + (a))

Definition at line 50 of file activation_layer.cl.

Referenced by linear_op().

#define MUL_OP (   a,
 
)    ((a) * (b))

Definition at line 49 of file activation_layer.cl.

Referenced by lrelu_op(), square_op(), and tanh_op().

#define SQRT_OP (   a)    sqrt((a))

Definition at line 54 of file activation_layer.cl.

Referenced by sqrt_op().

#define SUB_OP (   a,
 
)    ((a) - (b))

Definition at line 48 of file activation_layer.cl.

#define TANH_OP (   a)    tanh((a))

Definition at line 55 of file activation_layer.cl.

Referenced by tanh_op().

#define TYPE   VEC_DATA_TYPE(DATA_TYPE, VEC_SIZE)

Function Documentation

DATA_TYPEVEC_SIZE abs_op ( DATA_TYPEVEC_SIZE  x)
inline

Definition at line 95 of file activation_layer.cl.

References ABS_OP.

96 {
97  return ABS_OP(x);
98 }
#define ABS_OP(a)
DATA_TYPEVEC_SIZE brelu_op ( DATA_TYPEVEC_SIZE  x)
inline

Definition at line 75 of file activation_layer.cl.

References arm_compute::test::fixed_point_arithmetic::detail::max(), arm_compute::test::fixed_point_arithmetic::detail::min(), and TYPE.

76 {
77  return min((TYPE)A_VAL, max(0, x));
78 }
fixed_point< T > min(fixed_point< T > x, fixed_point< T > y)
Definition: FixedPoint.h:897
#define TYPE
fixed_point< T > max(fixed_point< T > x, fixed_point< T > y)
Definition: FixedPoint.h:902
DATA_TYPEVEC_SIZE linear_op ( DATA_TYPEVEC_SIZE  x)
inline

Definition at line 110 of file activation_layer.cl.

References MLA_OP, and TYPE.

111 {
112  return MLA_OP((TYPE)B_VAL, (TYPE)A_VAL, x);
113 }
#define TYPE
#define MLA_OP(a, b, c)
DATA_TYPEVEC_SIZE logistic_op ( DATA_TYPEVEC_SIZE  x)
inline

Definition at line 60 of file activation_layer.cl.

References ADD_OP, CONST_ONE, DIV_OP, EXP_OP, and TYPE.

61 {
62  return DIV_OP((TYPE)CONST_ONE, ADD_OP((TYPE)CONST_ONE, EXP_OP(-x)));
63 }
#define TYPE
#define ADD_OP(a, b)
#define EXP_OP(a)
#define CONST_ONE
#define DIV_OP(a, b)
DATA_TYPEVEC_SIZE lrelu_op ( DATA_TYPEVEC_SIZE  x)
inline

Definition at line 85 of file activation_layer.cl.

References MUL_OP, and TYPE.

86 {
87  return select(MUL_OP((TYPE)A_VAL, x), x, x > (TYPE)0);
88 }
#define TYPE
#define MUL_OP(a, b)
DATA_TYPEVEC_SIZE lu_brelu_op ( DATA_TYPEVEC_SIZE  x)
inline

Definition at line 80 of file activation_layer.cl.

References arm_compute::test::fixed_point_arithmetic::detail::max(), arm_compute::test::fixed_point_arithmetic::detail::min(), and TYPE.

81 {
82  return min(max(x, (TYPE)B_VAL), (TYPE)A_VAL);
83 }
fixed_point< T > min(fixed_point< T > x, fixed_point< T > y)
Definition: FixedPoint.h:897
#define TYPE
fixed_point< T > max(fixed_point< T > x, fixed_point< T > y)
Definition: FixedPoint.h:902
DATA_TYPEVEC_SIZE relu_op ( DATA_TYPEVEC_SIZE  x)
inline

Definition at line 70 of file activation_layer.cl.

References arm_compute::test::fixed_point_arithmetic::detail::max().

71 {
72  return max(0, x);
73 }
fixed_point< T > max(fixed_point< T > x, fixed_point< T > y)
Definition: FixedPoint.h:902
DATA_TYPEVEC_SIZE sqrt_op ( DATA_TYPEVEC_SIZE  x)
inline

Definition at line 105 of file activation_layer.cl.

References SQRT_OP.

106 {
107  return SQRT_OP(x);
108 }
#define SQRT_OP(a)
DATA_TYPEVEC_SIZE square_op ( DATA_TYPEVEC_SIZE  x)
inline

Definition at line 100 of file activation_layer.cl.

References MUL_OP.

101 {
102  return MUL_OP(x, x);
103 }
#define MUL_OP(a, b)
DATA_TYPEVEC_SIZE srelu_op ( DATA_TYPEVEC_SIZE  x)
inline

Definition at line 90 of file activation_layer.cl.

References ADD_OP, CONST_ONE, EXP_OP, LOG_OP, and TYPE.

91 {
92  return LOG_OP(ADD_OP((TYPE)CONST_ONE, EXP_OP(x)));
93 }
#define LOG_OP(a)
#define TYPE
#define ADD_OP(a, b)
#define EXP_OP(a)
#define CONST_ONE
DATA_TYPEVEC_SIZE tanh_op ( DATA_TYPEVEC_SIZE  x)
inline

Definition at line 65 of file activation_layer.cl.

References MUL_OP, TANH_OP, and TYPE.

66 {
67  return MUL_OP((TYPE)A_VAL, TANH_OP(MUL_OP((TYPE)B_VAL, x)));
68 }
#define TYPE
#define TANH_OP(a)
#define MUL_OP(a, b)