@@ -186,7 +186,7 @@ template <> MLI_FORCE_INLINE v2q15_t mli_math_sub_fx(v2q15_t L, v2q15_t R) {
186186
187187// Maximum of two fx operands
188188// ========================================================================
189- template < typename io_T >
189+ template < typename io_T >
190190MLI_FORCE_INLINE io_T mli_math_max_fx (io_T L, io_T R) {
191191 return MAX (L, R);
192192}
@@ -196,19 +196,19 @@ MLI_FORCE_INLINE l_T mli_math_max_fx(l_T L, r_T R) {
196196 return MAX (L, R);
197197}
198198
199- template <>
199+ template <>
200200MLI_FORCE_INLINE v2q15_t mli_math_max_fx (v2q15_t L, v2q15_t R) {
201201 return fx_max_v2q15 (L, R);
202202}
203203
204- template <typename l_T, typename r_T>
204+ template <typename l_T, typename r_T>
205205MLI_FORCE_INLINE v2q15_t mli_math_max_fx (v2q15_t L, r_T R) {
206206 return fx_max_v2q15 (L, fx_replic_v2q15 (R));
207207}
208208
209209// Minimum of two fx operands
210210// ========================================================================
211- template < typename io_T >
211+ template < typename io_T >
212212MLI_FORCE_INLINE io_T mli_math_min_fx (io_T L, io_T R) {
213213 return MIN (L, R);
214214}
@@ -218,12 +218,12 @@ MLI_FORCE_INLINE l_T mli_math_min_fx(l_T L, r_T R) {
218218 return (L < R) ? L : R;
219219}
220220
221- template <>
221+ template <>
222222MLI_FORCE_INLINE v2q15_t mli_math_min_fx (v2q15_t L, v2q15_t R) {
223223 return fx_min_v2q15 (L, R);
224224}
225225
226- template <typename l_T, typename r_T>
226+ template <typename l_T, typename r_T>
227227MLI_FORCE_INLINE v2q15_t mli_math_min_fx (v2q15_t L, r_T R) {
228228 return fx_min_v2q15 (L, fx_replic_v2q15 (R));
229229}
@@ -327,6 +327,11 @@ template <> MLI_FORCE_INLINE mli_acc32_t mli_math_acc_ashift_fx(mli_acc32_t acc,
327327}
328328
329329template <> MLI_FORCE_INLINE mli_acc40_t mli_math_acc_ashift_fx (mli_acc40_t acc, int shift_right) {
330+ if (shift_right > 0 ) {
331+ mli_acc40_t rnd = {((1ll << shift_right) >> 1 )};
332+ acc = fx_add_a40 (acc, rnd);
333+ }
334+
330335 return fx_asr_a40 (acc, shift_right);
331336}
332337
@@ -386,7 +391,7 @@ template < typename in_T > MLI_FORCE_INLINE void *mli_math_cast_scalar_to_ptr_fx
386391
387392// Comparators
388393// ========================================================================
389- template < typename io_T >
394+ template < typename io_T >
390395static MLI_FORCE_INLINE bool mli_prv_less_than_1 (io_T value, uint8_t frac_bits) {
391396 if (frac_bits >= sizeof (io_T) * 8 - 1 )
392397 return true ;
0 commit comments