HPM SDK
HPMicro Software Development Kit

Utils functions are miscellaneous auxiliary tools. More...

Functions

static void hpm_nn_reshape_s8 (const int8_t *in_tensor, int8_t *out_tensor, const uint32_t size)
 This function turns the input tensor into another tensor with the same data but in a different shape. More...
 
static int32_t hpm_nn_top_k_s8 (q7_t *in_vec, uint32_t size, uint32_t k, q7_t *val, uint32_t *idx)
 This function finds the k largest values and their indices from the signed 8-bit integer input vector. More...
 

Detailed Description

Utils functions are miscellaneous auxiliary tools.

Function Documentation

◆ hpm_nn_reshape_s8()

static void hpm_nn_reshape_s8 ( const int8_t *  in_tensor,
int8_t *  out_tensor,
const uint32_t  size 
)
inlinestatic

#include <middleware/hpm_math/hpm_math.h>

This function turns the input tensor into another tensor with the same data but in a different shape.

Parameters
[in]in_tensorpointer of the input tensor
[out]out_tensorpointer of the output tensor
[in]sizesize, in bytes, of total input tensor

Example:

#define SIZE 1024
int8_t in_tensor[SIZE] = {...};
int8_t out_tensor[SIZE];
hpm_nn_reshape_s8(in_tensor, out_tensor, SIZE);
static void hpm_nn_reshape_s8(const int8_t *in_tensor, int8_t *out_tensor, const uint32_t size)
This function turns the input tensor into another tensor with the same data but in a different shape.
Definition: hpm_math.h:16104

◆ hpm_nn_top_k_s8()

static int32_t hpm_nn_top_k_s8 ( q7_t *  in_vec,
uint32_t  size,
uint32_t  k,
q7_t *  val,
uint32_t *  idx 
)
inlinestatic

#include <middleware/hpm_math/hpm_math.h>

This function finds the k largest values and their indices from the signed 8-bit integer input vector.

Parameters
[in]in_vecpointer of the input vector
[in]sizenumber of elements in the input vector
[in]kthe number of the largest values to be searched
[out]valthe k largest values in the input vector
[out]idxthe indices of the k largest values in the input vector
Returns
This function only returns 0.
Note
  • If there is a number of elements with the same value, the element with smaller index will be selected with high priority.
  • The k largest values will be sorted from largest to smallest and stored in "val" output vector. If there is a number of elements with the same value, the elements will be sorted from smallest index to largest index.