Utils functions are miscellaneous auxiliary tools.
More...
|
| 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...
|
| |
Utils functions are miscellaneous auxiliary tools.
◆ 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 </home/docs/checkouts/readthedocs.org/user_builds/hpm-sdk/checkouts/latest/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_tensor | pointer of the input tensor |
| [out] | out_tensor | pointer of the output tensor |
| [in] | size | size, in bytes, of total input tensor |
Example:
#define SIZE 1024
int8_t in_tensor[SIZE] = {...};
int8_t 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 </home/docs/checkouts/readthedocs.org/user_builds/hpm-sdk/checkouts/latest/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_vec | pointer of the input vector |
| [in] | size | number of elements in the input vector |
| [in] | k | the number of the largest values to be searched |
| [out] | val | the k largest values in the input vector |
| [out] | idx | the 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.