Skip to content

Commit bc00d19

Browse files
Correct issue ARM-software#198 : weighted sum is a weighted average
1 parent fc6da81 commit bc00d19

File tree

15 files changed

+60
-59
lines changed

15 files changed

+60
-59
lines changed

Include/dsp/support_functions.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -499,16 +499,16 @@ const q7_t * pSrc,
499499

500500

501501
/**
502-
* @brief Weighted sum
502+
* @brief Weighted average
503503
*
504504
*
505505
* @param[in] *in Array of input values.
506506
* @param[in] *weigths Weights
507507
* @param[in] blockSize Number of samples in the input array.
508-
* @return Weighted sum
508+
* @return Weighted average
509509
*
510510
*/
511-
float32_t arm_weighted_sum_f32(const float32_t *in
511+
float32_t arm_weighted_average_f32(const float32_t *in
512512
, const float32_t *weigths
513513
, uint32_t blockSize);
514514

Include/dsp/support_functions_f16.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,13 @@ void arm_f16_to_float(const float16_t * pSrc, float32_t * pDst, uint32_t blockSi
113113

114114

115115
/**
116-
* @brief Weighted sum
116+
* @brief Weighted average
117117
* @param[in] *in Array of input values.
118118
* @param[in] *weigths Weights
119119
* @param[in] blockSize Number of samples in the input array.
120-
* @return Weighted sum
120+
* @return Weighted average
121121
*/
122-
float16_t arm_weighted_sum_f16(const float16_t *in
122+
float16_t arm_weighted_average_f16(const float16_t *in
123123
, const float16_t *weigths
124124
, uint32_t blockSize);
125125

PythonWrapper/cmsisdsp_pkg/src/cmsisdsp_support.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -901,7 +901,7 @@ cmsis_arm_barycenter_f32(PyObject *obj, PyObject *args)
901901
}
902902

903903
static PyObject *
904-
cmsis_arm_weighted_sum_f32(PyObject *obj, PyObject *args)
904+
cmsis_arm_weighted_average_f32(PyObject *obj, PyObject *args)
905905
{
906906

907907
PyObject *pSrcA=NULL; // input
@@ -919,7 +919,7 @@ cmsis_arm_weighted_sum_f32(PyObject *obj, PyObject *args)
919919
blockSize = arraySizepSrcA ;
920920

921921

922-
dst=arm_weighted_sum_f32(pSrcA_converted,pSrcB_converted,blockSize);
922+
dst=arm_weighted_average_f32(pSrcA_converted,pSrcB_converted,blockSize);
923923
PyObject* pDstOBJ=Py_BuildValue("f",dst);
924924
PyObject *pythonResult = Py_BuildValue("O",pDstOBJ);
925925

@@ -993,7 +993,7 @@ static PyMethodDef CMSISDSPMethods[] = {
993993
{"arm_sort_f32", cmsis_arm_sort_f32, METH_VARARGS,""},
994994
{"arm_sort_init_f32", cmsis_arm_sort_init_f32, METH_VARARGS,""},
995995
{"arm_barycenter_f32", cmsis_arm_barycenter_f32, METH_VARARGS,""},
996-
{"arm_weighted_sum_f32", cmsis_arm_weighted_sum_f32, METH_VARARGS,""},
996+
{"arm_weighted_average_f32", cmsis_arm_weighted_average_f32, METH_VARARGS,""},
997997

998998
{"error_out", (PyCFunction)error_out, METH_NOARGS, NULL},
999999
{NULL, NULL, 0, NULL} /* Sentinel */

Source/SupportFunctions/Config.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ SupportFunctions/arm_quick_sort_f32.c
4646
SupportFunctions/arm_selection_sort_f32.c
4747
SupportFunctions/arm_sort_f32.c
4848
SupportFunctions/arm_sort_init_f32.c
49-
SupportFunctions/arm_weighted_sum_f32.c
49+
SupportFunctions/arm_weighted_average_f32.c
5050
)
5151

5252

@@ -59,7 +59,7 @@ target_sources(CMSISDSP PRIVATE SupportFunctions/arm_f16_to_q15.c)
5959
target_sources(CMSISDSP PRIVATE SupportFunctions/arm_q15_to_f16.c)
6060
target_sources(CMSISDSP PRIVATE SupportFunctions/arm_float_to_f16.c)
6161
target_sources(CMSISDSP PRIVATE SupportFunctions/arm_f16_to_float.c)
62-
target_sources(CMSISDSP PRIVATE SupportFunctions/arm_weighted_sum_f16.c)
62+
target_sources(CMSISDSP PRIVATE SupportFunctions/arm_weighted_average_f16.c)
6363
target_sources(CMSISDSP PRIVATE SupportFunctions/arm_barycenter_f16.c)
6464
target_sources(CMSISDSP PRIVATE SupportFunctions/arm_f16_to_f64.c)
6565
target_sources(CMSISDSP PRIVATE SupportFunctions/arm_f64_to_f16.c)

Source/SupportFunctions/SupportFunctions.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
#include "arm_selection_sort_f32.c"
4848
#include "arm_sort_f32.c"
4949
#include "arm_sort_init_f32.c"
50-
#include "arm_weighted_sum_f32.c"
50+
#include "arm_weighted_average_f32.c"
5151

5252
#include "arm_f64_to_float.c"
5353
#include "arm_f64_to_q31.c"

Source/SupportFunctions/SupportFunctionsF16.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,5 @@
3434
#include "arm_f64_to_f16.c"
3535
#include "arm_q15_to_f16.c"
3636
#include "arm_float_to_f16.c"
37-
#include "arm_weighted_sum_f16.c"
37+
#include "arm_weighted_average_f16.c"
3838
#include "arm_barycenter_f16.c"

Source/SupportFunctions/arm_weighted_sum_f16.c renamed to Source/SupportFunctions/arm_weighted_average_f16.c

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* ----------------------------------------------------------------------
22
* Project: CMSIS DSP Library
3-
* Title: arm_weighted_sum_f16.c
4-
* Description: Weighted Sum
3+
* Title: arm_weighted_average_f16.c
4+
* Description: Weighted average
55
*
66
* $Date: 23 April 2021
77
* $Revision: V1.9.0
@@ -38,34 +38,35 @@
3838
*/
3939

4040
/**
41-
@defgroup weightedsum Weighted Sum
41+
@defgroup weightedaverage Weighted Average
4242
43-
Weighted sum of values
43+
Weighted average of values
4444
*/
4545

4646

4747
/**
48-
* @addtogroup weightedsum
48+
* @addtogroup weightedaverage
4949
* @{
5050
*/
5151

5252

5353
/**
54-
* @brief Weighted sum
54+
* @brief Weighted average
5555
*
5656
*
5757
* @param[in] *in Array of input values.
5858
* @param[in] *weigths Weights
5959
* @param[in] blockSize Number of samples in the input array.
60-
* @return Weighted sum
60+
*
61+
* @return Weighted average
6162
*
6263
*/
6364

6465
#if defined(ARM_MATH_MVE_FLOAT16) && !defined(ARM_MATH_AUTOVECTORIZE)
6566

6667
#include "arm_helium_utils.h"
6768

68-
ARM_DSP_ATTRIBUTE float16_t arm_weighted_sum_f16(const float16_t *in,const float16_t *weigths, uint32_t blockSize)
69+
ARM_DSP_ATTRIBUTE float16_t arm_weighted_average_f16(const float16_t *in,const float16_t *weigths, uint32_t blockSize)
6970
{
7071
_Float16 accum1, accum2;
7172
float16x8_t accum1V, accum2V;
@@ -112,7 +113,7 @@ ARM_DSP_ATTRIBUTE float16_t arm_weighted_sum_f16(const float16_t *in,const float
112113

113114
#else
114115

115-
ARM_DSP_ATTRIBUTE float16_t arm_weighted_sum_f16(const float16_t *in, const float16_t *weigths, uint32_t blockSize)
116+
ARM_DSP_ATTRIBUTE float16_t arm_weighted_average_f16(const float16_t *in, const float16_t *weigths, uint32_t blockSize)
116117
{
117118

118119
_Float16 accum1, accum2;
@@ -139,7 +140,7 @@ ARM_DSP_ATTRIBUTE float16_t arm_weighted_sum_f16(const float16_t *in, const floa
139140
#endif /* defined(ARM_MATH_MVEF) && !defined(ARM_MATH_AUTOVECTORIZE) */
140141

141142
/**
142-
* @} end of weightedsum group
143+
* @} end of weightedaverage group
143144
*/
144145

145146
#endif /* #if defined(ARM_FLOAT16_SUPPORTED) */

Source/SupportFunctions/arm_weighted_sum_f32.c renamed to Source/SupportFunctions/arm_weighted_average_f32.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* ----------------------------------------------------------------------
22
* Project: CMSIS DSP Library
3-
* Title: arm_weighted_sum_f32.c
4-
* Description: Weighted Sum
3+
* Title: arm_weighted_average_f32.c
4+
* Description: Weighted Average
55
*
66
* $Date: 23 April 2021
77
* $Revision: V1.9.0
@@ -32,27 +32,27 @@
3232
#include "dsp/support_functions.h"
3333

3434
/**
35-
* @addtogroup weightedsum
35+
* @addtogroup weightedaverage
3636
* @{
3737
*/
3838

3939

4040
/**
41-
* @brief Weighted sum
41+
* @brief Weighted average
4242
*
4343
*
4444
* @param[in] *in Array of input values.
4545
* @param[in] *weigths Weights
4646
* @param[in] blockSize Number of samples in the input array.
47-
* @return Weighted sum
47+
* @return Weighted average
4848
*
4949
*/
5050

5151
#if defined(ARM_MATH_MVEF) && !defined(ARM_MATH_AUTOVECTORIZE)
5252

5353
#include "arm_helium_utils.h"
5454

55-
ARM_DSP_ATTRIBUTE float32_t arm_weighted_sum_f32(const float32_t *in,const float32_t *weigths, uint32_t blockSize)
55+
ARM_DSP_ATTRIBUTE float32_t arm_weighted_average_f32(const float32_t *in,const float32_t *weigths, uint32_t blockSize)
5656
{
5757
float32_t accum1, accum2;
5858
f32x4_t accum1V, accum2V;
@@ -101,7 +101,7 @@ ARM_DSP_ATTRIBUTE float32_t arm_weighted_sum_f32(const float32_t *in,const float
101101
#if defined(ARM_MATH_NEON)
102102

103103
#include "NEMath.h"
104-
ARM_DSP_ATTRIBUTE float32_t arm_weighted_sum_f32(const float32_t *in,const float32_t *weigths, uint32_t blockSize)
104+
ARM_DSP_ATTRIBUTE float32_t arm_weighted_average_f32(const float32_t *in,const float32_t *weigths, uint32_t blockSize)
105105
{
106106

107107
float32_t accum1, accum2;
@@ -155,7 +155,7 @@ ARM_DSP_ATTRIBUTE float32_t arm_weighted_sum_f32(const float32_t *in,const float
155155
return(accum1 / accum2);
156156
}
157157
#else
158-
ARM_DSP_ATTRIBUTE float32_t arm_weighted_sum_f32(const float32_t *in, const float32_t *weigths, uint32_t blockSize)
158+
ARM_DSP_ATTRIBUTE float32_t arm_weighted_average_f32(const float32_t *in, const float32_t *weigths, uint32_t blockSize)
159159
{
160160

161161
float32_t accum1, accum2;
@@ -183,5 +183,5 @@ ARM_DSP_ATTRIBUTE float32_t arm_weighted_sum_f32(const float32_t *in, const floa
183183
#endif /* defined(ARM_MATH_MVEF) && !defined(ARM_MATH_AUTOVECTORIZE) */
184184

185185
/**
186-
* @} end of weightedsum group
186+
* @} end of weightedaverage group
187187
*/

Testing/Source/Benchmarks/SupportF16.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@
2323
arm_float_to_f16(this->pSrcF32,this->pDst,this->nbSamples);
2424
}
2525

26-
void SupportF16::test_weighted_sum_f16()
26+
void SupportF16::test_weighted_average_f16()
2727
{
28-
arm_weighted_sum_f16(this->pSrc, this->pWeights,this->nbSamples);
28+
arm_weighted_average_f16(this->pSrc, this->pWeights,this->nbSamples);
2929
}
3030

3131
void SupportF16::setUp(Testing::testID_t id,std::vector<Testing::param_t>& params,Client::PatternMgr *mgr)
@@ -56,7 +56,7 @@
5656
break;
5757

5858

59-
case TEST_WEIGHTED_SUM_F16_5:
59+
case TEST_WEIGHTED_AVERAGE_F16_5:
6060
samples.reload(SupportF16::INPUTS6_F16_ID,mgr,this->nbSamples);
6161
weights.reload(SupportF16::WEIGHTS6_F16_ID,mgr,this->nbSamples);
6262

Testing/Source/Benchmarks/SupportF32.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@
2727
arm_q31_to_float(this->pSrcQ31,this->pDst,this->nbSamples);
2828
}
2929

30-
void SupportF32::test_weighted_sum_f32()
30+
void SupportF32::test_weighted_average_f32()
3131
{
32-
arm_weighted_sum_f32(this->pSrc, this->pWeights,this->nbSamples);
32+
arm_weighted_average_f32(this->pSrc, this->pWeights,this->nbSamples);
3333
}
3434

3535
void SupportF32::setUp(Testing::testID_t id,std::vector<Testing::param_t>& params,Client::PatternMgr *mgr)
@@ -64,7 +64,7 @@
6464
this->pSrcQ7=samplesQ7.ptr();
6565
break;
6666

67-
case TEST_WEIGHTED_SUM_F32_6:
67+
case TEST_WEIGHTED_AVERAGE_F32_6:
6868
samples.reload(SupportF32::INPUTS6_F32_ID,mgr,this->nbSamples);
6969
weights.reload(SupportF32::WEIGHTS6_F32_ID,mgr,this->nbSamples);
7070

0 commit comments

Comments
 (0)