XCORE SDK
XCORE Software Development Kit
bfp_s32.h
1 // Copyright 2020-2021 XMOS LIMITED.
2 // This Software is subject to the terms of the XMOS Public Licence: Version 1.
3 
4 #pragma once
5 
6 #include "xs3_math_types.h"
7 
8 
9 
10 /*
11  Saturation Logic:
12 
13  Where specified, the VPU-enhanced arithmetic functions apply symmetric saturation logic, which is applied
14  where results would otherwise overflow.
15 
16  The resulting integer range for N-bit saturation is -(2^(N-1))+1 to (2^(N-1))-1.
17 
18  8-bit: (-127, 127)
19  16-bit: (-65535, 65535)
20  32-bit: (-2147483647, 2147483647)
21 */
22 
55 C_API
56 void bfp_s32_set(
57  bfp_s32_t* a,
58  const int32_t b,
59  const exponent_t exp);
60 
61 
112 C_API
114  bfp_s32_t* a,
115  const exponent_t exp);
116 
117 
144 C_API
146  bfp_s32_t* b);
147 
148 
182 C_API
183 void bfp_s32_shl(
184  bfp_s32_t* a,
185  const bfp_s32_t* b,
186  const left_shift_t b_shl);
187 
188 
208 C_API
209 void bfp_s32_add(
210  bfp_s32_t* a,
211  const bfp_s32_t* b,
212  const bfp_s32_t* c);
213 
214 
235 C_API
236 void bfp_s32_add_scalar(
237  bfp_s32_t* a,
238  const bfp_s32_t* b,
239  const float_s32_t c);
240 
241 
262 C_API
263 void bfp_s32_sub(
264  bfp_s32_t* a,
265  const bfp_s32_t* b,
266  const bfp_s32_t* c);
267 
268 
291 C_API
292 void bfp_s32_mul(
293  bfp_s32_t* a,
294  const bfp_s32_t* b,
295  const bfp_s32_t* c);
296 
297 
314 C_API
315 void bfp_s32_macc(
316  bfp_s32_t* acc,
317  const bfp_s32_t* b,
318  const bfp_s32_t* c);
319 
320 
337 C_API
338 void bfp_s32_nmacc(
339  bfp_s32_t* acc,
340  const bfp_s32_t* b,
341  const bfp_s32_t* c);
342 
343 
367 C_API
368 void bfp_s32_scale(
369  bfp_s32_t* a,
370  const bfp_s32_t* b,
371  const float_s32_t alpha);
372 
373 
395 C_API
396 void bfp_s32_abs(
397  bfp_s32_t* a,
398  const bfp_s32_t* b);
399 
400 
421 C_API
423  const bfp_s32_t* b);
424 
425 
447 C_API
449  const bfp_s32_t* b,
450  const bfp_s32_t* c);
451 
452 
482 C_API
483 void bfp_s32_clip(
484  bfp_s32_t* a,
485  const bfp_s32_t* b,
486  const int32_t lower_bound,
487  const int32_t upper_bound,
488  const int bound_exp);
489 
490 
515 C_API
516 void bfp_s32_rect(
517  bfp_s32_t* a,
518  const bfp_s32_t* b);
519 
541 C_API
542 void bfp_s32_to_s16(
543  bfp_s16_t* a,
544  const bfp_s32_t* b);
545 
546 
576 C_API
577 void bfp_s32_sqrt(
578  bfp_s32_t* a,
579  const bfp_s32_t* b);
580 
581 
603 C_API
604 void bfp_s32_inverse(
605  bfp_s32_t* a,
606  const bfp_s32_t* b);
607 
608 
628 C_API
630  const bfp_s32_t* b);
631 
632 
652 C_API
654  const bfp_s32_t* b);
655 
656 
676 C_API
678  const bfp_s32_t* b);
679 
680 
702 C_API
704  const bfp_s32_t* b);
705 
706 
726 C_API
728  const bfp_s32_t* b);
729 
730 
754 C_API
756  bfp_s32_t* a,
757  const bfp_s32_t* b,
758  const bfp_s32_t* c);
759 
760 
780 C_API
782  const bfp_s32_t* b);
783 
784 
808 C_API
810  bfp_s32_t* a,
811  const bfp_s32_t* b,
812  const bfp_s32_t* c);
813 
814 
840 C_API
841 unsigned bfp_s32_argmax(
842  const bfp_s32_t* b);
843 
844 
870 C_API
871 unsigned bfp_s32_argmin(
872  const bfp_s32_t* b);
873 
874 
913 C_API
915  bfp_s32_t* y,
916  const bfp_s32_t* x,
917  const int32_t b_q30[],
918  const unsigned b_length);
919 
920 
966 C_API
968  bfp_s32_t* y,
969  const bfp_s32_t* x,
970  const int32_t b_q30[],
971  const unsigned b_length,
972  const pad_mode_e padding_mode);
void bfp_s32_min_elementwise(bfp_s32_t *a, const bfp_s32_t *b, const bfp_s32_t *c)
Get the element-wise minimum of two 32-bit BFP vectors.
Definition: bfp_s32.c:426
void bfp_s32_shl(bfp_s32_t *a, const bfp_s32_t *b, const left_shift_t b_shl)
Apply a left-shift to the mantissas of a 32-bit BFP vector.
Definition: bfp_s32.c:45
float_s32_t bfp_s32_mean(const bfp_s32_t *b)
Get the mean value of a 32-bit BFP vector.
Definition: bfp_s32.c:313
void bfp_s32_add(bfp_s32_t *a, const bfp_s32_t *b, const bfp_s32_t *c)
Add two 32-bit BFP vectors together.
Definition: bfp_s32.c:60
headroom_t bfp_s32_headroom(bfp_s32_t *b)
Get the headroom of a 32-bit BFP vector.
Definition: bfp_s32.c:15
unsigned bfp_s32_argmin(const bfp_s32_t *b)
Get the index of the minimum value of a 32-bit BFP vector.
Definition: bfp_s32.c:461
void bfp_s32_add_scalar(bfp_s32_t *a, const bfp_s32_t *b, const float_s32_t c)
Add a scalar to a 32-bit BFP vector.
Definition: bfp_s32.c:79
void bfp_s32_clip(bfp_s32_t *a, const bfp_s32_t *b, const int32_t lower_bound, const int32_t upper_bound, const int bound_exp)
Definition: bfp_s32.c:205
void bfp_s32_macc(bfp_s32_t *acc, const bfp_s32_t *b, const bfp_s32_t *c)
Multiply one 32-bit BFP vector by another element-wise and add the result to a third vector.
Definition: bfp_s32.c:492
void bfp_s32_to_s16(bfp_s16_t *a, const bfp_s32_t *b)
Convert a 32-bit BFP vector into a 16-bit BFP vector.
Definition: bfp_s32.c:472
float_s32_t bfp_s32_max(const bfp_s32_t *b)
Get the maximum value of a 32-bit BFP vector.
Definition: bfp_s32.c:374
void bfp_s32_inverse(bfp_s32_t *a, const bfp_s32_t *b)
Get the inverses of elements of a 32-bit BFP vector.
Definition: bfp_s32.c:282
void bfp_s32_scale(bfp_s32_t *a, const bfp_s32_t *b, const float_s32_t alpha)
Multiply a 32-bit BFP vector by a scalar.
Definition: bfp_s32.c:138
float_s64_t bfp_s32_sum(const bfp_s32_t *b)
Sum the elements of a 32-bit BFP vector.
Definition: bfp_s32.c:172
void bfp_s32_set(bfp_s32_t *a, const int32_t b, const exponent_t exp)
Set all elements of a 32-bit BFP vector to a specified value.
Definition: bfp_init.c:97
float_s32_t bfp_s32_rms(const bfp_s32_t *b)
Get the RMS value of elements of a 32-bit BFP vector.
Definition: bfp_s32.c:355
float_s32_t bfp_s32_min(const bfp_s32_t *b)
Get the minimum value of a 32-bit BFP vector.
Definition: bfp_s32.c:412
void bfp_s32_mul(bfp_s32_t *a, const bfp_s32_t *b, const bfp_s32_t *c)
Multiply one 32-bit BFP vector by another element-wise.
Definition: bfp_s32.c:120
void bfp_s32_rect(bfp_s32_t *a, const bfp_s32_t *b)
Rectify a 32-bit BFP vector.
Definition: bfp_s32.c:251
void bfp_s32_nmacc(bfp_s32_t *acc, const bfp_s32_t *b, const bfp_s32_t *c)
Multiply one 32-bit BFP vector by another element-wise and subtract the result from a third vector.
Definition: bfp_s32.c:513
void bfp_s32_convolve_same(bfp_s32_t *y, const bfp_s32_t *x, const int32_t b_q30[], const unsigned b_length, const pad_mode_e padding_mode)
Convolve a 32-bit BFP vector with a short convolution kernel ("same" mode).
Definition: bfp_s32.c:553
void bfp_s32_sqrt(bfp_s32_t *a, const bfp_s32_t *b)
Get the square roots of elements of a 32-bit BFP vector.
Definition: bfp_s32.c:265
float_s64_t bfp_s32_abs_sum(const bfp_s32_t *b)
Sum the absolute values of elements of a 32-bit BFP vector.
Definition: bfp_s32.c:299
float_s64_t bfp_s32_dot(const bfp_s32_t *b, const bfp_s32_t *c)
Compute the inner product of two 32-bit BFP vectors.
Definition: bfp_s32.c:186
void bfp_s32_abs(bfp_s32_t *a, const bfp_s32_t *b)
Get the absolute values of elements of a 32-bit BFP vector.
Definition: bfp_s32.c:158
void bfp_s32_sub(bfp_s32_t *a, const bfp_s32_t *b, const bfp_s32_t *c)
Subtract one 32-bit BFP vector from another.
Definition: bfp_s32.c:101
float_s64_t bfp_s32_energy(const bfp_s32_t *b)
Get the energy (sum of squared of elements) of a 32-bit BFP vector.
Definition: bfp_s32.c:340
unsigned bfp_s32_argmax(const bfp_s32_t *b)
Get the index of the maximum value of a 32-bit BFP vector.
Definition: bfp_s32.c:450
void bfp_s32_use_exponent(bfp_s32_t *a, const exponent_t exp)
Modify a 32-bit BFP vector to use a specified exponent.
Definition: bfp_s32.c:28
void bfp_s32_convolve_valid(bfp_s32_t *y, const bfp_s32_t *x, const int32_t b_q30[], const unsigned b_length)
Convolve a 32-bit BFP vector with a short convolution kernel ("valid" mode).
Definition: bfp_s32.c:535
void bfp_s32_max_elementwise(bfp_s32_t *a, const bfp_s32_t *b, const bfp_s32_t *c)
Get the element-wise maximum of two 32-bit BFP vectors.
Definition: bfp_s32.c:388
int exponent_t
An exponent.
Definition: xs3_math_types.h:76
int left_shift_t
A leftwards arithmetic bit-shift.
Definition: xs3_math_types.h:110
unsigned headroom_t
Headroom of some integer or integer array.
Definition: xs3_math_types.h:86
pad_mode_e
Supported padding modes for convolutions in "same" mode.
Definition: xs3_vect_s32.h:2149
[bfp_s32_t]
Definition: xs3_math_types.h:309
A block floating-point vector of 32-bit elements.
Definition: xs3_math_types.h:276
A floating-point scalar with a 32-bit mantissa.
Definition: xs3_math_types.h:167
A floating-point scalar with a 64-bit mantissa.
Definition: xs3_math_types.h:190