CMSIS-NN: Activation Functions

| CMSIS-NN Version 3.1.0 CMSIS NN Software Library

- Main Page
- Usage and Description
- Reference

All Data Structures Files Functions Variables Enumerations Enumerator Macros Groups Pages
Functions
Activation Functions
Neural Network Functions

## Functions

void | arm_nn_activations_direct_q15 (q15_t *data, uint16_t size, uint16_t int_width, arm_nn_activation_type type)
| neural network activation function using direct table look-up More...
void | arm_nn_activations_direct_q7 (q7_t *data, uint16_t size, uint16_t int_width, arm_nn_activation_type type)
| Q7 neural network activation function using direct table look-up. More...
void | arm_relu6_s8 (q7_t *data, uint16_t size)
| s8 ReLU6 function More...
void | arm_relu_q15 (q15_t *data, uint16_t size)
| Q15 RELU function. More...
void | arm_relu_q7 (q7_t *data, uint16_t size)
| Q7 RELU function. More...

## Description

Perform activation layers, including ReLU (Rectified Linear Unit), sigmoid and tanh

## Function Documentation

void arm_nn_activations_direct_q15 | ( | q15_t * | data,
|  | uint16_t | size,
|  | uint16_t | int_width,
|  | arm_nn_activation_type | type
| ) |  |

Q15 neural network activation function using direct table look-up.

Note
  Refer header file for details.

References ARM_SIGMOID, ARM_TANH, sigmoidTable_q15, and tanhTable_q15.

void arm_nn_activations_direct_q7 | ( | q7_t * | data,
|  | uint16_t | size,
|  | uint16_t | int_width,
|  | arm_nn_activation_type | type
| ) |  |

Parameters

  [in,out] | data | pointer to input
  [in] | size | number of elements
  [in] | int_width | bit-width of the integer part, assume to be smaller than 3
  [in] | type | type of activation functions

This is the direct table look-up approach.

Assume here the integer part of the fixed-point is <= 3. More than 3 just not making much sense, makes no difference with saturation followed by any of these activation functions.

References ARM_SIGMOID, ARM_TANH, sigmoidTable_q7, and tanhTable_q7.

void arm_relu6_s8 | ( | q7_t * | data,
|  | uint16_t | size
| ) |  |

Parameters

  [in,out] | data | pointer to input
  [in] | size | number of elements

References MAX, and MIN.

void arm_relu_q15 | ( | q15_t * | data,
|  | uint16_t | size
| ) |  |

Parameters

  [in,out] | data | pointer to input
  [in] | size | number of elements

Optimized relu with QSUB instructions.

References arm_nn_read_q15x2_ia(), and arm_nn_write_q15x2_ia().

void arm_relu_q7 | ( | q7_t * | data,
|  | uint16_t | size
| ) |  |

Parameters

  [in,out] | data | pointer to input
  [in] | size | number of elements

Optimized relu with QSUB instructions.

References arm_nn_read_q7x4_ia(), and arm_nn_write_q7x4_ia().