HPM SDK
HPMicro Software Development Kit
NN Fully Connected Functions

The fully connected functions multiply the input vector by a weight matrix and add a bias, if any, to the result. The supported combinations of input vector and weight matrix are (signed 8-bit integer, signed 8-bit integer), (unsigned 8-bit integer, signed 8-bit integer), (signed 16-bit integer, signed 8-bit integer), (signed 16-bit integer, signed 16-bit integer) and (16-bit half-precision floating point, 16-bit half-precision floating point). More...

Functions

static int32_t hpm_nn_fc_s8_s8_s8_sft_bias (const q7_t *in_vec, const q7_t *wt_mat, const uint16_t size, const uint16_t wt_row_num, const uint16_t bias_lshift, const uint16_t out_rshift, const q7_t *bias, q7_t *out_vec, q15_t *in_tmp_buf) return riscv_nn_fc_s8_s8_s8_sft_bias(in_vec
 This is a fully connected layer function for signed 8-bit integer inputs with shift-based quantization on the outputs. More...
 
static int32_t hpm_nn_fc_s8_s8_s8_sft_bias_fast (const q7_t *in_vec, const q7_t *wt_mat, const uint16_t size, const uint16_t wt_row_num, const uint16_t bias_lshift, const uint16_t out_rshift, const q7_t *bias, q7_t *out_vec, q15_t *in_tmp_buf)
 This is a fully connected layer function for signed 8-bit integer inputs with interleaved multiplication and shift-based quantization on the outputs. More...
 
static int32_t hpm_nn_fc_s16_s16_s16_sft_bias (const q15_t *in_vec, const q15_t *wt_mat, const uint16_t size, const uint16_t wt_row_num, const uint16_t bias_lshift, const uint16_t out_rshift, const q15_t *bias, q15_t *out_vec, q15_t *tmp_buf)
 This is a fully connected layer function for signed 16-bit integer inputs with shift-based quantization on the outputs. More...
 
static int32_t hpm_nn_fc_s16_s16_s16_sft_bias_fast (const q15_t *in_vec, const q15_t *wt_mat, const uint16_t size, const uint16_t wt_row_num, const uint16_t bias_lshift, const uint16_t out_rshift, const q15_t *bias, q15_t *out_vec, q15_t *in_tmp_buf)
 This is a fully connected layer function for signed 16-bit integer inputs with interleaved multiplication and shift-based quantization on the outputs. More...
 
static int32_t hpm_nn_fc_mat_vec_s16_s16_s8_sft_bias (const q15_t *in_vec, const q7_t *wt_mat, const uint16_t size, const uint16_t wt_row_num, const uint16_t bias_lshift, const uint16_t out_rshift, const q7_t *bias, q15_t *out_vec, q15_t *tmp_buf)
 This function multiplies a signed 16-bit integer input vector by a signed 8-bit integer weight matrix with shift-based quantization on the outputs. More...
 
static int32_t hpm_nn_fc_mat_vec_s16_s16_s8_sft_bias_fast (const q15_t *in_vec, const q7_t *wt_mat, const uint16_t size, const uint16_t wt_row_num, const uint16_t bias_lshift, const uint16_t out_rshift, const q7_t *bias, q15_t *out_vec, q15_t *tmp_buf)
 This function multiplies a signed 16-bit integer input vector by a signed 8-bit integer weight matrix with interleaved multiplication and shift-based quantization on the outputs. More...
 
static int32_t hpm_nn_fc_s8_s8_s8_sym_bias (const q7_t *in_vec, const q7_t *wt_mat, const uint16_t size, const uint16_t wt_row_num, const uint16_t pre_rshift, const uint16_t out_scale, const uint16_t post_rshift, const q31_t *bias, q7_t *out_vec, q15_t *in_tmp_buf)
 This is a fully connected layer function for signed 8-bit integer inputs/outputs with bias inputs and symmetric quantization on the outputs. More...
 
static int32_t hpm_nn_fc_s8_s16_s8_sym_bias (const q7_t *in_vec, const q7_t *wt_mat, const uint16_t size, const uint16_t wt_row_num, const uint16_t pre_rshift, const uint16_t out_scale, const uint16_t post_rshift, const q31_t *bias, q15_t *out_vec, q15_t *in_tmp_buf)
 This is a fully connected layer function for signed 8-bit integer inputs and signed 16-bit integer outputs with bias inputs and symmetric quantization on the outputs. More...
 
static int32_t hpm_nn_fc_u8_u8_s8_sym_bias (const u8_t *in_vec, const q7_t *wt_mat, const uint16_t size, const uint16_t wt_row_num, const uint16_t pre_rshift, const uint16_t out_scale, const uint16_t post_rshift, const q31_t *bias, u8_t *out_vec, q15_t *in_tmp_buf)
 This is a fully connected layer function for unsigned 8-bit integer inputs/outputs with bias inputs and symmetric quantization on the outputs. More...
 
static int32_t hpm_nn_fc_u8_s8_s8_sym_bias (const u8_t *in_vec, const q7_t *wt_mat, const uint16_t size, const uint16_t wt_row_num, const uint16_t pre_rshift, const uint16_t out_scale, const uint16_t post_rshift, const q31_t *bias, q7_t *out_vec, q15_t *in_tmp_buf)
 This is a fully connected layer function for unsigned 8-bit integer inputs and signed 8-bit integer outputs with bias inputs and symmetric quantization on the outputs. More...
 
static int32_t hpm_nn_fc_u8_s16_s8_sym_bias (const u8_t *in_vec, const q7_t *wt_mat, const uint16_t size, const uint16_t wt_row_num, const uint16_t pre_rshift, const uint16_t out_scale, const uint16_t post_rshift, const q31_t *bias, q15_t *out_vec, q15_t *in_tmp_buf)
 This is a fully connected layer function for unsigned 8-bit integer inputs and signed 16-bit integer outputs with bias inputs and symmetric quantization on the outputs. More...
 
static int32_t hpm_nn_fc_s8_s8_s8_sym (const q7_t *in_vec, const q7_t *wt_mat, const uint16_t size, const uint16_t wt_row_num, const uint16_t pre_rshift, const uint16_t out_scale, const uint16_t post_rshift, q7_t *out_vec, q15_t *in_tmp_buf)
 This is a fully connected layer function for signed 8-bit integer inputs/outputs with symmetric quantization on the outputs. More...
 
static int32_t hpm_nn_fc_s8_s16_s8_sym (const q7_t *in_vec, const q7_t *wt_mat, const uint16_t size, const uint16_t wt_row_num, const uint16_t pre_rshift, const uint16_t out_scale, const uint16_t post_rshift, q15_t *out_vec, q15_t *in_tmp_buf)
 This is a fully connected layer function for signed 8-bit integer inputs and signed 16-bit integer outputs with symmetric quantization on the outputs. More...
 
static int32_t hpm_nn_fc_u8_u8_s8_sym (const u8_t *in_vec, const q7_t *wt_mat, const uint16_t size, const uint16_t wt_row_num, const uint16_t pre_rshift, const uint16_t out_scale, const uint16_t post_rshift, u8_t *out_vec, q15_t *in_tmp_buf)
 This is a fully connected layer function for unsigned 8-bit integer inputs/outputs with symmetric quantization on the outputs. More...
 
static int32_t hpm_nn_fc_u8_s8_s8_sym (const u8_t *in_vec, const q7_t *wt_mat, const uint16_t size, const uint16_t wt_row_num, const uint16_t pre_rshift, const uint16_t out_scale, const uint16_t post_rshift, q7_t *out_vec, q15_t *in_tmp_buf)
 This is a fully connected layer function for unsigned 8-bit integer inputs and signed 8-bit integer outputs with symmetric quantization on the outputs. More...
 
static int32_t hpm_nn_fc_u8_s16_s8_sym (const u8_t *in_vec, const q7_t *wt_mat, const uint16_t size, const uint16_t wt_row_num, const uint16_t pre_rshift, const uint16_t out_scale, const uint16_t post_rshift, q15_t *out_vec, q15_t *in_tmp_buf)
 This is a fully connected layer function for unsigned 8-bit integer inputs and signed 16-bit integer outputs with symmetric quantization on the outputs. More...
 
static int32_t hpm_nn_fc_s8_s8_s8_sym_bias_fast (const q7_t *in_vec, const q7_t *wt_mat, const uint16_t size, const uint16_t wt_row_num, const uint16_t pre_rshift, const uint16_t out_scale, const uint16_t post_rshift, const q31_t *bias, q7_t *out_vec, q15_t *in_tmp_buf)
 This is a fully connected layer function for signed 8-bit integer inputs/outputs with bias inputs, interleaved multiplication and symmetric quantization on the outputs. More...
 
static int32_t hpm_nn_fc_s8_s16_s8_sym_bias_fast (const q7_t *in_vec, const q7_t *wt_mat, const uint16_t size, const uint16_t wt_row_num, const uint16_t pre_rshift, const uint16_t out_scale, const uint16_t post_rshift, const q31_t *bias, q15_t *out_vec, q15_t *in_tmp_buf)
 This is a fully connected layer function for signed 8-bit integer inputs and signed 16-bit integer outputs with bias inputs, interleaved multiplication and symmetric quantization on the outputs. More...
 
static int32_t hpm_nn_fc_u8_u8_s8_sym_bias_fast (const u8_t *in_vec, const q7_t *wt_mat, const uint16_t size, const uint16_t wt_row_num, const uint16_t pre_rshift, const uint16_t out_scale, const uint16_t post_rshift, const q31_t *bias, u8_t *out_vec, q15_t *in_tmp_buf)
 This is a fully connected layer function for unsigned 8-bit integer inputs/outputs with bias inputs, interleaved multiplication and symmetric quantization on the outputs. More...
 
static int32_t hpm_nn_fc_u8_s8_s8_sym_bias_fast (const u8_t *in_vec, const q7_t *wt_mat, const uint16_t size, const uint16_t wt_row_num, const uint16_t pre_rshift, const uint16_t out_scale, const uint16_t post_rshift, const q31_t *bias, q7_t *out_vec, q15_t *in_tmp_buf)
 This is a fully connected layer function for unsigned 8-bit integer inputs and signed 8-bit integer outputs with bias inputs, interleaved multiplication and symmetric quantization on the outputs. More...
 
static int32_t hpm_nn_fc_u8_s16_s8_sym_bias_fast (const u8_t *in_vec, const q7_t *wt_mat, const uint16_t size, const uint16_t wt_row_num, const uint16_t pre_rshift, const uint16_t out_scale, const uint16_t post_rshift, const q31_t *bias, q15_t *out_vec, q15_t *in_tmp_buf)
 This is a fully connected layer function for unsigned 8-bit integer inputs and signed 16-bit integer outputs with bias inputs, interleaved multiplication and symmetric quantization on the outputs. More...
 
static int32_t hpm_nn_fc_s8_s8_s8_sym_fast (const q7_t *in_vec, const q7_t *wt_mat, const uint16_t size, const uint16_t wt_row_num, const uint16_t pre_rshift, const uint16_t out_scale, const uint16_t post_rshift, q7_t *out_vec, q15_t *in_tmp_buf)
 This is a fully connected layer function for signed 8-bit integer inputs/outputs with interleaved multiplication and symmetric quantization on the outputs. More...
 
static int32_t hpm_nn_fc_s8_s16_s8_sym_fast (const q7_t *in_vec, const q7_t *wt_mat, const uint16_t size, const uint16_t wt_row_num, const uint16_t pre_rshift, const uint16_t out_scale, const uint16_t post_rshift, q15_t *out_vec, q15_t *in_tmp_buf)
 This is a fully connected layer function for signed 8-bit integer inputs and signed 16-bit integer outputs with interleaved multiplication and symmetric quantization on the outputs. More...
 
static int32_t hpm_nn_fc_u8_u8_s8_sym_fast (const u8_t *in_vec, const q7_t *wt_mat, const uint16_t size, const uint16_t wt_row_num, const uint16_t pre_rshift, const uint16_t out_scale, const uint16_t post_rshift, u8_t *out_vec, q15_t *in_tmp_buf)
 This is a fully connected layer function for unsigned 8-bit integer inputs/outputs with interleaved multiplication and symmetric quantization on the outputs. More...
 
static int32_t hpm_nn_fc_u8_s8_s8_sym_fast (const u8_t *in_vec, const q7_t *wt_mat, const uint16_t size, const uint16_t wt_row_num, const uint16_t pre_rshift, const uint16_t out_scale, const uint16_t post_rshift, q7_t *out_vec, q15_t *in_tmp_buf)
 This is a fully connected layer function for unsigned 8-bit integer inputs and signed 8-bit integer outputs with interleaved multiplication and symmetric quantization on the outputs. More...
 
static int32_t hpm_nn_fc_u8_s16_s8_sym_fast (const u8_t *in_vec, const q7_t *wt_mat, const uint16_t size, const uint16_t wt_row_num, const uint16_t pre_rshift, const uint16_t out_scale, const uint16_t post_rshift, q15_t *out_vec, q15_t *in_tmp_buf)
 This is a fully connected layer function for unsigned 8-bit integer inputs and signed 16-bit integer outputs with interleaved multiplication and symmetric quantization on the outputs. More...
 
static void hpm_nn_fc_s8_wt_converter (const q7_t *wt_mat, const uint32_t size, const uint32_t wt_row_num, q7_t *wt_mat_out)
 This is a weight converter for those fully-connected functions with signed 8-bit weight data and named with "fast". More...
 
static void hpm_nn_fc_s16_wt_converter (const q15_t *wt_mat, const uint32_t size, const uint32_t wt_row_num, q15_t *wt_mat_out)
 This is a weight converter for those fully-connected functions with signed 16-bit weight data and named with "fast". More...
 
static void hpm_nn_fc_mat_vec_s8_wt_converter (const q7_t *wt_mat, const uint32_t size, const uint32_t wt_row_num, q7_t *wt_mat_out)
 This is a weight converter for riscv_nn_fc_mat_vec_s16_s16_s8_sft_bias_fast. More...
 
static int32_t hpm_nn_fc_s8_s8_s8_asym_bias (const int8_t *in_vec, const int8_t *wt_mat, const uint16_t in_vec_col, const uint16_t wt_mat_row, const uint16_t in_vec_group, const int32_t in_offset, const int32_t wt_offset, const int32_t out_scale, const int32_t out_shift, const int32_t out_offset, const int32_t *bias, int8_t *out_vec, const int32_t act_min, const int32_t act_max, q15_t *tmp_buf)
 This is a fully connected layer function for signed 8-bit integer inputs with bias inputs and asymmetric quantization on the outputs. More...
 
static int32_t hpm_nn_fc_s8_s8_s8_asym_bias_get_buffer_size (const uint16_t in_vec_col)
 This function is used to get the needed size, in bytes, by the temporary buffer of riscv_nn_fc_s8_s8_s8_asym_bias. More...
 

Variables

static int32_t wt_mat
 
static int32_t wt_row_num
 
static int32_t bias_lshift
 
static int32_t out_rshift
 
static int32_t bias
 
static int32_t out_vec
 
static int32_t in_tmp_buf
 

Detailed Description

The fully connected functions multiply the input vector by a weight matrix and add a bias, if any, to the result. The supported combinations of input vector and weight matrix are (signed 8-bit integer, signed 8-bit integer), (unsigned 8-bit integer, signed 8-bit integer), (signed 16-bit integer, signed 8-bit integer), (signed 16-bit integer, signed 16-bit integer) and (16-bit half-precision floating point, 16-bit half-precision floating point).

Function Documentation

◆ hpm_nn_fc_mat_vec_s16_s16_s8_sft_bias()

static int32_t hpm_nn_fc_mat_vec_s16_s16_s8_sft_bias ( const q15_t *  in_vec,
const q7_t *  wt_mat,
const uint16_t  size,
const uint16_t  wt_row_num,
const uint16_t  bias_lshift,
const uint16_t  out_rshift,
const q7_t *  bias,
q15_t *  out_vec,
q15_t *  tmp_buf 
)
inlinestatic

#include <middleware/hpm_math/hpm_math.h>

This function multiplies a signed 16-bit integer input vector by a signed 8-bit integer weight matrix with shift-based quantization on the outputs.

Parameters
[in]in_vecpointer of the input vector
[in]wt_matpointer of the weight matrix
[in]sizenumber of elements in the input vector
[in]wt_row_numnumber of rows in the weight matrix
[in]bias_lshiftleft shift amount for the bias
[in]out_rshiftright shift amount for the output
[in]biaspointer of the bias
[out]out_vecpointer of the output vector
[in]tmp_bufdummy
Returns
This function only returns 0.

◆ hpm_nn_fc_mat_vec_s16_s16_s8_sft_bias_fast()

static int32_t hpm_nn_fc_mat_vec_s16_s16_s8_sft_bias_fast ( const q15_t *  in_vec,
const q7_t *  wt_mat,
const uint16_t  size,
const uint16_t  wt_row_num,
const uint16_t  bias_lshift,
const uint16_t  out_rshift,
const q7_t *  bias,
q15_t *  out_vec,
q15_t *  tmp_buf 
)
inlinestatic

#include <middleware/hpm_math/hpm_math.h>

This function multiplies a signed 16-bit integer input vector by a signed 8-bit integer weight matrix with interleaved multiplication and shift-based quantization on the outputs.

Parameters
[in]in_vecpointer of the input vector
[in]wt_matpointer of the weight matrix
[in]sizenumber of elements in the input vector
[in]wt_row_numnumber of rows in the weight matrix
[in]bias_lshiftleft shift amount for the bias
[in]out_rshiftright shift amount for the output
[in]biaspointer of the bias
[out]out_vecpointer of the output vector
[in]tmp_bufdummy
Returns
This function only returns 0.
Note
In this function, the input vector is multiplied by a weight matrix in interleaved formats which could be obtained by hpm_nn_fc_mat_vec_s8_wt_converter.

◆ hpm_nn_fc_mat_vec_s8_wt_converter()

static void hpm_nn_fc_mat_vec_s8_wt_converter ( const q7_t *  wt_mat,
const uint32_t  size,
const uint32_t  wt_row_num,
q7_t *  wt_mat_out 
)
inlinestatic

#include <middleware/hpm_math/hpm_math.h>

This is a weight converter for riscv_nn_fc_mat_vec_s16_s16_s8_sft_bias_fast.

Parameters
[in]wt_matpointer of the weight matrix
[in]sizenumber of elements in the input vector
[in]wt_row_numnumber of rows in the weight matrix
[out]wt_mat_outpointer of the weight matrix stored in specific ordering

◆ hpm_nn_fc_s16_s16_s16_sft_bias()

static int32_t hpm_nn_fc_s16_s16_s16_sft_bias ( const q15_t *  in_vec,
const q15_t *  wt_mat,
const uint16_t  size,
const uint16_t  wt_row_num,
const uint16_t  bias_lshift,
const uint16_t  out_rshift,
const q15_t *  bias,
q15_t *  out_vec,
q15_t *  tmp_buf 
)
inlinestatic

#include <middleware/hpm_math/hpm_math.h>

This is a fully connected layer function for signed 16-bit integer inputs with shift-based quantization on the outputs.

Parameters
[in]in_vecpointer of the input vector
[in]wt_matpointer of the weight matrix
[in]sizenumber of elements in the input vector
[in]wt_row_numnumber of rows in the weight matrix
[in]bias_lshiftleft shift amount for the bias
[in]out_rshiftright shift amount for the output
[in]biaspointer of the bias
[out]out_vecpointer of the output vector
[in]tmp_bufdummy
Returns
This function only returns 0.

◆ hpm_nn_fc_s16_s16_s16_sft_bias_fast()

static int32_t hpm_nn_fc_s16_s16_s16_sft_bias_fast ( const q15_t *  in_vec,
const q15_t *  wt_mat,
const uint16_t  size,
const uint16_t  wt_row_num,
const uint16_t  bias_lshift,
const uint16_t  out_rshift,
const q15_t *  bias,
q15_t *  out_vec,
q15_t *  in_tmp_buf 
)
inlinestatic

#include <middleware/hpm_math/hpm_math.h>

This is a fully connected layer function for signed 16-bit integer inputs with interleaved multiplication and shift-based quantization on the outputs.

Parameters
[in]in_vecpointer of the input vector
[in]wt_matpointer of the weight matrix
[in]sizenumber of elements in the input vector
[in]wt_row_numnumber of rows in the weight matrix
[in]bias_lshiftleft shift amount for the bias
[in]out_rshiftright shift amount for the output
[in]biaspointer of the bias
[out]out_vecpointer of the output vector
[in]in_tmp_buftemporary buffer for input vector. It is required when -mext-vector is enabled and its size must be 4 * size.
Returns
This function only returns 0.
Note
In this function, the input vector is multiplied by a weight matrix in interleaved formats which could be obtained by riscv_nn_fc_s16_wt_converter.

◆ hpm_nn_fc_s16_wt_converter()

static void hpm_nn_fc_s16_wt_converter ( const q15_t *  wt_mat,
const uint32_t  size,
const uint32_t  wt_row_num,
q15_t *  wt_mat_out 
)
inlinestatic

#include <middleware/hpm_math/hpm_math.h>

This is a weight converter for those fully-connected functions with signed 16-bit weight data and named with "fast".

Parameters
[in]wt_matpointer of the weight matrix
[in]sizenumber of elements in the input vector
[in]wt_row_numnumber of rows in the weight matrix
[out]wt_mat_outpointer of the weight matrix stored in specific ordering

◆ hpm_nn_fc_s8_s16_s8_sym()

static int32_t hpm_nn_fc_s8_s16_s8_sym ( const q7_t *  in_vec,
const q7_t *  wt_mat,
const uint16_t  size,
const uint16_t  wt_row_num,
const uint16_t  pre_rshift,
const uint16_t  out_scale,
const uint16_t  post_rshift,
q15_t *  out_vec,
q15_t *  in_tmp_buf 
)
inlinestatic

#include <middleware/hpm_math/hpm_math.h>

This is a fully connected layer function for signed 8-bit integer inputs and signed 16-bit integer outputs with symmetric quantization on the outputs.

Parameters
[in]in_vecpointer of the input vector
[in]wt_matpointer of the weight matrix
[in]sizenumber of elements in the input vector
[in]wt_row_numnumber of rows in the weight matrix
[in]pre_rshiftright shift amount for the output before the scaling
[in]out_scalescaling value for the output
[in]post_rshiftright shift amount for the output after the scaling
[out]out_vecpointer of the output vector
[in]in_tmp_buftemporary buffer for input vector. It is required when -mext-dsp is enabled and its size must be "size".
Returns
This function only returns 0.
Note
The outputs will be two-stage shifted before being stored, i.e., out = ((out >> pre_rshift) *out_scale) >> post_rshift.

◆ hpm_nn_fc_s8_s16_s8_sym_bias()

static int32_t hpm_nn_fc_s8_s16_s8_sym_bias ( const q7_t *  in_vec,
const q7_t *  wt_mat,
const uint16_t  size,
const uint16_t  wt_row_num,
const uint16_t  pre_rshift,
const uint16_t  out_scale,
const uint16_t  post_rshift,
const q31_t *  bias,
q15_t *  out_vec,
q15_t *  in_tmp_buf 
)
inlinestatic

#include <middleware/hpm_math/hpm_math.h>

This is a fully connected layer function for signed 8-bit integer inputs and signed 16-bit integer outputs with bias inputs and symmetric quantization on the outputs.

Parameters
[in]in_vecpointer of the input vector
[in]wt_matpointer of the weight matrix
[in]sizenumber of elements in the input vector
[in]wt_row_numnumber of rows in the weight matrix
[in]pre_rshiftright shift amount for the output before the scaling
[in]out_scalescaling value for the output
[in]post_rshiftright shift amount for the output after the scaling
[in]biaspointer of the bias vector
[out]out_vecpointer of the output vector
[in]in_tmp_buftemporary buffer for input vector. It is required when -mext-dsp is enabled and its size must be "size".
Returns
This function only returns 0.
Note
The outputs will be two-stage shifted before being stored, i.e., out = ((out >> pre_rshift) *out_scale) >> post_rshift.

◆ hpm_nn_fc_s8_s16_s8_sym_bias_fast()

static int32_t hpm_nn_fc_s8_s16_s8_sym_bias_fast ( const q7_t *  in_vec,
const q7_t *  wt_mat,
const uint16_t  size,
const uint16_t  wt_row_num,
const uint16_t  pre_rshift,
const uint16_t  out_scale,
const uint16_t  post_rshift,
const q31_t *  bias,
q15_t *  out_vec,
q15_t *  in_tmp_buf 
)
inlinestatic

#include <middleware/hpm_math/hpm_math.h>

This is a fully connected layer function for signed 8-bit integer inputs and signed 16-bit integer outputs with bias inputs, interleaved multiplication and symmetric quantization on the outputs.

Parameters
[in]in_vecpointer of the input vector
[in]wt_matpointer of the weight matrix
[in]sizenumber of elements in the input vector
[in]wt_row_numnumber of rows in the weight matrix
[in]pre_rshiftright shift amount for the output
[in]out_scalevalue of scaling for the output
[in]post_rshiftright shift amount for the output
[in]biaspointer of the bias vector
[out]out_vecpointer of the output vector
[in]in_tmp_buftemporary buffer for input vector. It is required when -mext-vector is enabled and its size must be 2 * size.
Returns
This function only returns 0.
Note
  • In this function, the input vector is multiplied by the weight matrix in interleaved format which could be obtained by riscv_nn_fc_s8_wt_converter.
  • The outputs will be two-stage shifted before being stored, i.e., out = ((out >> pre_rshift) *out_scale) >> post_rshift.

◆ hpm_nn_fc_s8_s16_s8_sym_fast()

static int32_t hpm_nn_fc_s8_s16_s8_sym_fast ( const q7_t *  in_vec,
const q7_t *  wt_mat,
const uint16_t  size,
const uint16_t  wt_row_num,
const uint16_t  pre_rshift,
const uint16_t  out_scale,
const uint16_t  post_rshift,
q15_t *  out_vec,
q15_t *  in_tmp_buf 
)
inlinestatic

#include <middleware/hpm_math/hpm_math.h>

This is a fully connected layer function for signed 8-bit integer inputs and signed 16-bit integer outputs with interleaved multiplication and symmetric quantization on the outputs.

Parameters
[in]in_vecpointer of the input vector
[in]wt_matpointer of the weight matrix
[in]sizenumber of elements in the input vector
[in]wt_row_numnumber of rows in the weight matrix
[in]pre_rshiftright shift amount for the output
[in]out_scalevalue of scaling for the output
[in]post_rshiftright shift amount for the output
[out]out_vecpointer of the output vector
[in]in_tmp_buftemporary buffer for input vector. It is required when -mext-vector is enabled and its size must be 2 * size.
Returns
This function only returns 0.
Note
  • In this function, the input vector is multiplied by the weight matrix in interleaved format which could be obtained by riscv_nn_fc_s8_wt_converter.
  • The outputs will be two-stage shifted before being stored, i.e., out = ((out >> pre_rshift) *out_scale) >> post_rshift.

◆ hpm_nn_fc_s8_s8_s8_asym_bias()

static int32_t hpm_nn_fc_s8_s8_s8_asym_bias ( const int8_t *  in_vec,
const int8_t *  wt_mat,
const uint16_t  in_vec_col,
const uint16_t  wt_mat_row,
const uint16_t  in_vec_group,
const int32_t  in_offset,
const int32_t  wt_offset,
const int32_t  out_scale,
const int32_t  out_shift,
const int32_t  out_offset,
const int32_t *  bias,
int8_t *  out_vec,
const int32_t  act_min,
const int32_t  act_max,
q15_t *  tmp_buf 
)
inlinestatic

#include <middleware/hpm_math/hpm_math.h>

This is a fully connected layer function for signed 8-bit integer inputs with bias inputs and asymmetric quantization on the outputs.

Parameters
[in]in_vecpointer of the input vector
[in]wt_matpointer of the transposed weight matrix
[in]in_vec_colnumber of columns in the input vector (or transposed weight matrix)
[in]wt_mat_rownumber of rows in the transposed weight matrix
[in]in_vec_groupnumber of input vector groups
[in]in_offsetvalue of offset to be added to the input tensor. It should be in the range of -127 to 128.
[in]wt_offsetvalue of offset to be added to the weight. It should be in the range of -127 to 128.
[in]out_scalevalue of sacling for the output tensor
[in]out_shiftshift amount for the output tensor
[in]out_offsetvalue of offset to be added to the output tensor. It should be in the range of -128 to 127.
[in]biaspointer of the bias vector
[in]out_vecpointer of the output vector
[in]act_minminimum value to clip out the ouput tensor. It should be in the range of -128 to 127.
[in]act_maxmaximum value to clip out the ouput tensor. It should be in the range of -128 to 127.
[in]tmp_bufdummy
Returns
This function only returns 0.

◆ hpm_nn_fc_s8_s8_s8_asym_bias_get_buffer_size()

static int32_t hpm_nn_fc_s8_s8_s8_asym_bias_get_buffer_size ( const uint16_t  in_vec_col)
inlinestatic

#include <middleware/hpm_math/hpm_math.h>

This function is used to get the needed size, in bytes, by the temporary buffer of riscv_nn_fc_s8_s8_s8_asym_bias.

Parameters
[in]in_vec_colnumber of columns in the input vector (or transposed weight matrix)
Returns
This function returns the needed size by the temporary buffer.

◆ hpm_nn_fc_s8_s8_s8_sft_bias()

static int32_t hpm_nn_fc_s8_s8_s8_sft_bias ( const q7_t *  in_vec,
const q7_t *  wt_mat,
const uint16_t  size,
const uint16_t  wt_row_num,
const uint16_t  bias_lshift,
const uint16_t  out_rshift,
const q7_t *  bias,
q7_t *  out_vec,
q15_t *  in_tmp_buf 
)
inlinestatic

#include <middleware/hpm_math/hpm_math.h>

This is a fully connected layer function for signed 8-bit integer inputs with shift-based quantization on the outputs.

Parameters
[in]in_vecpointer of the input vector
[in]wt_matpointer of the weight matrix
[in]sizenumber of elements in the input vector
[in]wt_row_numnumber of rows in the weight matrix
[in]bias_lshiftleft shift amount for the bias
[in]out_rshiftright shift amount for the output
[in]biaspointer of the bias vector
[out]out_vecpointer of the output vector
[in]in_tmp_bufdummy
Returns
This function only returns 0.

Example:

#define IN_SIZE 2048
#define OUT_SIZE 256
#define BIAS_LSHIFT 9
#define OUT_RSHIFT 9
q7_t in_vec[IN_SIZE] = {...};;
q7_t wt_mat[IN_SIZE * OUT_SIZE] {...};
q7_t bias[OUT_SIZE] = {...};
q7_t out_vec[OUT_SIZE];
hpm_nn_fc_s8_s8_s8_sft_bias(in_vec, wt_mat, IN_SIZE, OUT_SIZE, BIAS_LSHIFT,
OUT_RSHIFT, bias, out_vec, NULL);
static int32_t out_vec
Definition: hpm_math.h:14079
static int32_t bias
Definition: hpm_math.h:14079
static int32_t hpm_nn_fc_s8_s8_s8_sft_bias(const q7_t *in_vec, const q7_t *wt_mat, const uint16_t size, const uint16_t wt_row_num, const uint16_t bias_lshift, const uint16_t out_rshift, const q7_t *bias, q7_t *out_vec, q15_t *in_tmp_buf) return riscv_nn_fc_s8_s8_s8_sft_bias(in_vec
This is a fully connected layer function for signed 8-bit integer inputs with shift-based quantizatio...
static int32_t wt_mat
Definition: hpm_math.h:14078

◆ hpm_nn_fc_s8_s8_s8_sft_bias_fast()

static int32_t hpm_nn_fc_s8_s8_s8_sft_bias_fast ( const q7_t *  in_vec,
const q7_t *  wt_mat,
const uint16_t  size,
const uint16_t  wt_row_num,
const uint16_t  bias_lshift,
const uint16_t  out_rshift,
const q7_t *  bias,
q7_t *  out_vec,
q15_t *  in_tmp_buf 
)
inlinestatic

#include <middleware/hpm_math/hpm_math.h>

This is a fully connected layer function for signed 8-bit integer inputs with interleaved multiplication and shift-based quantization on the outputs.

Parameters
[in]in_vecpointer of the input vector
[in]wt_matpointer of the weight matrix
[in]sizenumber of elements in the input vector
[in]wt_row_numnumber of rows in the weight matrix
[in]bias_lshiftleft shift amount for the bias
[in]out_rshiftright shift amount for the output
[in]biaspointer of the bias vector
[out]out_vecpointer of the output vector
[in]in_tmp_buftemporary buffer for input vector. It is required when -mext-vector is enabled and its size must be "2 * size".
Returns
This function only returns 0.
Note
In this function, the input vector is multiplied by the weight matrix in interleaved formats which could be obtained by riscv_nn_fc_s8_wt_converter.

◆ hpm_nn_fc_s8_s8_s8_sym()

static int32_t hpm_nn_fc_s8_s8_s8_sym ( const q7_t *  in_vec,
const q7_t *  wt_mat,
const uint16_t  size,
const uint16_t  wt_row_num,
const uint16_t  pre_rshift,
const uint16_t  out_scale,
const uint16_t  post_rshift,
q7_t *  out_vec,
q15_t *  in_tmp_buf 
)
inlinestatic

#include <middleware/hpm_math/hpm_math.h>

This is a fully connected layer function for signed 8-bit integer inputs/outputs with symmetric quantization on the outputs.

Parameters
[in]in_vecpointer of the input vector
[in]wt_matpointer of the weight matrix
[in]sizenumber of elements in the input vector
[in]wt_row_numnumber of rows in the weight matrix
[in]pre_rshiftright shift amount for the output before the scaling
[in]out_scalescaling value for the output
[in]post_rshiftright shift amount for the output after the scaling
[out]out_vecpointer of the output vector
[in]in_tmp_buftemporary buffer for input vector. It is required when -mext-dsp is enabled and its size must be "size".
Returns
This function only returns 0.
Note
The outputs will be two-stage shifted before being stored, i.e., out = ((out >> pre_rshift) *out_scale) >> post_rshift.

◆ hpm_nn_fc_s8_s8_s8_sym_bias()

static int32_t hpm_nn_fc_s8_s8_s8_sym_bias ( const q7_t *  in_vec,
const q7_t *  wt_mat,
const uint16_t  size,
const uint16_t  wt_row_num,
const uint16_t  pre_rshift,
const uint16_t  out_scale,
const uint16_t  post_rshift,
const q31_t *  bias,
q7_t *  out_vec,
q15_t *  in_tmp_buf 
)
inlinestatic

#include <middleware/hpm_math/hpm_math.h>

This is a fully connected layer function for signed 8-bit integer inputs/outputs with bias inputs and symmetric quantization on the outputs.

Parameters
[in]in_vecpointer of the input vector
[in]wt_matpointer of the weight matrix
[in]sizenumber of elements in the input vector
[in]wt_row_numnumber of rows in the weight matrix
[in]pre_rshiftright shift amount for the output before the scaling
[in]out_scalescaling value for the output
[in]post_rshiftright shift amount for the output after the scaling
[in]biaspointer of the bias vector
[out]out_vecpointer of the output vector
[in]in_tmp_buftemporary buffer for input vector. It is required when -mext-dsp is enabled and its size must be "size".
Returns
This function only returns 0.
Note
The outputs will be two-stage shifted before being stored, i.e., out = ((out >> pre_rshift) *out_scale) >> post_rshift.

◆ hpm_nn_fc_s8_s8_s8_sym_bias_fast()

static int32_t hpm_nn_fc_s8_s8_s8_sym_bias_fast ( const q7_t *  in_vec,
const q7_t *  wt_mat,
const uint16_t  size,
const uint16_t  wt_row_num,
const uint16_t  pre_rshift,
const uint16_t  out_scale,
const uint16_t  post_rshift,
const q31_t *  bias,
q7_t *  out_vec,
q15_t *  in_tmp_buf 
)
inlinestatic

#include <middleware/hpm_math/hpm_math.h>

This is a fully connected layer function for signed 8-bit integer inputs/outputs with bias inputs, interleaved multiplication and symmetric quantization on the outputs.

Parameters
[in]in_vecpointer of the input vector
[in]wt_matpointer of the weight matrix
[in]sizenumber of elements in the input vector
[in]wt_row_numnumber of rows in the weight matrix
[in]pre_rshiftright shift amount for the output
[in]out_scalevalue of scaling for the output
[in]post_rshiftright shift amount for the output
[in]biaspointer of the bias vector
[out]out_vecpointer of the output vector
[in]in_tmp_buftemporary buffer for input vector. It is required when -mext-vector is enabled and its size must be 2 * size.
Returns
This function only returns 0.
Note
  • In this function, the input vector is multiplied by the weight matrix in interleaved format which could be obtained by riscv_nn_fc_s8_wt_converter.
  • The outputs will be two-stage shifted before being stored, i.e., out = ((out >> pre_rshift) *out_scale) >> post_rshift.

◆ hpm_nn_fc_s8_s8_s8_sym_fast()

static int32_t hpm_nn_fc_s8_s8_s8_sym_fast ( const q7_t *  in_vec,
const q7_t *  wt_mat,
const uint16_t  size,
const uint16_t  wt_row_num,
const uint16_t  pre_rshift,
const uint16_t  out_scale,
const uint16_t  post_rshift,
q7_t *  out_vec,
q15_t *  in_tmp_buf 
)
inlinestatic

#include <middleware/hpm_math/hpm_math.h>

This is a fully connected layer function for signed 8-bit integer inputs/outputs with interleaved multiplication and symmetric quantization on the outputs.

Parameters
[in]in_vecpointer of the input vector
[in]wt_matpointer of the weight matrix
[in]sizenumber of elements in the input vector
[in]wt_row_numnumber of rows in the weight matrix
[in]pre_rshiftright shift amount for the output
[in]out_scalevalue of scaling for the output
[in]post_rshiftright shift amount for the output
[out]out_vecpointer of the output vector
[in]in_tmp_buftemporary buffer for input vector. It is required when -mext-vector is enabled and its size must be 2 * size.
Returns
This function only returns 0.
Note
  • In this function, the input vector is multiplied by the weight matrix in interleaved format which could be obtained by riscv_nn_fc_s8_wt_converter.
  • The outputs will be two-stage shifted before being stored, i.e., out = ((out >> pre_rshift) *out_scale) >> post_rshift.

◆ hpm_nn_fc_s8_wt_converter()

static void hpm_nn_fc_s8_wt_converter ( const q7_t *  wt_mat,
const uint32_t  size,
const uint32_t  wt_row_num,
q7_t *  wt_mat_out 
)
inlinestatic

#include <middleware/hpm_math/hpm_math.h>

This is a weight converter for those fully-connected functions with signed 8-bit weight data and named with "fast".

Parameters
[in]wt_matpointer of the weight matrix
[in]sizenumber of elements in the input vector
[in]wt_row_numnumber of rows in the weight matrix
[out]wt_mat_outpointer of the weight matrix stored in specific ordering

◆ hpm_nn_fc_u8_s16_s8_sym()

static int32_t hpm_nn_fc_u8_s16_s8_sym ( const u8_t *  in_vec,
const q7_t *  wt_mat,
const uint16_t  size,
const uint16_t  wt_row_num,
const uint16_t  pre_rshift,
const uint16_t  out_scale,
const uint16_t  post_rshift,
q15_t *  out_vec,
q15_t *  in_tmp_buf 
)
inlinestatic

#include <middleware/hpm_math/hpm_math.h>

This is a fully connected layer function for unsigned 8-bit integer inputs and signed 16-bit integer outputs with symmetric quantization on the outputs.

Parameters
[in]in_vecpointer of the input vector
[in]wt_matpointer of the weight matrix
[in]sizenumber of elements in the input vector
[in]wt_row_numnumber of rows in the weight matrix
[in]pre_rshiftright shift amount for the output before the scaling
[in]out_scalescaling value for the output
[in]post_rshiftright shift amount for the output after the scaling
[out]out_vecpointer of the output vector
[in]in_tmp_buftemporary buffer for input vector. It is required when -mext-dsp is enabled and its size must be "size".
Returns
This function only returns 0.
Note
The outputs will be two-stage shifted before being stored, i.e., out = ((out >> pre_rshift) *out_scale) >> post_rshift.

◆ hpm_nn_fc_u8_s16_s8_sym_bias()

static int32_t hpm_nn_fc_u8_s16_s8_sym_bias ( const u8_t *  in_vec,
const q7_t *  wt_mat,
const uint16_t  size,
const uint16_t  wt_row_num,
const uint16_t  pre_rshift,
const uint16_t  out_scale,
const uint16_t  post_rshift,
const q31_t *  bias,
q15_t *  out_vec,
q15_t *  in_tmp_buf 
)
inlinestatic

#include <middleware/hpm_math/hpm_math.h>

This is a fully connected layer function for unsigned 8-bit integer inputs and signed 16-bit integer outputs with bias inputs and symmetric quantization on the outputs.

Parameters
[in]in_vecpointer of the input vector
[in]wt_matpointer of the weight matrix
[in]sizenumber of elements in the input vector
[in]wt_row_numnumber of rows in the weight matrix
[in]pre_rshiftright shift amount for the output before the scaling
[in]out_scalescaling value for the output
[in]post_rshiftright shift amount for the output after the scaling
[in]biaspointer of the bias vector
[out]out_vecpointer of the output vector
[in]in_tmp_buftemporary buffer for input vector. It is required when -mext-dsp is enabled and its size must be "size".
Returns
This function only returns 0.
Note
The outputs will be two-stage shifted before being stored, i.e., out = ((out >> pre_rshift) *out_scale) >> post_rshift.

◆ hpm_nn_fc_u8_s16_s8_sym_bias_fast()

static int32_t hpm_nn_fc_u8_s16_s8_sym_bias_fast ( const u8_t *  in_vec,
const q7_t *  wt_mat,
const uint16_t  size,
const uint16_t  wt_row_num,
const uint16_t  pre_rshift,
const uint16_t  out_scale,
const uint16_t  post_rshift,
const q31_t *  bias,
q15_t *  out_vec,
q15_t *  in_tmp_buf 
)
inlinestatic

#include <middleware/hpm_math/hpm_math.h>

This is a fully connected layer function for unsigned 8-bit integer inputs and signed 16-bit integer outputs with bias inputs, interleaved multiplication and symmetric quantization on the outputs.

Parameters
[in]in_vecpointer of the input vector
[in]wt_matpointer of the weight matrix
[in]sizenumber of elements in the input vector
[in]wt_row_numnumber of rows in the weight matrix
[in]pre_rshiftright shift amount for the output
[in]out_scalevalue of scaling for the output
[in]post_rshiftright shift amount for the output
[in]biaspointer of the bias vector
[out]out_vecpointer of the output vector
[in]in_tmp_buftemporary buffer for input vector. It is required when -mext-vector is enabled and its size must be 2 * size.
Returns
This function only returns 0.
Note
  • In this function, the input vector is multiplied by the weight matrix in interleaved format which could be obtained by riscv_nn_fc_s8_wt_converter.
  • The outputs will be two-stage shifted before being stored, i.e., out = ((out >> pre_rshift) *out_scale) >> post_rshift.

◆ hpm_nn_fc_u8_s16_s8_sym_fast()

static int32_t hpm_nn_fc_u8_s16_s8_sym_fast ( const u8_t *  in_vec,
const q7_t *  wt_mat,
const uint16_t  size,
const uint16_t  wt_row_num,
const uint16_t  pre_rshift,
const uint16_t  out_scale,
const uint16_t  post_rshift,
q15_t *  out_vec,
q15_t *  in_tmp_buf 
)
inlinestatic

#include <middleware/hpm_math/hpm_math.h>

This is a fully connected layer function for unsigned 8-bit integer inputs and signed 16-bit integer outputs with interleaved multiplication and symmetric quantization on the outputs.

Parameters
[in]in_vecpointer of the input vector
[in]wt_matpointer of the weight matrix
[in]sizenumber of elements in the input vector
[in]wt_row_numnumber of rows in the weight matrix
[in]pre_rshiftright shift amount for the output
[in]out_scalevalue of scaling for the output
[in]post_rshiftright shift amount for the output
[out]out_vecpointer of the output vector
[in]in_tmp_buftemporary buffer for input vector. It is required when -mext-vector is enabled and its size must be 2 * size.
Returns
This function only returns 0.
Note
  • In this function, the input vector is multiplied by the weight matrix in interleaved format which could be obtained by riscv_nn_fc_s8_wt_converter.
  • The outputs will be two-stage shifted before being stored, i.e., out = ((out >> pre_rshift) *out_scale) >> post_rshift.

◆ hpm_nn_fc_u8_s8_s8_sym()

static int32_t hpm_nn_fc_u8_s8_s8_sym ( const u8_t *  in_vec,
const q7_t *  wt_mat,
const uint16_t  size,
const uint16_t  wt_row_num,
const uint16_t  pre_rshift,
const uint16_t  out_scale,
const uint16_t  post_rshift,
q7_t *  out_vec,
q15_t *  in_tmp_buf 
)
inlinestatic

#include <middleware/hpm_math/hpm_math.h>

This is a fully connected layer function for unsigned 8-bit integer inputs and signed 8-bit integer outputs with symmetric quantization on the outputs.

Parameters
[in]in_vecpointer of the input vector
[in]wt_matpointer of the weight matrix
[in]sizenumber of elements in the input vector
[in]wt_row_numnumber of rows in the weight matrix
[in]pre_rshiftright shift amount for the output before the scaling
[in]out_scalescaling value for the output
[in]post_rshiftright shift amount for the output after the scaling
[out]out_vecpointer of the output vector
[in]in_tmp_buftemporary buffer for input vector. It is required when -mext-dsp is enabled and its size must be "size".
Returns
This function only returns 0.
Note
The outputs will be two-stage shifted before being stored, i.e., out = ((out >> pre_rshift) *out_scale) >> post_rshift.

◆ hpm_nn_fc_u8_s8_s8_sym_bias()

static int32_t hpm_nn_fc_u8_s8_s8_sym_bias ( const u8_t *  in_vec,
const q7_t *  wt_mat,
const uint16_t  size,
const uint16_t  wt_row_num,
const uint16_t  pre_rshift,
const uint16_t  out_scale,
const uint16_t  post_rshift,
const q31_t *  bias,
q7_t *  out_vec,
q15_t *  in_tmp_buf 
)
inlinestatic

#include <middleware/hpm_math/hpm_math.h>

This is a fully connected layer function for unsigned 8-bit integer inputs and signed 8-bit integer outputs with bias inputs and symmetric quantization on the outputs.

Parameters
[in]in_vecpointer of the input vector
[in]wt_matpointer of the weight matrix
[in]sizenumber of elements in the input vector
[in]wt_row_numnumber of rows in the weight matrix
[in]pre_rshiftright shift amount for the output before the scaling
[in]out_scalescaling value for the output
[in]post_rshiftright shift amount for the output after the scaling
[in]biaspointer of the bias vector
[out]out_vecpointer of the output vector
[in]in_tmp_buftemporary buffer for input vector. It is required when -mext-dsp is enabled and its size must be "size".
Returns
This function only returns 0.
Note
The outputs will be two-stage shifted before being stored, i.e., out = ((out >> pre_rshift) *out_scale) >> post_rshift.

◆ hpm_nn_fc_u8_s8_s8_sym_bias_fast()

static int32_t hpm_nn_fc_u8_s8_s8_sym_bias_fast ( const u8_t *  in_vec,
const q7_t *  wt_mat,
const uint16_t  size,
const uint16_t  wt_row_num,
const uint16_t  pre_rshift,
const uint16_t  out_scale,
const uint16_t  post_rshift,
const q31_t *  bias,
q7_t *  out_vec,
q15_t *  in_tmp_buf 
)
inlinestatic

#include <middleware/hpm_math/hpm_math.h>

This is a fully connected layer function for unsigned 8-bit integer inputs and signed 8-bit integer outputs with bias inputs, interleaved multiplication and symmetric quantization on the outputs.

Parameters
[in]in_vecpointer of the input vector
[in]wt_matpointer of the weight matrix
[in]sizenumber of elements in the input vector
[in]wt_row_numnumber of rows in the weight matrix
[in]pre_rshiftright shift amount for the output
[in]out_scalevalue of scaling for the output
[in]post_rshiftright shift amount for the output
[in]biaspointer of the bias vector
[out]out_vecpointer of the output vector
[in]in_tmp_buftemporary buffer for input vector. It is required when -mext-vector is enabled and its size must be 2 * size.
Returns
This function only returns 0.
Note
  • In this function, the input vector is multiplied by the weight matrix in interleaved format which could be obtained by riscv_nn_fc_s8_wt_converter.
  • The outputs will be two-stage shifted before being stored, i.e., out = ((out >> pre_rshift) *out_scale) >> post_rshift.

◆ hpm_nn_fc_u8_s8_s8_sym_fast()

static int32_t hpm_nn_fc_u8_s8_s8_sym_fast ( const u8_t *  in_vec,
const q7_t *  wt_mat,
const uint16_t  size,
const uint16_t  wt_row_num,
const uint16_t  pre_rshift,
const uint16_t  out_scale,
const uint16_t  post_rshift,
q7_t *  out_vec,
q15_t *  in_tmp_buf 
)
inlinestatic

#include <middleware/hpm_math/hpm_math.h>

This is a fully connected layer function for unsigned 8-bit integer inputs and signed 8-bit integer outputs with interleaved multiplication and symmetric quantization on the outputs.

Parameters
[in]in_vecpointer of the input vector
[in]wt_matpointer of the weight matrix
[in]sizenumber of elements in the input vector
[in]wt_row_numnumber of rows in the weight matrix
[in]pre_rshiftright shift amount for the output
[in]out_scalevalue of scaling for the output
[in]post_rshiftright shift amount for the output
[out]out_vecpointer of the output vector
[in]in_tmp_buftemporary buffer for input vector. It is required when -mext-vector is enabled and its size must be 2 * size.
Returns
This function only returns 0.
Note
  • In this function, the input vector is multiplied by the weight matrix in interleaved format which could be obtained by riscv_nn_fc_s8_wt_converter.
  • The outputs will be two-stage shifted before being stored, i.e., out = ((out >> pre_rshift) *out_scale) >> post_rshift.

◆ hpm_nn_fc_u8_u8_s8_sym()

static int32_t hpm_nn_fc_u8_u8_s8_sym ( const u8_t *  in_vec,
const q7_t *  wt_mat,
const uint16_t  size,
const uint16_t  wt_row_num,
const uint16_t  pre_rshift,
const uint16_t  out_scale,
const uint16_t  post_rshift,
u8_t *  out_vec,
q15_t *  in_tmp_buf 
)
inlinestatic

#include <middleware/hpm_math/hpm_math.h>

This is a fully connected layer function for unsigned 8-bit integer inputs/outputs with symmetric quantization on the outputs.

Parameters
[in]in_vecpointer of the input vector
[in]wt_matpointer of the weight matrix
[in]sizenumber of elements in the input vector
[in]wt_row_numnumber of rows in the weight matrix
[in]pre_rshiftright shift amount for the output before the scaling
[in]out_scalescaling value for the output
[in]post_rshiftright shift amount for the output after the scaling
[out]out_vecpointer of the output vector
[in]in_tmp_buftemporary buffer for input vector. It is required when -mext-dsp is enabled and its size must be "size".
Returns
This function only returns 0.
Note
The outputs will be two-stage shifted before being stored, i.e., out = ((out >> pre_rshift) *out_scale) >> post_rshift.

◆ hpm_nn_fc_u8_u8_s8_sym_bias()

static int32_t hpm_nn_fc_u8_u8_s8_sym_bias ( const u8_t *  in_vec,
const q7_t *  wt_mat,
const uint16_t  size,
const uint16_t  wt_row_num,
const uint16_t  pre_rshift,
const uint16_t  out_scale,
const uint16_t  post_rshift,
const q31_t *  bias,
u8_t *  out_vec,
q15_t *  in_tmp_buf 
)
inlinestatic

#include <middleware/hpm_math/hpm_math.h>

This is a fully connected layer function for unsigned 8-bit integer inputs/outputs with bias inputs and symmetric quantization on the outputs.

Parameters
[in]in_vecpointer of the input vector
[in]wt_matpointer of the weight matrix
[in]sizenumber of elements in the input vector
[in]wt_row_numnumber of rows in the weight matrix
[in]pre_rshiftright shift amount for the output before the scaling
[in]out_scalescaling value for the output
[in]post_rshiftright shift amount for the output after the scaling
[in]biaspointer of the bias vector
[out]out_vecpointer of the output vector
[in]in_tmp_buftemporary buffer for input vector. It is required when -mext-dsp is enabled and its size must be "size".
Returns
This function only returns 0.
Note
The outputs will be two-stage shifted before being stored, i.e., out = ((out >> pre_rshift) *out_scale) >> post_rshift.

◆ hpm_nn_fc_u8_u8_s8_sym_bias_fast()

static int32_t hpm_nn_fc_u8_u8_s8_sym_bias_fast ( const u8_t *  in_vec,
const q7_t *  wt_mat,
const uint16_t  size,
const uint16_t  wt_row_num,
const uint16_t  pre_rshift,
const uint16_t  out_scale,
const uint16_t  post_rshift,
const q31_t *  bias,
u8_t *  out_vec,
q15_t *  in_tmp_buf 
)
inlinestatic

#include <middleware/hpm_math/hpm_math.h>

This is a fully connected layer function for unsigned 8-bit integer inputs/outputs with bias inputs, interleaved multiplication and symmetric quantization on the outputs.

Parameters
[in]in_vecpointer of the input vector
[in]wt_matpointer of the weight matrix
[in]sizenumber of elements in the input vector
[in]wt_row_numnumber of rows in the weight matrix
[in]pre_rshiftright shift amount for the output
[in]out_scalevalue of scaling for the output
[in]post_rshiftright shift amount for the output
[in]biaspointer of the bias vector
[out]out_vecpointer of the output vector
[in]in_tmp_buftemporary buffer for input vector. It is required when -mext-vector is enabled and its size must be 2 * size.
Returns
This function only returns 0.
Note
  • In this function, the input vector is multiplied by the weight matrix in interleaved format which could be obtained by riscv_nn_fc_s8_wt_converter.
  • The outputs will be two-stage shifted before being stored, i.e., out = ((out >> pre_rshift) *out_scale) >> post_rshift.

◆ hpm_nn_fc_u8_u8_s8_sym_fast()

static int32_t hpm_nn_fc_u8_u8_s8_sym_fast ( const u8_t *  in_vec,
const q7_t *  wt_mat,
const uint16_t  size,
const uint16_t  wt_row_num,
const uint16_t  pre_rshift,
const uint16_t  out_scale,
const uint16_t  post_rshift,
u8_t *  out_vec,
q15_t *  in_tmp_buf 
)
inlinestatic

#include <middleware/hpm_math/hpm_math.h>

This is a fully connected layer function for unsigned 8-bit integer inputs/outputs with interleaved multiplication and symmetric quantization on the outputs.

Parameters
[in]in_vecpointer of the input vector
[in]wt_matpointer of the weight matrix
[in]sizenumber of elements in the input vector
[in]wt_row_numnumber of rows in the weight matrix
[in]pre_rshiftright shift amount for the output
[in]out_scalevalue of scaling for the output
[in]post_rshiftright shift amount for the output
[out]out_vecpointer of the output vector
[in]in_tmp_buftemporary buffer for input vector. It is required when -mext-vector is enabled and its size must be 2 * size.
Returns
This function only returns 0.
Note
  • In this function, the input vector is multiplied by the weight matrix in interleaved format which could be obtained by riscv_nn_fc_s8_wt_converter.
  • The outputs will be two-stage shifted before being stored, i.e., out = ((out >> pre_rshift) *out_scale) >> post_rshift.

Variable Documentation

◆ bias

int32_t bias

◆ bias_lshift

int32_t bias_lshift

◆ in_tmp_buf

int32_t in_tmp_buf

◆ out_rshift

int32_t out_rshift

◆ out_vec

int32_t out_vec

◆ wt_mat

int32_t wt_mat

◆ wt_row_num

int32_t wt_row_num