Neural Network Activation Functions

void riscv_nn_activations_direct_q15(q15_t *data, uint16_t size, uint16_t int_width, riscv_nn_activation_type type)
void riscv_nn_activations_direct_q7(q7_t *data, uint16_t size, uint16_t int_width, riscv_nn_activation_type type)
void riscv_relu_q15(q15_t *data, uint16_t size)
void riscv_relu_q7(q7_t *data, uint16_t size)
group Acti

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

Functions

void riscv_nn_activations_direct_q15(q15_t *data, uint16_t size, uint16_t int_width, riscv_nn_activation_type type)

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

This is the direct table look-up approach.

Return

none.

Parameters
  • [inout] 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

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.

void riscv_nn_activations_direct_q7(q7_t *data, uint16_t size, uint16_t int_width, riscv_nn_activation_type type)

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

This is the direct table look-up approach.

Return

none.

Parameters
  • [inout] 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

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.

void riscv_relu_q15(q15_t *data, uint16_t size)

Q15 RELU function.

Optimized relu with QSUB instructions.

Return

none.

Parameters
  • [inout] data: pointer to input

  • [in] size: number of elements

void riscv_relu_q7(q7_t *data, uint16_t size)

Q7 RELU function.

Optimized relu with QSUB instructions.

Return

none.

Parameters
  • [inout] data: pointer to input

  • [in] size: number of elements