| #include "edge-impulse-sdk/dsp/config.hpp" |
| #if EIDSP_LOAD_CMSIS_DSP_SOURCES |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| #include "edge-impulse-sdk/CMSIS/DSP/Include/dsp/statistics_functions_f16.h" |
|
|
| #if defined(ARM_FLOAT16_SUPPORTED) |
|
|
| #if (defined(ARM_MATH_NEON) || defined(ARM_MATH_MVEF)) && !defined(ARM_MATH_AUTOVECTORIZE) |
| #include <limits.h> |
| #endif |
|
|
| |
| |
| |
|
|
|
|
| |
| |
| |
| |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| #if defined(ARM_MATH_MVE_FLOAT16) && !defined(ARM_MATH_AUTOVECTORIZE) |
|
|
| void arm_max_f16( |
| const float16_t * pSrc, |
| uint32_t blockSize, |
| float16_t * pResult, |
| uint32_t * pIndex) |
| { |
| int32_t blkCnt; |
| f16x8_t vecSrc; |
| f16x8_t curExtremValVec = vdupq_n_f16(F16_MIN); |
| float16_t maxValue = F16_MIN; |
| uint32_t idx = blockSize; |
| uint16x8_t indexVec; |
| uint16x8_t curExtremIdxVec; |
| uint32_t curIdx = 0; |
| mve_pred16_t p0; |
| float16_t tmp; |
|
|
|
|
| indexVec = vidupq_wb_u16(&curIdx, 1); |
| curExtremIdxVec = vdupq_n_u16(0); |
|
|
| |
| blkCnt = blockSize >> 3; |
| while (blkCnt > 0) |
| { |
| vecSrc = vldrhq_f16(pSrc); |
| |
| |
| |
| |
| p0 = vcmpgeq(vecSrc, curExtremValVec); |
| curExtremValVec = vpselq(vecSrc, curExtremValVec, p0); |
| curExtremIdxVec = vpselq(indexVec, curExtremIdxVec, p0); |
|
|
| indexVec = vidupq_wb_u16(&curIdx, 1); |
|
|
| pSrc += 8; |
| |
| blkCnt--; |
| } |
|
|
|
|
| |
| |
| |
| maxValue = vmaxnmvq(maxValue, curExtremValVec); |
| |
| |
| |
| p0 = vcmpgeq(curExtremValVec, maxValue); |
| indexVec = vpselq(curExtremIdxVec, vdupq_n_u16(blockSize), p0); |
| |
| |
| |
| idx = vminvq(idx, indexVec); |
|
|
| |
| blkCnt = blockSize & 7; |
|
|
| while (blkCnt > 0) |
| { |
| |
| tmp = *pSrc++; |
|
|
| |
| if ((_Float16)maxValue < (_Float16)tmp) |
| { |
| |
| maxValue = tmp; |
| idx = blockSize - blkCnt; |
| } |
|
|
| |
| blkCnt--; |
| } |
|
|
| |
| |
| |
| *pIndex = idx; |
| *pResult = maxValue; |
| } |
|
|
| #else |
| void arm_max_f16( |
| const float16_t * pSrc, |
| uint32_t blockSize, |
| float16_t * pResult, |
| uint32_t * pIndex) |
| { |
| float16_t maxVal, out; |
| uint32_t blkCnt, outIndex; |
|
|
| #if defined (ARM_MATH_LOOPUNROLL) && !defined(ARM_MATH_AUTOVECTORIZE) |
| uint32_t index; |
| #endif |
|
|
| |
| outIndex = 0U; |
|
|
| |
| out = *pSrc++; |
|
|
| #if defined (ARM_MATH_LOOPUNROLL) && !defined(ARM_MATH_AUTOVECTORIZE) |
| |
| index = 0U; |
|
|
| |
| blkCnt = (blockSize - 1U) >> 2U; |
|
|
| while (blkCnt > 0U) |
| { |
| |
| maxVal = *pSrc++; |
|
|
| |
| if ((_Float16)out < (_Float16)maxVal) |
| { |
| |
| out = maxVal; |
| outIndex = index + 1U; |
| } |
|
|
| maxVal = *pSrc++; |
| if ((_Float16)out < (_Float16)maxVal) |
| { |
| out = maxVal; |
| outIndex = index + 2U; |
| } |
|
|
| maxVal = *pSrc++; |
| if ((_Float16)out < (_Float16)maxVal) |
| { |
| out = maxVal; |
| outIndex = index + 3U; |
| } |
|
|
| maxVal = *pSrc++; |
| if ((_Float16)out < (_Float16)maxVal) |
| { |
| out = maxVal; |
| outIndex = index + 4U; |
| } |
|
|
| index += 4U; |
|
|
| |
| blkCnt--; |
| } |
|
|
| |
| blkCnt = (blockSize - 1U) % 4U; |
|
|
| #else |
|
|
| |
| blkCnt = (blockSize - 1U); |
|
|
| #endif |
|
|
| while (blkCnt > 0U) |
| { |
| |
| maxVal = *pSrc++; |
|
|
| |
| if ((_Float16)out < (_Float16)maxVal) |
| { |
| |
| out = maxVal; |
| outIndex = blockSize - blkCnt; |
| } |
|
|
| |
| blkCnt--; |
| } |
|
|
| |
| *pResult = out; |
| *pIndex = outIndex; |
| } |
| #endif |
|
|
| |
| |
| |
|
|
| #endif |
|
|
|
|
| #endif |
|
|