![]() |
LIBML Version 4.1.9
LIBML NN Software Library
|
#include <assert.h>#include <limits.h>#include <math.h>#include <stdbool.h>#include <stddef.h>#include <stdint.h>#include <string.h>#include "libnn/tpt_libnn_version.h"#include "libnn/nn_pi_values.h"#include "libnn/tpt_activation.h"#include "libnn/tpt_basicmath.h"#include "libnn/tpt_concatenation.h"#include "libnn/tpt_convolution.h"#include "libnn/tpt_fully_connected.h"#include "libnn/tpt_pooling.h"#include "libnn/tpt_reshape.h"#include "libnn/tpt_softmax.h"#include "libnn/tpt_support.h"#include "libnn/tpt_svd.h"#include "libnn/tpt_util.h"#include "libnn/nds_math.h"
Data Structures | |
| struct | tpt_nn_double |
| Union for data type long long. More... | |
| union | tpt_nn_long_long |
| union | _union32_t |
Macros | |
| #define | OPT_BRANCH_PREDICTION 1 |
| #define | TPT_MATH_LOOPUNROLL 8 |
| #define | LEFT_SHIFT(_shift) |
| #define | RIGHT_SHIFT(_shift) |
| #define | MASK_IF_ZERO(x) |
| #define | MASK_IF_NON_ZERO(x) |
| #define | SELECT_USING_MASK(mask, a, b) |
| #define | NN_ROUND(out_shift) |
| #define | TPT_MUL_SAT(a, b) |
| #define | TPT_MUL_POW2(a, b) |
| #define | TPT_DIV_POW2_V2(a, b) |
| #define | TPT_DIV_POW2(a, b) |
| #define | TPT_EXP_ON_NEG(x) |
| #define | TPT_ONE_OVER1(x) |
| #define | MAX(A, B) |
| #define | MIN(A, B) |
| #define | CLAMP(x, h, l) |
| #define | REDUCE_MULTIPLIER(_mult) |
| #define | likely(x) |
| #define | unlikely(x) |
| #define | Q63_MAX (q63_t)0x7FFFFFFFFFFFFFFFLL |
| #define | Q63_MIN (q63_t)0x8000000000000000LL |
| #define | Q31_MAX (q31_t)0x7FFFFFFF |
| #define | Q31_MIN (q31_t)0x80000000 |
| #define | Q15_MAX (q15_t)0x7FFF |
| #define | Q15_MIN (q15_t)0x8000 |
| #define | Q7_MAX (q7_t)0x7F |
| #define | Q7_MIN (q7_t)0x80 |
| #define | ABS(val, bit) |
| #define | CLIP(val, bit) |
| #define | CLIPS(val, bit) |
| #define | SELECT_IF_NON_ZERO(x) |
Typedefs | |
| typedef int64_t | q63_t |
| 64-bit fractional data type in 1.63 format. | |
| typedef int32_t | q31_t |
| 32-bit fractional data type in 1.31 format. | |
| typedef int16_t | q15_t |
| 16-bit fractional data type in 1.15 format. | |
| typedef int8_t | q7_t |
| 8-bit fractional data type in 1.7 format. | |
| typedef float | f32_t |
| 32-bit floating-point type definition. | |
Functions | |
| static int32_t | tpt_nn_doubling_high_mult_no_sat (const int32_t m1, const int32_t m2) |
| Doubling high multiply without saturation. This is intended for requantization where the scale is a positive integer. | |
| static uint32_t | __ABS (q31_t data) |
| static uint8_t | __NN_CLZ (uint32_t aData) |
| This function counts leading zeros of the given value. | |
| static int8_t * | tpt_memcpy_q7 (int8_t *buf, const int8_t *start, uint16_t input_c) |
| static uint8_t * | tpt_memcpy_u8 (uint8_t *buf, const uint8_t *start, uint16_t input_c) |
| static uint8_t * | tpt_memcpy_mul_of_four_u8 (uint8_t *buf, const uint8_t *start, uint16_t input_c) |
| static int8_t * | tpt_memcpy_mul_of_four_q7 (int8_t *buf, const int8_t *start, uint16_t input_c) |
| static int8_t * | tpt_memset_q7 (int8_t *buf, uint16_t input_c) |
| static uint8_t * | tpt_memset_u8 (uint8_t *buf, uint16_t input_c) |
| static int8_t * | tpt_memset_mul_of_four_q7 (int8_t *buf, uint16_t input_c) |
| static uint8_t * | tpt_memset_mul_of_four_u8 (uint8_t *buf, uint16_t input_c) |
| static int32_t | tpt_nn_requantize (const int32_t val, const int32_t multiplier, const int32_t shift) |
| Requantize a given value. | |
| static int32_t | tpt_nn_requantize_op (const int32_t val, const int32_t multiplier, const int32_t shift) |
| Requantize a given value with overflow protection. | |
| static int32_t | tpt_nn_requantize_ns (const int32_t val, const int32_t multiplier, const int32_t shift) |
| static int32_t | tpt_nn_requantize_q63 (const int64_t val, const int32_t multiplier, const int32_t shift) |
| static q31_t | tpt_nn_divide_by_power_of_two (const q31_t dividend, const q31_t exponent) |
| static q31_t | tpt_nn_divide_by_power_of_two_v2 (const q31_t dividend, const q31_t exponent) |
| static q31_t | tpt_nn_mult_by_power_of_two (const int32_t val, const int32_t exp) |
| static int32_t | tpt_nn_sat_doubling_high_mult (const int32_t m1, const int32_t m2) |
| static int32_t | tpt_nn_exp_on_negative_values (int32_t val) |
| static int32_t | tpt_nn_one_over_one_plus_x_for_x_in_0_1 (int32_t val) |
| #define ABS | ( | val, | |
| bit ) |
| #define CLAMP | ( | x, | |
| h, | |||
| l ) |
| #define CLIP | ( | val, | |
| bit ) |
| #define CLIPS | ( | val, | |
| bit ) |
| #define LEFT_SHIFT | ( | _shift | ) |
| #define likely | ( | x | ) |
| #define MASK_IF_NON_ZERO | ( | x | ) |
| #define MASK_IF_ZERO | ( | x | ) |
| #define MAX | ( | A, | |
| B ) |
| #define MIN | ( | A, | |
| B ) |
| #define NN_ROUND | ( | out_shift | ) |
| #define OPT_BRANCH_PREDICTION 1 |
| #define Q15_MAX (q15_t)0x7FFF |
| #define Q15_MIN (q15_t)0x8000 |
| #define Q31_MAX (q31_t)0x7FFFFFFF |
| #define Q31_MIN (q31_t)0x80000000 |
| #define Q63_MAX (q63_t)0x7FFFFFFFFFFFFFFFLL |
| #define Q63_MIN (q63_t)0x8000000000000000LL |
| #define Q7_MAX (q7_t)0x7F |
| #define Q7_MIN (q7_t)0x80 |
| #define REDUCE_MULTIPLIER | ( | _mult | ) |
| #define RIGHT_SHIFT | ( | _shift | ) |
| #define SELECT_IF_NON_ZERO | ( | x | ) |
| #define SELECT_USING_MASK | ( | mask, | |
| a, | |||
| b ) |
| #define TPT_DIV_POW2 | ( | a, | |
| b ) |
| #define TPT_DIV_POW2_V2 | ( | a, | |
| b ) |
| #define TPT_EXP_ON_NEG | ( | x | ) |
| #define TPT_MATH_LOOPUNROLL 8 |
| #define TPT_MUL_POW2 | ( | a, | |
| b ) |
| #define TPT_MUL_SAT | ( | a, | |
| b ) |
| #define TPT_ONE_OVER1 | ( | x | ) |
| #define unlikely | ( | x | ) |
| typedef float f32_t |
32-bit floating-point type definition.
| typedef int16_t q15_t |
16-bit fractional data type in 1.15 format.
| typedef int32_t q31_t |
32-bit fractional data type in 1.31 format.
| typedef int64_t q63_t |
64-bit fractional data type in 1.63 format.
| typedef int8_t q7_t |
8-bit fractional data type in 1.7 format.
|
inlinestatic |
|
inlinestatic |
This function counts leading zeros of the given value.
| aData |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
Doubling high multiply without saturation. This is intended for requantization where the scale is a positive integer.
| [in] | m1 | Multiplicand. Range: {NN_Q31_MIN, NN_Q31_MAX} |
| [in] | m2 | Multiplier Range: {NN_Q31_MIN, NN_Q31_MAX} |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
Requantize a given value.
| [in] | val | Value to be requantized |
| [in] | multiplier | multiplier. Range {NN_Q31_MIN + 1, Q31_MAX} |
| [in] | shift | left or right shift for 'val * multiplier' |
|
inlinestatic |
|
inlinestatic |
Requantize a given value with overflow protection.
| [in] | val | Value to be requantized |
| [in] | multiplier | multiplier. Range {NN_Q31_MIN + 1, Q32_MAX} |
| [in] | shift | left or right shift for 'val * multiplier' |
|
inlinestatic |
|
inlinestatic |