HPM SDK
HPMicro Software Development Kit

The softmax functions are exponential functions with base 2. More...

Functions

static void hpm_nn_softmax_s8_fast (const q7_t *in_vec, const uint16_t size, q7_t *out_vec)
 This is a softmax function for signed 8-bit integer input vectors. More...
 
static void hpm_nn_softmax_s16_fast (const q15_t *in_vec, const uint16_t size, q15_t *out_vec)
 This is a softmax function for signed 16-bit integer input vectors. More...
 
static void hpm_nn_softmax_s8_hp (const int8_t *in_tensor, const int32_t in_tensor_row, const int32_t in_tensor_col, const int32_t scale, const int32_t lshift, const int32_t diff_min, int8_t *out_tensor)
 This is a softmax function for signed 8-bit integer input tensor with high precision algorithm. More...
 
static void hpm_nn_softmax_u8_hp (const uint8_t *in_tensor, const int32_t in_tensor_row, const int32_t in_tensor_col, const int32_t scale, const int32_t lshift, const int32_t diff_min, uint8_t *out_tensor)
 This is a softmax function for unsigned 8-bit integer input tensor with high precision algorithm. More...
 

Detailed Description

The softmax functions are exponential functions with base 2.

Function Documentation

◆ hpm_nn_softmax_s16_fast()

static void hpm_nn_softmax_s16_fast ( const q15_t *  in_vec,
const uint16_t  size,
q15_t *  out_vec 
)
inlinestatic

#include <middleware/hpm_math/hpm_math.h>

This is a softmax function for signed 16-bit integer input vectors.

Parameters
[in]in_vecpointer of the input vector
[in]sizenumber of elements in the input vector
[out]out_vecpointer of the output vector

◆ hpm_nn_softmax_s8_fast()

static void hpm_nn_softmax_s8_fast ( const q7_t *  in_vec,
const uint16_t  size,
q7_t *  out_vec 
)
inlinestatic

#include <middleware/hpm_math/hpm_math.h>

This is a softmax function for signed 8-bit integer input vectors.

Parameters
[in]in_vecpointer of the input vector
[in]sizenumber of elements in the input vector
[out]out_vecpointer of the output vector

Example:

#define LENGTH 10
q7_t in_data[LENGTH] = {...};
q7_t out_data[LENGTH];
hpm_nn_softmax_s8_fast(in_data, LENGTH, out_data);
static void hpm_nn_softmax_s8_fast(const q7_t *in_vec, const uint16_t size, q7_t *out_vec)
This is a softmax function for signed 8-bit integer input vectors.
Definition: hpm_math.h:15913

◆ hpm_nn_softmax_s8_hp()

static void hpm_nn_softmax_s8_hp ( const int8_t *  in_tensor,
const int32_t  in_tensor_row,
const int32_t  in_tensor_col,
const int32_t  scale,
const int32_t  lshift,
const int32_t  diff_min,
int8_t *  out_tensor 
)
inlinestatic

#include <middleware/hpm_math/hpm_math.h>

This is a softmax function for signed 8-bit integer input tensor with high precision algorithm.

Parameters
[in]in_tensorpointer of the input tensor
[in]in_tensor_rownumber of rows in the input tensor
[in]in_tensor_colnumber of columns in the input tensor
[in]scalescaling value for input quantization
[in]lshiftleft shift amount for input quantization
[in]diff_minminimum threshold to perform the quantized exponential operation. The difference can be obtained by subtracting the input from the maximum in row.
[out]out_tensorpointer of the output tensor

◆ hpm_nn_softmax_u8_hp()

static void hpm_nn_softmax_u8_hp ( const uint8_t *  in_tensor,
const int32_t  in_tensor_row,
const int32_t  in_tensor_col,
const int32_t  scale,
const int32_t  lshift,
const int32_t  diff_min,
uint8_t *  out_tensor 
)
inlinestatic

#include <middleware/hpm_math/hpm_math.h>

This is a softmax function for unsigned 8-bit integer input tensor with high precision algorithm.

Parameters
[in]in_tensorpointer of the input tensor
[in]in_tensor_rownumber of rows in the input tensor
[in]in_tensor_colnumber of columns in the input tensor
[in]scalescaling value for input quantization
[in]lshiftleft shift amount for input quantization
[in]diff_minminimum threshold to perform the quantized exponential operation. The difference can be obtained by subtracting the input from the maximum in row.
[out]out_tensorpointer of the output tensor