123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202 |
- #ifndef _ARM_NNSUPPORTFUNCTIONS_H_
- #define _ARM_NNSUPPORTFUNCTIONS_H_
- #include "arm_math.h"
- #include "arm_common_tables.h"
- #ifdef __cplusplus
- extern "C"
- {
- #endif
- union arm_nnword
- {
- q31_t word;
-
- q15_t half_words[2];
-
- q7_t bytes[4];
-
- };
- typedef enum
- {
- ARM_SIGMOID = 0,
-
- ARM_TANH = 1,
-
- } arm_nn_activation_type;
- void arm_q7_to_q15_no_shift(const q7_t * pSrc, q15_t * pDst, uint32_t blockSize);
- void arm_q7_to_q15_reordered_no_shift(const q7_t * pSrc, q15_t * pDst, uint32_t blockSize);
- #if defined (ARM_MATH_DSP)
- __STATIC_FORCEINLINE void *read_and_pad(void *source, q31_t * out1, q31_t * out2)
- {
- q31_t inA = *__SIMD32(source)++;
- q31_t inAbuf1 = __SXTB16(__ROR(inA, 8));
- q31_t inAbuf2 = __SXTB16(inA);
- #ifndef ARM_MATH_BIG_ENDIAN
- *out2 = __PKHTB(inAbuf1, inAbuf2, 16);
- *out1 = __PKHBT(inAbuf2, inAbuf1, 16);
- #else
- *out1 = __PKHTB(inAbuf1, inAbuf2, 16);
- *out2 = __PKHBT(inAbuf2, inAbuf1, 16);
- #endif
- return source;
- }
- __STATIC_FORCEINLINE void *read_and_pad_reordered(void *source, q31_t * out1, q31_t * out2)
- {
- q31_t inA = *__SIMD32(source)++;
- #ifndef ARM_MATH_BIG_ENDIAN
- *out2 = __SXTB16(__ROR(inA, 8));
- *out1 = __SXTB16(inA);
- #else
- *out1 = __SXTB16(__ROR(inA, 8));
- *out2 = __SXTB16(inA);
- #endif
- return source;
- }
- #endif
- void arm_nn_mult_q15(
- q15_t * pSrcA,
- q15_t * pSrcB,
- q15_t * pDst,
- const uint16_t out_shift,
- uint32_t blockSize);
-
- void arm_nn_mult_q7(
- q7_t * pSrcA,
- q7_t * pSrcB,
- q7_t * pDst,
- const uint16_t out_shift,
- uint32_t blockSize);
-
- #ifndef ARM_NN_TRUNCATE
- #define NN_ROUND(out_shift) ( 0x1 << (out_shift - 1) )
- #else
- #define NN_ROUND(out_shift) 0
- #endif
- #ifdef __cplusplus
- }
- #endif
- #endif
|