Compute Library
 22.08
activation_quant_helpers.h File Reference
#include "helpers.h"

Go to the source code of this file.

Macros

#define TYPE   VEC_DATA_TYPE(DATA_TYPE, VEC_SIZE)
 
#define ACTIVATION_OP2(op, x)   op##_op(x)
 
#define ACTIVATION_OP(op, x)   ACTIVATION_OP2(op, x)
 
#define PERFORM_ACTIVATION_QUANT(act, data)
 

Functions

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 hard_swish_op (DATA_TYPEVEC_SIZE x)
 
DATA_TYPEVEC_SIZE identiy_op (DATA_TYPEVEC_SIZE x)
 

Macro Definition Documentation

◆ ACTIVATION_OP

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

Definition at line 63 of file activation_quant_helpers.h.

◆ ACTIVATION_OP2

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

Definition at line 62 of file activation_quant_helpers.h.

◆ PERFORM_ACTIVATION_QUANT

#define PERFORM_ACTIVATION_QUANT (   act,
  data 
)
Value:
({ \
data = ACTIVATION_OP(act, data); \
})
#define ACTIVATION_OP(op, x)

Definition at line 90 of file activation_quant_helpers.h.

◆ TYPE

#define TYPE   VEC_DATA_TYPE(DATA_TYPE, VEC_SIZE)

Definition at line 27 of file activation_quant_helpers.h.

Referenced by brelu_op(), hard_swish_op(), lu_brelu_op(), and relu_op().

Function Documentation

◆ brelu_op()

DATA_TYPEVEC_SIZE brelu_op ( DATA_TYPEVEC_SIZE  x)
inline

Definition at line 42 of file activation_quant_helpers.h.

References TYPE.

43 {
44  return min((TYPE)A_VAL, max((TYPE)CONST_0, x));
45 }
#define TYPE

◆ hard_swish_op()

DATA_TYPEVEC_SIZE hard_swish_op ( DATA_TYPEVEC_SIZE  x)
inline

Definition at line 52 of file activation_quant_helpers.h.

References TYPE.

53 {
54  return (x * ((min(max((TYPE)(x + (TYPE)3.f), (TYPE)0.f), (TYPE)6.f)) * (TYPE)0.166666667f));
55 }
#define TYPE

◆ identiy_op()

DATA_TYPEVEC_SIZE identiy_op ( DATA_TYPEVEC_SIZE  x)
inline

Definition at line 57 of file activation_quant_helpers.h.

58 {
59  return x;
60 }

◆ lu_brelu_op()

DATA_TYPEVEC_SIZE lu_brelu_op ( DATA_TYPEVEC_SIZE  x)
inline

Definition at line 47 of file activation_quant_helpers.h.

References TYPE.

48 {
49  return min(max(x, (TYPE)B_VAL), (TYPE)A_VAL);
50 }
#define TYPE

◆ relu_op()

DATA_TYPEVEC_SIZE relu_op ( DATA_TYPEVEC_SIZE  x)
inline

Definition at line 37 of file activation_quant_helpers.h.

References TYPE.

38 {
39  return max((TYPE)CONST_0, x);
40 }
#define TYPE