CMSIS-NN  Version 1.2.0
CMSIS NN Software Library
 All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Macros Groups Pages
arm_nnsupportfunctions.h File Reference

Data Structures

union  arm_nnword
 Union for SIMD access of q31/q15/q7 types. More...
 

Macros

#define LEFT_SHIFT(_shift)
 
#define RIGHT_SHIFT(_shift)
 
#define MASK_IF_ZERO(x)
 
#define MASK_IF_NON_ZERO(x)
 
#define SELECT_USING_MASK(mask, a, b)
 
#define MAX(A, B)
 
#define MIN(A, B)
 
#define CLAMP(x, h, l)
 
#define NN_ROUND(out_shift)
 macro for adding rounding offset More...
 
#define MUL_SAT(a, b)
 
#define MUL_POW2(a, b)
 
#define DIV_POW2(a, b)
 
#define EXP_ON_NEG(x)
 
#define ONE_OVER1(x)
 
#define SELECT_IF_NON_ZERO(x)
 

Enumerations

enum  arm_nn_activation_type
 Struct for specifying activation function types. More...
 

Functions

void arm_q7_to_q15_no_shift (const q7_t *pSrc, q15_t *pDst, uint32_t blockSize)
 Converts the elements of the q7 vector to q15 vector without left-shift. More...
 
void arm_nn_add_q7 (const q7_t *input, q31_t *output, uint32_t block_size)
 Non-saturating addition of elements of a q7 vector. More...
 
void arm_q7_to_q15_reordered_no_shift (const q7_t *pSrc, q15_t *pDst, uint32_t blockSize)
 Converts the elements of the q7 vector to reordered q15 vector without left-shift. More...
 
void arm_q7_to_q15_with_offset (const q7_t *src, q15_t *dst, uint32_t block_size, q7_t offset)
 Converts the elements from a q7 vector to a q15 vector with an added offset. More...
 
void arm_q7_to_q15_reordered_with_offset (const q7_t *src, q15_t *dst, uint32_t block_size, q7_t offset)
 Converts the elements of the q7 vector to reordered q15 vector with an added offset. More...
 
void arm_nn_accumulate_q7_to_q15 (q15_t *dst, const q7_t *src, uint32_t block_size)
 Converts the elements from a q7 vector and accumulate to a q15 vector. More...
 
__STATIC_FORCEINLINE q31_t arm_nn_read_q15x2_ia (const q15_t **in_q15)
 Read 2 q15 elements and post increment pointer. More...
 
__STATIC_FORCEINLINE q31_t arm_nn_read_q7x4_ia (const q7_t **in_q7)
 Read 4 q7 from q7 pointer and post increment pointer. More...
 
__STATIC_FORCEINLINE q31_t arm_nn_read_q15x2 (const q15_t *in_q15)
 Read 2 q15 from q15 pointer. More...
 
__STATIC_FORCEINLINE q31_t arm_nn_read_q7x4 (const q7_t *in_q7)
 Read 4 q7 values. More...
 
void arm_nn_mult_q15 (q15_t *pSrcA, q15_t *pSrcB, q15_t *pDst, const uint16_t out_shift, uint32_t blockSize)
 q7 vector multiplication with variable output shifts More...
 
void arm_nn_mult_q7 (q7_t *pSrcA, q7_t *pSrcB, q7_t *pDst, const uint16_t out_shift, uint32_t blockSize)
 q7 vector multiplication with variable output shifts More...
 
__STATIC_FORCEINLINE q31_t arm_nn_sat_doubling_high_mult (const q31_t m1, const q31_t m2)
 Saturating doubling high multiply. Result matches NEON instruction VQRDMULH. More...
 
__STATIC_FORCEINLINE q31_t arm_nn_divide_by_power_of_two (const q31_t dividend, const q31_t exponent)
 Rounding divide by power of two. More...
 
__STATIC_FORCEINLINE q31_t arm_nn_requantize (const q31_t val, const q31_t multiplier, const q31_t shift)
 Requantize a given value. More...
 
__STATIC_FORCEINLINE int32_t arm_nn_exp_on_negative_values (int32_t val)
 
__STATIC_FORCEINLINE q31_t arm_nn_mult_by_power_of_two (const int32_t val, const int32_t exp)
 
__STATIC_FORCEINLINE int32_t arm_nn_one_over_one_plus_x_for_x_in_0_1 (int32_t val)
 

Macro Definition Documentation

#define CLAMP (   x,
  h,
 
)

Referenced by arm_softmax_s8().

#define DIV_POW2 (   a,
 
)
#define EXP_ON_NEG (   x)

Referenced by arm_softmax_s8().

#define LEFT_SHIFT (   _shift)
#define MASK_IF_NON_ZERO (   x)
#define MASK_IF_ZERO (   x)
#define MUL_POW2 (   a,
 
)
#define ONE_OVER1 (   x)

Referenced by arm_softmax_s8().

#define RIGHT_SHIFT (   _shift)
#define SELECT_IF_NON_ZERO (   x)
#define SELECT_USING_MASK (   mask,
  a,
 
)

Enumeration Type Documentation

Enumerator
ARM_SIGMOID 

Sigmoid activation function

ARM_TANH 

Tanh activation function

Function Documentation

__STATIC_FORCEINLINE q31_t arm_nn_divide_by_power_of_two ( const q31_t  dividend,
const q31_t  exponent 
)
Parameters
[in]dividend- Dividend
[in]exponent- Divisor = power(2, exponent) Range: [0, 31]
Returns
Rounded result of division. Midpoint is rounded away from zero.

Referenced by arm_depthwise_conv_u8_basic_ver1(), arm_elementwise_add_s8(), arm_elementwise_mul_s8(), arm_fully_connected_s8(), and arm_nn_requantize().

__STATIC_FORCEINLINE int32_t arm_nn_exp_on_negative_values ( int32_t  val)
__STATIC_FORCEINLINE q31_t arm_nn_mult_by_power_of_two ( const int32_t  val,
const int32_t  exp 
)
__STATIC_FORCEINLINE int32_t arm_nn_one_over_one_plus_x_for_x_in_0_1 ( int32_t  val)

References MUL_POW2, and MUL_SAT.

__STATIC_FORCEINLINE q31_t arm_nn_read_q15x2 ( const q15_t *  in_q15)
Parameters
[in]in_q15pointer to address of input.
Returns
q31 value

Referenced by arm_depthwise_conv_s8_opt(), and arm_nn_accumulate_q7_to_q15().

__STATIC_FORCEINLINE q31_t arm_nn_read_q15x2_ia ( const q15_t **  in_q15)
Parameters
[in]in_q15Pointer to pointer that holds address of input.
Returns
q31 value

Referenced by arm_convolve_1x1_s8_fast(), arm_convolve_s8(), arm_nn_mat_mult_kernel_s8_s16(), and arm_nn_mat_mult_kernel_s8_s16_reordered().

__STATIC_FORCEINLINE q31_t arm_nn_read_q7x4 ( const q7_t *  in_q7)
Parameters
[in]in_q7pointer to address of input.
Returns
q31 value

Referenced by arm_depthwise_conv_s8_opt().

__STATIC_FORCEINLINE q31_t arm_nn_read_q7x4_ia ( const q7_t **  in_q7)
__STATIC_FORCEINLINE q31_t arm_nn_requantize ( const q31_t  val,
const q31_t  multiplier,
const q31_t  shift 
)
Parameters
[in]valValue to be requantized
[in]multipliermultiplier
[in]shiftleft or right shift for 'val * multiplier'
Returns
Returns (val * multiplier)/(2 ^ shift)

References arm_nn_divide_by_power_of_two(), arm_nn_sat_doubling_high_mult(), LEFT_SHIFT, and RIGHT_SHIFT.

Referenced by arm_convolve_1x1_s8_fast(), arm_convolve_s8(), arm_depthwise_conv_s8(), arm_depthwise_conv_s8_opt(), arm_nn_mat_mult_kernel_s8_s16(), and arm_nn_mat_mult_kernel_s8_s16_reordered().

__STATIC_FORCEINLINE q31_t arm_nn_sat_doubling_high_mult ( const q31_t  m1,
const q31_t  m2 
)
Parameters
[in]m1Multiplicand
[in]m2Multiplier
Returns
Result of multiplication.

Referenced by arm_depthwise_conv_u8_basic_ver1(), arm_elementwise_add_s8(), arm_elementwise_mul_s8(), arm_fully_connected_s8(), and arm_nn_requantize().