Преглед изворни кода

CMSIS-DSP: Fixed compilation issue with AC5 compiler for test framework.

Christophe Favergeon пре 6 година
родитељ
комит
dcddf67beb

+ 11 - 6
CMSIS/DSP/Testing/FrameworkInclude/Error.h

@@ -155,8 +155,18 @@ void assert_near_equal(unsigned long nb,T pa, T pb, T threshold)
     }
 };
 
+template <> 
+void assert_near_equal(unsigned long nb,double pa, double pb, double threshold);
 template <> 
 void assert_near_equal(unsigned long nb,float32_t pa, float32_t pb, float32_t threshold);
+template <> 
+void assert_near_equal(unsigned long nb,q63_t pa, q63_t pb, q63_t threshold);
+template <> 
+void assert_near_equal(unsigned long nb,q31_t pa, q31_t pb, q31_t threshold);
+template <> 
+void assert_near_equal(unsigned long nb,q15_t pa, q15_t pb, q15_t threshold);
+template <> 
+void assert_near_equal(unsigned long nb,q7_t pa, q7_t pb, q7_t threshold);
 
 template <typename T> 
 void assert_near_equal(unsigned long nb,AnyPattern<T> &pa, AnyPattern<T> &pb, T threshold)
@@ -177,15 +187,10 @@ void assert_near_equal(unsigned long nb,AnyPattern<T> &pa, AnyPattern<T> &pb, T
 
     for(i=0; i < pa.nbSamples(); i++)
     {
-       if (abs(ptrA[i] - ptrB[i]) > threshold)
-       {
-         throw (Error(NEAR_EQUAL_ERROR,nb));
-       }
+       assert_near_equal(nb,ptrA[i],ptrB[i],threshold);
     }
 };
 
-template <> 
-void assert_near_equal(unsigned long nb,AnyPattern<float32_t> &pa, AnyPattern<float32_t> &pb, float32_t threshold);
 
 }
 #endif

+ 41 - 17
CMSIS/DSP/Testing/FrameworkSource/Error.cpp

@@ -27,6 +27,7 @@
  */
 #include "arm_math.h"
 #include "Error.h"
+#include <stdlib.h> 
 
 namespace Client {
 
@@ -43,8 +44,9 @@ void assert_not_empty_generic(unsigned long nb, AnyPattern<T> &p)
    }
 };
 
+
 template <> 
-void assert_near_equal(unsigned long nb,float32_t pa, float32_t pb, float32_t threshold)
+void assert_near_equal(unsigned long nb,double pa, double pb, double threshold)
 {
     if (fabs(pa - pb) > threshold)
     {
@@ -52,31 +54,53 @@ void assert_near_equal(unsigned long nb,float32_t pa, float32_t pb, float32_t th
     }
 };
 
-template <>
-void assert_near_equal(unsigned long nb,AnyPattern<float32_t> &pa, AnyPattern<float32_t> &pb, float32_t threshold)
+template <> 
+void assert_near_equal(unsigned long nb,float32_t pa, float32_t pb, float32_t threshold)
 {
-    ASSERT_NOT_EMPTY(pa);
-    ASSERT_NOT_EMPTY(pb);
+    if (fabs(pa - pb) > threshold)
+    {
+         throw (Error(EQUAL_ERROR,nb));
+    }
+};
 
-    if (pa.nbSamples() != pb.nbSamples())
+
+template <> 
+void assert_near_equal(unsigned long nb,q63_t pa, q63_t pb, q63_t threshold)
+{
+    if (abs(pa - pb) > threshold)
     {
-        throw (Error(DIFFERENT_LENGTH_ERROR,nb));
+         throw (Error(EQUAL_ERROR,nb));
     }
+};
 
-    unsigned long i=0;
+template <> 
+void assert_near_equal(unsigned long nb,q31_t pa, q31_t pb, q31_t threshold)
+{
+    if (abs(pa - pb) > threshold)
+    {
+         throw (Error(EQUAL_ERROR,nb));
+    }
+};
 
-    float32_t *ptrA = pa.ptr();
-    float32_t *ptrB = pb.ptr();
+template <> 
+void assert_near_equal(unsigned long nb,q15_t pa, q15_t pb, q15_t threshold)
+{
+    if (abs(pa - pb) > threshold)
+    {
+         throw (Error(EQUAL_ERROR,nb));
+    }
+};
 
-    for(i=0; i < pa.nbSamples(); i++)
+template <> 
+void assert_near_equal(unsigned long nb,q7_t pa, q7_t pb, q7_t threshold)
+{
+    if (abs(pa - pb) > threshold)
     {
-       if (fabs(ptrA[i] - ptrB[i]) > threshold)
-       {
-         throw (Error(NEAR_EQUAL_ERROR,nb));
-       }
+         throw (Error(EQUAL_ERROR,nb));
     }
 };
 
+
 void assert_not_empty(unsigned long nb, AnyPattern<float32_t> &p)
 {
   assert_not_empty_generic(nb,p);
@@ -216,8 +240,8 @@ float arm_snr_q63(q63_t *pRef, q63_t *pTest, uint32_t buffSize)
   for (i = 0; i < buffSize; i++)
     {
      
-      testVal = ((float32_t)pTest[i])  / 9223372036854775808.0;
-      refVal = ((float32_t)pRef[i])  / 9223372036854775808.0;
+      testVal = ((double)pTest[i])  / 9223372036854775808.0;
+      refVal = ((double)pRef[i])  / 9223372036854775808.0;
 
       EnergySignal += refVal * refVal;
       EnergyError += (refVal - testVal) * (refVal - testVal);

+ 1 - 1
CMSIS/DSP/Testing/Source/Tests/BasicTestsQ7.cpp

@@ -71,7 +71,7 @@ q7_t *outp=output.ptr();
 
         ASSERT_EMPTY_TAIL(output);
 
-        ASSERT_SNR(output,ref,(float32_t)SNR_THRESHOLD - 1.0);
+        ASSERT_SNR(output,ref,(float32_t)SNR_THRESHOLD - 1.0f);
 
         ASSERT_NEAR_EQ(output,ref,ABS_ERROR_Q7);
        

+ 1 - 1
CMSIS/NN/Source/ReshapeFunctions/arm_reshape_s8.c

@@ -51,4 +51,4 @@ void arm_reshape_s8(const int8_t *input,
                     const uint32_t total_size)
 {
     memcpy(output, input, total_size);
-}
+}