Skip to content

Commit

Permalink
CMSIS-DSP: Remove some gcc compilation warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
christophe0606 committed Apr 29, 2021
1 parent 5bc9e87 commit 8adff0d
Show file tree
Hide file tree
Showing 27 changed files with 128 additions and 95 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ int32_t main(void)

/* Result of the classifier */
float32_t result[NB_OF_CLASSES];
float32_t temp[NB_OF_CLASSES];
float32_t maxProba;
uint32_t index;

Expand All @@ -105,7 +106,7 @@ int32_t main(void)
in[0] = 1.5f;
in[1] = 1.0f;

index = arm_gaussian_naive_bayes_predict_f32(&S, in, result);
index = arm_gaussian_naive_bayes_predict_f32(&S, in, result,temp);

maxProba = result[index];

Expand All @@ -116,7 +117,7 @@ int32_t main(void)
in[0] = -1.5f;
in[1] = 1.0f;

index = arm_gaussian_naive_bayes_predict_f32(&S, in, result);
index = arm_gaussian_naive_bayes_predict_f32(&S, in, result,temp);

maxProba = result[index];

Expand All @@ -127,7 +128,7 @@ int32_t main(void)
in[0] = 0.0f;
in[1] = -3.0f;

index = arm_gaussian_naive_bayes_predict_f32(&S, in, result);
index = arm_gaussian_naive_bayes_predict_f32(&S, in, result,temp);

maxProba = result[index];

Expand Down
10 changes: 6 additions & 4 deletions CMSIS/DSP/Include/dsp/bayes_functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,19 @@ typedef struct
/**
* @brief Naive Gaussian Bayesian Estimator
*
* @param[in] S points to a naive bayes instance structure
* @param[in] in points to the elements of the input vector.
* @param[in] pBuffer points to a buffer of length numberOfClasses
* @param[in] S points to a naive bayes instance structure
* @param[in] in points to the elements of the input vector.
* @param[out] *pOutputProbabilities points to a buffer of length numberOfClasses containing estimated probabilities
* @param[out] *pBufferB points to a temporary buffer of length numberOfClasses
* @return The predicted class
*
*/


uint32_t arm_gaussian_naive_bayes_predict_f32(const arm_gaussian_naive_bayes_instance_f32 *S,
const float32_t * in,
float32_t *pBuffer);
float32_t *pOutputProbabilities,
float32_t *pBufferB);


#ifdef __cplusplus
Expand Down
10 changes: 6 additions & 4 deletions CMSIS/DSP/Include/dsp/bayes_functions_f16.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,19 @@ typedef struct
/**
* @brief Naive Gaussian Bayesian Estimator
*
* @param[in] S points to a naive bayes instance structure
* @param[in] in points to the elements of the input vector.
* @param[in] pBuffer points to a buffer of length numberOfClasses
* @param[in] S points to a naive bayes instance structure
* @param[in] in points to the elements of the input vector.
* @param[out] *pOutputProbabilities points to a buffer of length numberOfClasses containing estimated probabilities
* @param[out] *pBufferB points to a temporary buffer of length numberOfClasses
* @return The predicted class
*
*/


uint32_t arm_gaussian_naive_bayes_predict_f16(const arm_gaussian_naive_bayes_instance_f16 *S,
const float16_t * in,
float16_t *pBuffer);
float16_t *pOutputProbabilities,
float16_t *pBufferB);

#endif /*defined(ARM_FLOAT16_SUPPORTED)*/
#ifdef __cplusplus
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,12 @@
/**
* @brief Naive Gaussian Bayesian Estimator
*
* @param[in] *S points to a naive bayes instance structure
* @param[in] *in points to the elements of the input vector.
* @param[in] *pBuffer points to a buffer of length numberOfClasses
* @param[in] *S points to a naive bayes instance structure
* @param[in] *in points to the elements of the input vector.
* @param[out] *pOutputProbabilities points to a buffer of length numberOfClasses containing estimated probabilities
* @param[out] *pBufferB points to a temporary buffer of length numberOfClasses
* @return The predicted class
*
* @par If the number of classes is big, MVE version will consume lot of
* stack since the log prior are computed on the stack.
*
*/

Expand All @@ -60,19 +59,21 @@

uint32_t arm_gaussian_naive_bayes_predict_f16(const arm_gaussian_naive_bayes_instance_f16 *S,
const float16_t * in,
float16_t *pBuffer)
float16_t *pOutputProbabilities,
float16_t *pBufferB
)
{
uint32_t nbClass;
const float16_t *pTheta = S->theta;
const float16_t *pSigma = S->sigma;
float16_t *buffer = pBuffer;
float16_t *buffer = pOutputProbabilities;
const float16_t *pIn = in;
float16_t result;
f16x8_t vsigma;
_Float16 tmp;
f16x8_t vacc1, vacc2;
uint32_t index;
float16_t logclassPriors[S->numberOfClasses];
float16_t *logclassPriors=pBufferB;
float16_t *pLogPrior = logclassPriors;

arm_vlog_f16((float16_t *) S->classPriors, logclassPriors, S->numberOfClasses);
Expand Down Expand Up @@ -135,38 +136,31 @@ uint32_t arm_gaussian_naive_bayes_predict_f16(const arm_gaussian_naive_bayes_ins
buffer++;
}

arm_max_f16(pBuffer, S->numberOfClasses, &result, &index);
arm_max_f16(pOutputProbabilities, S->numberOfClasses, &result, &index);

return (index);
}

#else

/**
* @brief Naive Gaussian Bayesian Estimator
*
* @param[in] *S points to a naive bayes instance structure
* @param[in] *in points to the elements of the input vector.
* @param[in] *pBuffer points to a buffer of length numberOfClasses
* @return The predicted class
*
*/
uint32_t arm_gaussian_naive_bayes_predict_f16(const arm_gaussian_naive_bayes_instance_f16 *S,
const float16_t * in,
float16_t *pBuffer)
float16_t *pOutputProbabilities,
float16_t *pBufferB)
{
uint32_t nbClass;
uint32_t nbDim;
const float16_t *pPrior = S->classPriors;
const float16_t *pTheta = S->theta;
const float16_t *pSigma = S->sigma;
float16_t *buffer = pBuffer;
float16_t *buffer = pOutputProbabilities;
const float16_t *pIn=in;
float16_t result;
_Float16 sigma;
_Float16 tmp;
_Float16 acc1,acc2;
uint32_t index;
(void)pBufferB;

pTheta=S->theta;
pSigma=S->sigma;
Expand Down Expand Up @@ -199,7 +193,7 @@ uint32_t arm_gaussian_naive_bayes_predict_f16(const arm_gaussian_naive_bayes_ins
buffer++;
}

arm_max_f16(pBuffer,S->numberOfClasses,&result,&index);
arm_max_f16(pOutputProbabilities,S->numberOfClasses,&result,&index);

return(index);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,12 @@
/**
* @brief Naive Gaussian Bayesian Estimator
*
* @param[in] *S points to a naive bayes instance structure
* @param[in] *in points to the elements of the input vector.
* @param[in] *pBuffer points to a buffer of length numberOfClasses
* @param[in] *S points to a naive bayes instance structure
* @param[in] *in points to the elements of the input vector.
* @param[out] *pOutputProbabilities points to a buffer of length numberOfClasses containing estimated probabilities
* @param[out] *pBufferB points to a temporary buffer of length numberOfClasses
* @return The predicted class
*
* @par If the number of classes is big, MVE version will consume lot of
* stack since the log prior are computed on the stack.
*
*/

Expand All @@ -58,19 +57,21 @@

uint32_t arm_gaussian_naive_bayes_predict_f32(const arm_gaussian_naive_bayes_instance_f32 *S,
const float32_t * in,
float32_t *pBuffer)
float32_t *pOutputProbabilities,
float32_t *pBufferB
)
{
uint32_t nbClass;
const float32_t *pTheta = S->theta;
const float32_t *pSigma = S->sigma;
float32_t *buffer = pBuffer;
float32_t *buffer = pOutputProbabilities;
const float32_t *pIn = in;
float32_t result;
f32x4_t vsigma;
float32_t tmp;
f32x4_t vacc1, vacc2;
uint32_t index;
float32_t logclassPriors[S->numberOfClasses];
float32_t *logclassPriors=pBufferB;
float32_t *pLogPrior = logclassPriors;

arm_vlog_f32((float32_t *) S->classPriors, logclassPriors, S->numberOfClasses);
Expand Down Expand Up @@ -133,7 +134,7 @@ uint32_t arm_gaussian_naive_bayes_predict_f32(const arm_gaussian_naive_bayes_ins
buffer++;
}

arm_max_f32(pBuffer, S->numberOfClasses, &result, &index);
arm_max_f32(pOutputProbabilities, S->numberOfClasses, &result, &index);

return (index);
}
Expand All @@ -148,7 +149,8 @@ uint32_t arm_gaussian_naive_bayes_predict_f32(const arm_gaussian_naive_bayes_ins

uint32_t arm_gaussian_naive_bayes_predict_f32(const arm_gaussian_naive_bayes_instance_f32 *S,
const float32_t * in,
float32_t *pBuffer)
float32_t *pOutputProbabilities,
float32_t *pBufferB)
{

const float32_t *pPrior = S->classPriors;
Expand All @@ -159,7 +161,7 @@ uint32_t arm_gaussian_naive_bayes_predict_f32(const arm_gaussian_naive_bayes_ins
const float32_t *pTheta1 = S->theta + S->vectorDimension;
const float32_t *pSigma1 = S->sigma + S->vectorDimension;

float32_t *buffer = pBuffer;
float32_t *buffer = pOutputProbabilities;
const float32_t *pIn=in;

float32_t result;
Expand All @@ -174,6 +176,7 @@ uint32_t arm_gaussian_naive_bayes_predict_f32(const arm_gaussian_naive_bayes_ins
float32x2_t tmpV2;
float32x4_t thetaV,thetaV1;
float32x4_t inV;
(void)pBufferB;

epsilonV = vdupq_n_f32(S->epsilon);

Expand Down Expand Up @@ -322,39 +325,33 @@ uint32_t arm_gaussian_naive_bayes_predict_f32(const arm_gaussian_naive_bayes_ins
classBlkCnt--;
}

arm_max_f32(pBuffer,S->numberOfClasses,&result,&index);
arm_max_f32(pOutputProbabilities,S->numberOfClasses,&result,&index);

return(index);
}

#else

/**
* @brief Naive Gaussian Bayesian Estimator
*
* @param[in] *S points to a naive bayes instance structure
* @param[in] *in points to the elements of the input vector.
* @param[in] *pBuffer points to a buffer of length numberOfClasses
* @return The predicted class
*
*/
uint32_t arm_gaussian_naive_bayes_predict_f32(const arm_gaussian_naive_bayes_instance_f32 *S,
const float32_t * in,
float32_t *pBuffer)
float32_t *pOutputProbabilities,
float32_t *pBufferB)
{
uint32_t nbClass;
uint32_t nbDim;
const float32_t *pPrior = S->classPriors;
const float32_t *pTheta = S->theta;
const float32_t *pSigma = S->sigma;
float32_t *buffer = pBuffer;
float32_t *buffer = pOutputProbabilities;
const float32_t *pIn=in;
float32_t result;
float32_t sigma;
float32_t tmp;
float32_t acc1,acc2;
uint32_t index;

(void)pBufferB;

pTheta=S->theta;
pSigma=S->sigma;

Expand Down Expand Up @@ -386,7 +383,7 @@ uint32_t arm_gaussian_naive_bayes_predict_f32(const arm_gaussian_naive_bayes_ins
buffer++;
}

arm_max_f32(pBuffer,S->numberOfClasses,&result,&index);
arm_max_f32(pOutputProbabilities,S->numberOfClasses,&result,&index);

return(index);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ void arm_cmplx_mult_real_f16(
float16_t * pCmplxDst,
uint32_t numSamples)
{
const static uint16_t stride_cmplx_x_real_16[8] = {
static const uint16_t stride_cmplx_x_real_16[8] = {
0, 0, 1, 1, 2, 2, 3, 3
};
uint32_t blockSizeC = numSamples * CMPLX_DIM; /* loop counters */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ void arm_cmplx_mult_real_f32(
float32_t * pCmplxDst,
uint32_t numSamples)
{
const static uint32_t stride_cmplx_x_real_32[4] = { 0, 0, 1, 1 };
static const uint32_t stride_cmplx_x_real_32[4] = { 0, 0, 1, 1 };

uint32_t blockSizeC = numSamples * CMPLX_DIM; /* loop counters */
uint32_t blkCnt;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ void arm_cmplx_mult_real_q15(
q15_t * pCmplxDst,
uint32_t numSamples)
{
const static uint16_t stride_cmplx_x_real_16[8] = {
static const uint16_t stride_cmplx_x_real_16[8] = {
0, 0, 1, 1, 2, 2, 3, 3
};
q15x8_t rVec;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ void arm_cmplx_mult_real_q31(
uint32_t numSamples)
{

const static uint32_t stride_cmplx_x_real_32[4] = {
static const uint32_t stride_cmplx_x_real_32[4] = {
0, 0, 1, 1
};
q31x4_t rVec;
Expand Down
2 changes: 1 addition & 1 deletion CMSIS/DSP/Source/FilteringFunctions/arm_conv_partial_f32.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ arm_status arm_conv_partial_f32(
blockSize3 = ((int32_t)check > (int32_t)srcALen) ? (int32_t)check - (int32_t)srcALen : 0;
blockSize3 = ((int32_t)firstIndex > (int32_t)srcALen - 1) ? blockSize3 - (int32_t)firstIndex + (int32_t)srcALen : blockSize3;
blockSize1 = ((int32_t) srcBLen - 1) - (int32_t) firstIndex;
blockSize1 = (blockSize1 > 0) ? ((check > (srcBLen - 1U)) ? blockSize1 : numPoints) : 0;
blockSize1 = (blockSize1 > 0) ? ((check > (srcBLen - 1U)) ? blockSize1 : (int32_t)numPoints) : 0;
blockSize2 = ((int32_t) check - blockSize3) - (blockSize1 + (int32_t) firstIndex);
blockSize2 = (blockSize2 > 0) ? blockSize2 : 0;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ arm_status arm_conv_partial_fast_q31(
blockSize3 = ((int32_t)check > (int32_t)srcALen) ? (int32_t)check - (int32_t)srcALen : 0;
blockSize3 = ((int32_t)firstIndex > (int32_t)srcALen - 1) ? blockSize3 - (int32_t)firstIndex + (int32_t)srcALen : blockSize3;
blockSize1 = ((int32_t) srcBLen - 1) - (int32_t) firstIndex;
blockSize1 = (blockSize1 > 0) ? ((check > (srcBLen - 1U)) ? blockSize1 : numPoints) : 0;
blockSize1 = (blockSize1 > 0) ? ((check > (srcBLen - 1U)) ? blockSize1 : (int32_t)numPoints) : 0;
blockSize2 = (int32_t) check - ((blockSize3 + blockSize1) + (int32_t) firstIndex);
blockSize2 = (blockSize2 > 0) ? blockSize2 : 0;

Expand Down
2 changes: 1 addition & 1 deletion CMSIS/DSP/Source/FilteringFunctions/arm_conv_partial_q15.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ arm_status arm_conv_partial_q15(
blockSize3 = ((int32_t)check > (int32_t)srcALen) ? (int32_t)check - (int32_t)srcALen : 0;
blockSize3 = ((int32_t)firstIndex > (int32_t)srcALen - 1) ? blockSize3 - (int32_t)firstIndex + (int32_t)srcALen : blockSize3;
blockSize1 = ((int32_t) srcBLen - 1) - (int32_t) firstIndex;
blockSize1 = (blockSize1 > 0) ? ((check > (srcBLen - 1U)) ? blockSize1 : numPoints) : 0;
blockSize1 = (blockSize1 > 0) ? ((check > (srcBLen - 1U)) ? blockSize1 : (int32_t)numPoints) : 0;
blockSize2 = (int32_t) check - ((blockSize3 + blockSize1) + (int32_t) firstIndex);
blockSize2 = (blockSize2 > 0) ? blockSize2 : 0;

Expand Down
2 changes: 1 addition & 1 deletion CMSIS/DSP/Source/FilteringFunctions/arm_conv_partial_q31.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ arm_status arm_conv_partial_q31(
blockSize3 = ((int32_t)check > (int32_t)srcALen) ? (int32_t)check - (int32_t)srcALen : 0;
blockSize3 = ((int32_t)firstIndex > (int32_t)srcALen - 1) ? blockSize3 - (int32_t)firstIndex + (int32_t)srcALen : blockSize3;
blockSize1 = ((int32_t) srcBLen - 1) - (int32_t) firstIndex;
blockSize1 = (blockSize1 > 0) ? ((check > (srcBLen - 1U)) ? blockSize1 : numPoints) : 0;
blockSize1 = (blockSize1 > 0) ? ((check > (srcBLen - 1U)) ? blockSize1 : (int32_t)numPoints) : 0;
blockSize2 = (int32_t) check - ((blockSize3 + blockSize1) + (int32_t) firstIndex);
blockSize2 = (blockSize2 > 0) ? blockSize2 : 0;

Expand Down
2 changes: 1 addition & 1 deletion CMSIS/DSP/Source/FilteringFunctions/arm_conv_partial_q7.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ arm_status arm_conv_partial_q7(
blockSize3 = ((int32_t)check > (int32_t)srcALen) ? (int32_t)check - (int32_t)srcALen : 0;
blockSize3 = ((int32_t)firstIndex > (int32_t)srcALen - 1) ? blockSize3 - (int32_t)firstIndex + (int32_t)srcALen : blockSize3;
blockSize1 = ((int32_t) srcBLen - 1) - (int32_t) firstIndex;
blockSize1 = (blockSize1 > 0) ? ((check > (srcBLen - 1U)) ? blockSize1 : numPoints) : 0;
blockSize1 = (blockSize1 > 0) ? ((check > (srcBLen - 1U)) ? blockSize1 : (int32_t)numPoints) : 0;
blockSize2 = (int32_t) check - ((blockSize3 + blockSize1) + (int32_t) firstIndex);
blockSize2 = (blockSize2 > 0) ? blockSize2 : 0;

Expand Down

0 comments on commit 8adff0d

Please sign in to comment.