CMSIS-DSP:Added tests for arm_linear_interp f32, q31, q15 and q7.

pull/19/head
Christophe Favergeon 6 years ago
parent 9fdf799b23
commit ceca332b10

@ -194,6 +194,10 @@ set(TESTSRC
Source/Tests/BIQUADQ15.cpp
Source/Tests/Pooling.cpp
Source/Tests/Softmax.cpp
Source/Tests/InterpolationTestsF32.cpp
Source/Tests/InterpolationTestsQ31.cpp
Source/Tests/InterpolationTestsQ15.cpp
Source/Tests/InterpolationTestsQ7.cpp
Source/Tests/NNSupport.cpp
Source/Tests/ExampleCategoryF32.cpp
Source/Tests/ExampleCategoryQ31.cpp

@ -0,0 +1,19 @@
#include "Test.h"
#include "Pattern.h"
class InterpolationTestsF32:public Client::Suite
{
public:
InterpolationTestsF32(Testing::testID_t id);
virtual void setUp(Testing::testID_t,std::vector<Testing::param_t>& params,Client::PatternMgr *mgr);
virtual void tearDown(Testing::testID_t,Client::PatternMgr *mgr);
private:
#include "InterpolationTestsF32_decl.h"
Client::Pattern<float32_t> input;
Client::Pattern<float32_t> y;
Client::LocalPattern<float32_t> output;
// Reference patterns are not loaded when we are in dump mode
Client::RefPattern<float32_t> ref;
arm_linear_interp_instance_f32 S;
};

@ -0,0 +1,18 @@
#include "Test.h"
#include "Pattern.h"
class InterpolationTestsQ15:public Client::Suite
{
public:
InterpolationTestsQ15(Testing::testID_t id);
virtual void setUp(Testing::testID_t,std::vector<Testing::param_t>& params,Client::PatternMgr *mgr);
virtual void tearDown(Testing::testID_t,Client::PatternMgr *mgr);
private:
#include "InterpolationTestsQ15_decl.h"
Client::Pattern<q31_t> input;
Client::Pattern<q15_t> y;
Client::LocalPattern<q15_t> output;
// Reference patterns are not loaded when we are in dump mode
Client::RefPattern<q15_t> ref;
};

@ -0,0 +1,18 @@
#include "Test.h"
#include "Pattern.h"
class InterpolationTestsQ31:public Client::Suite
{
public:
InterpolationTestsQ31(Testing::testID_t id);
virtual void setUp(Testing::testID_t,std::vector<Testing::param_t>& params,Client::PatternMgr *mgr);
virtual void tearDown(Testing::testID_t,Client::PatternMgr *mgr);
private:
#include "InterpolationTestsQ31_decl.h"
Client::Pattern<q31_t> input;
Client::Pattern<q31_t> y;
Client::LocalPattern<q31_t> output;
// Reference patterns are not loaded when we are in dump mode
Client::RefPattern<q31_t> ref;
};

@ -0,0 +1,18 @@
#include "Test.h"
#include "Pattern.h"
class InterpolationTestsQ7:public Client::Suite
{
public:
InterpolationTestsQ7(Testing::testID_t id);
virtual void setUp(Testing::testID_t,std::vector<Testing::param_t>& params,Client::PatternMgr *mgr);
virtual void tearDown(Testing::testID_t,Client::PatternMgr *mgr);
private:
#include "InterpolationTestsQ7_decl.h"
Client::Pattern<q31_t> input;
Client::Pattern<q7_t> y;
Client::LocalPattern<q7_t> output;
// Reference patterns are not loaded when we are in dump mode
Client::RefPattern<q7_t> ref;
};

@ -25,6 +25,7 @@ Decimate.generatePatterns()
Distance.generatePatterns()
FastMath.generatePatterns()
FIR.generatePatterns()
Interpolate.generatePatterns()
Matrix.generatePatterns()
Softmax.generatePatterns()
Stats.generatePatterns()

@ -0,0 +1,53 @@
import os.path
import numpy as np
import itertools
import Tools
from scipy.interpolate import interp1d
# Those patterns are used for tests and benchmarks.
# For tests, there is the need to add tests for saturation
def writeTests(config,format):
NBSAMPLES=40
x = np.linspace(0, NBSAMPLES, num=NBSAMPLES+1, endpoint=True)
y = np.cos(-x**2/(NBSAMPLES - 1))
f = interp1d(x, y)
data=x+0.5
data=data[:-1]
z = f(data)
if format != 0:
data = data / 2.0**11
if format != 0:
config.writeInputQ31(1, data,"Input")
else:
config.writeInput(1, data)
config.writeInput(1, y,"YVals")
ref = z
config.writeReference(1, ref)
def generatePatterns():
PATTERNDIR = os.path.join("Patterns","DSP","Interpolation","Interpolation")
PARAMDIR = os.path.join("Parameters","DSP","Interpolation","Interpolation")
configf32=Tools.Config(PATTERNDIR,PARAMDIR,"f32")
configq31=Tools.Config(PATTERNDIR,PARAMDIR,"q31")
configq15=Tools.Config(PATTERNDIR,PARAMDIR,"q15")
configq7=Tools.Config(PATTERNDIR,PARAMDIR,"q7")
writeTests(configf32,0)
writeTests(configq31,31)
writeTests(configq15,15)
writeTests(configq7,7)
if __name__ == '__main__':
generatePatterns()

@ -0,0 +1,82 @@
W
40
// 0.500000
0x3f000000
// 1.500000
0x3fc00000
// 2.500000
0x40200000
// 3.500000
0x40600000
// 4.500000
0x40900000
// 5.500000
0x40b00000
// 6.500000
0x40d00000
// 7.500000
0x40f00000
// 8.500000
0x41080000
// 9.500000
0x41180000
// 10.500000
0x41280000
// 11.500000
0x41380000
// 12.500000
0x41480000
// 13.500000
0x41580000
// 14.500000
0x41680000
// 15.500000
0x41780000
// 16.500000
0x41840000
// 17.500000
0x418c0000
// 18.500000
0x41940000
// 19.500000
0x419c0000
// 20.500000
0x41a40000
// 21.500000
0x41ac0000
// 22.500000
0x41b40000
// 23.500000
0x41bc0000
// 24.500000
0x41c40000
// 25.500000
0x41cc0000
// 26.500000
0x41d40000
// 27.500000
0x41dc0000
// 28.500000
0x41e40000
// 29.500000
0x41ec0000
// 30.500000
0x41f40000
// 31.500000
0x41fc0000
// 32.500000
0x42020000
// 33.500000
0x42060000
// 34.500000
0x420a0000
// 35.500000
0x420e0000
// 36.500000
0x42120000
// 37.500000
0x42160000
// 38.500000
0x421a0000
// 39.500000
0x421e0000

@ -0,0 +1,82 @@
W
40
// 0.999836
0x3f7ff53b
// 0.997208
0x3f7f4908
// 0.984118
0x3f7bef25
// 0.945255
0x3f71fc36
// 0.859251
0x3f5bf7db
// 0.702426
0x3f33d232
// 0.456301
0x3ee9a049
// 0.119531
0x3df4cc6e
// -0.277482
0xbe8e122d
// -0.661314
0xbf294be6
// -0.918537
0xbf6b253e
// -0.925695
0xbf6cfa51
// -0.611097
0xbf1c70d9
// -0.030945
0xbcfd7f9a
// 0.589481
0x3f16e834
// 0.915804
0x3f6a7228
// 0.695054
0x3f31ef13
// -0.004498
0xbb9367b4
// -0.712082
0xbf364afd
// -0.829765
0xbf546b7a
// -0.183298
0xbe3bb262
// 0.647457
0x3f25bfbd
// 0.765024
0x3f43d8a0
// -0.024301
0xbcc71299
// -0.770387
0xbf453819
// -0.447708
0xbee53a07
// 0.521104
0x3f056717
// 0.650064
0x3f266a9a
// -0.298863
0xbe9904a3
// -0.688210
0xbf302e8f
// 0.207648
0x3e54a1be
// 0.656951
0x3f282dea
// -0.253282
0xbe81ae2d
// -0.570816
0xbf1220fa
// 0.398647
0x3ecc1b6e
// 0.379176
0x3ec2236a
// -0.548368
0xbf0c61d1
// -0.036721
0xbd1668f6
// 0.524152
0x3f062ed8
// -0.358152
0xbeb75fc4

@ -0,0 +1,84 @@
W
41
// 1.000000
0x3f800000
// 0.999671
0x3f7fea75
// 0.994745
0x3f7ea79a
// 0.973491
0x3f7936b0
// 0.917019
0x3f6ac1bb
// 0.801483
0x3f4d2dfb
// 0.603369
0x3f1a7669
// 0.309233
0x3e9e53bf
// -0.070172
0xbd8fb620
// -0.484793
0xbef836d2
// -0.837836
0xbf567c63
// -0.999238
0xbf7fce18
// -0.852151
0xbf5a268a
// -0.370043
0xbebd7651
// 0.308154
0x3e9dc65e
// 0.870807
0x3f5eed38
// 0.960802
0x3f75f717
// 0.429307
0x3edbce1d
// -0.438304
0xbee0695b
// -0.985860
0xbf7c614c
// -0.673670
0xbf2c75a9
// 0.307075
0x3e9d38f0
// 0.987839
0x3f7ce303
// 0.542209
0x3f0ace3c
// -0.590811
0xbf173f66
// -0.949963
0xbf7330cc
// 0.054547
0x3d5f6c50
// 0.987662
0x3f7cd76a
// 0.312466
0x3e9ffb93
// -0.910193
0xbf69026c
// -0.466228
0xbeeeb565
// 0.881524
0x3f61ab91
// 0.432377
0x3edd6086
// -0.938941
0xbf705e6f
// -0.202690
0xbe4f8e12
// 0.999984
0x3f7ffef2
// -0.241631
0xbe776e22
// -0.855104
0xbf5ae819
// 0.781662
0x3f481afa
// 0.266643
0x3e88856c
// -0.982948
0xbf7ba27a

@ -0,0 +1,82 @@
W
40
// 0.000244
0x00080000
// 0.000732
0x00180000
// 0.001221
0x00280000
// 0.001709
0x00380000
// 0.002197
0x00480000
// 0.002686
0x00580000
// 0.003174
0x00680000
// 0.003662
0x00780000
// 0.004150
0x00880000
// 0.004639
0x00980000
// 0.005127
0x00A80000
// 0.005615
0x00B80000
// 0.006104
0x00C80000
// 0.006592
0x00D80000
// 0.007080
0x00E80000
// 0.007568
0x00F80000
// 0.008057
0x01080000
// 0.008545
0x01180000
// 0.009033
0x01280000
// 0.009521
0x01380000
// 0.010010
0x01480000
// 0.010498
0x01580000
// 0.010986
0x01680000
// 0.011475
0x01780000
// 0.011963
0x01880000
// 0.012451
0x01980000
// 0.012939
0x01A80000
// 0.013428
0x01B80000
// 0.013916
0x01C80000
// 0.014404
0x01D80000
// 0.014893
0x01E80000
// 0.015381
0x01F80000
// 0.015869
0x02080000
// 0.016357
0x02180000
// 0.016846
0x02280000
// 0.017334
0x02380000
// 0.017822
0x02480000
// 0.018311
0x02580000
// 0.018799
0x02680000
// 0.019287
0x02780000

@ -0,0 +1,82 @@
H
40
// 0.999836
0x7FFB
// 0.997208
0x7FA5
// 0.984118
0x7DF8
// 0.945255
0x78FE
// 0.859251
0x6DFC
// 0.702426
0x59E9
// 0.456301
0x3A68
// 0.119531
0x0F4D
// -0.277482
0xDC7B
// -0.661314
0xAB5A
// -0.918537
0x8A6D
// -0.925695
0x8983
// -0.611097
0xB1C8
// -0.030945
0xFC0A
// 0.589481
0x4B74
// 0.915804
0x7539
// 0.695054
0x58F8
// -0.004498
0xFF6D
// -0.712082
0xA4DB
// -0.829765
0x95CA
// -0.183298
0xE88A
// 0.647457
0x52E0
// 0.765024
0x61EC
// -0.024301
0xFCE4
// -0.770387
0x9D64
// -0.447708
0xC6B1
// 0.521104
0x42B4
// 0.650064
0x5335
// -0.298863
0xD9BF
// -0.688210
0xA7E9
// 0.207648
0x1A94
// 0.656951
0x5417
// -0.253282
0xDF94
// -0.570816
0xB6F0
// 0.398647
0x3307
// 0.379176
0x3089
// -0.548368
0xB9CF
// -0.036721
0xFB4D
// 0.524152
0x4317
// -0.358152
0xD228

@ -0,0 +1,84 @@
H
41
// 1.000000
0x7FFF
// 0.999671
0x7FF5
// 0.994745
0x7F54
// 0.973491
0x7C9B
// 0.917019
0x7561
// 0.801483
0x6697
// 0.603369
0x4D3B
// 0.309233
0x2795
// -0.070172
0xF705
// -0.484793
0xC1F2
// -0.837836
0x94C2
// -0.999238
0x8019
// -0.852151
0x92ED
// -0.370043
0xD0A2
// 0.308154
0x2772
// 0.870807
0x6F77
// 0.960802
0x7AFC
// 0.429307
0x36F4
// -0.438304
0xC7E6
// -0.985860
0x81CF
// -0.673670
0xA9C5
// 0.307075
0x274E
// 0.987839
0x7E72
// 0.542209
0x4567
// -0.590811
0xB460
// -0.949963
0x8668
// 0.054547
0x06FB
// 0.987662
0x7E6C
// 0.312466
0x27FF
// -0.910193
0x8B7F
// -0.466228
0xC453
// 0.881524
0x70D6
// 0.432377
0x3758
// -0.938941
0x87D1
// -0.202690
0xE60E
// 0.999984
0x7FFF
// -0.241631
0xE112
// -0.855104
0x928C
// 0.781662
0x640D
// 0.266643
0x2221
// -0.982948
0x822F

@ -0,0 +1,82 @@
W
40
// 0.000244
0x00080000
// 0.000732
0x00180000
// 0.001221
0x00280000
// 0.001709
0x00380000
// 0.002197
0x00480000
// 0.002686
0x00580000
// 0.003174
0x00680000
// 0.003662
0x00780000
// 0.004150
0x00880000
// 0.004639
0x00980000
// 0.005127
0x00A80000
// 0.005615
0x00B80000
// 0.006104
0x00C80000
// 0.006592
0x00D80000
// 0.007080
0x00E80000
// 0.007568
0x00F80000
// 0.008057
0x01080000
// 0.008545
0x01180000
// 0.009033
0x01280000
// 0.009521
0x01380000
// 0.010010
0x01480000
// 0.010498
0x01580000
// 0.010986
0x01680000
// 0.011475
0x01780000
// 0.011963
0x01880000
// 0.012451
0x01980000
// 0.012939
0x01A80000
// 0.013428
0x01B80000
// 0.013916
0x01C80000
// 0.014404
0x01D80000
// 0.014893
0x01E80000
// 0.015381
0x01F80000
// 0.015869
0x02080000
// 0.016357
0x02180000
// 0.016846
0x02280000
// 0.017334
0x02380000
// 0.017822
0x02480000
// 0.018311
0x02580000
// 0.018799
0x02680000
// 0.019287
0x02780000

@ -0,0 +1,82 @@
W
40
// 0.999836
0x7FFA9D47
// 0.997208
0x7FA483D7
// 0.984118
0x7DF792AA
// 0.945255
0x78FE1AD3
// 0.859251
0x6DFBED5A
// 0.702426
0x59E918D9
// 0.456301
0x3A681221
// 0.119531
0x0F4CC6E6
// -0.277482
0xDC7B74C7
// -0.661314
0xAB5A0CFB
// -0.918537
0x8A6D613A
// -0.925695
0x8982D786
// -0.611097
0xB1C79353
// -0.030945
0xFC0A0199
// 0.589481
0x4B7419C6
// 0.915804
0x753913C6
// 0.695054
0x58F7896E
// -0.004498
0xFF6C984C
// -0.712082
0xA4DA81BA
// -0.829765
0x95CA42E6
// -0.183298
0xE889B3C1
// 0.647457
0x52DFDEA1
// 0.765024
0x61EC4FCA
// -0.024301
0xFCE3B59E
// -0.770387
0x9D63F365
// -0.447708
0xC6B17E22
// 0.521104
0x42B38BB9
// 0.650064
0x53354CCE
// -0.298863
0xD9BED74A
// -0.688210
0xA7E8B864
// 0.207648
0x1A9437BE
// 0.656951
0x5416F502
// -0.253282
0xDF9474DD
// -0.570816
0xB6EF8307
// 0.398647
0x3306DB70
// 0.379176
0x3088DA74
// -0.548368
0xB9CF17B9
// -0.036721
0xFB4CB84E
// 0.524152
0x43176BFA
// -0.358152
0xD2280F1C

@ -0,0 +1,84 @@
W
41
// 1.000000
0x7FFFFFFF
// 0.999671
0x7FF53A8E
// 0.994745
0x7F53CD1F
// 0.973491
0x7C9B5835
// 0.917019
0x7560DD71
// 0.801483
0x6696FD43
// 0.603369
0x4D3B346F
// 0.309233
0x2794EFD3
// -0.070172
0xF7049DF8
// -0.484793
0xC1F24B95
// -0.837836
0x94C1CE62
// -0.999238
0x8018F412
// -0.852151
0x92ECBAF9
// -0.370043
0xD0A26BAC
// 0.308154
0x27719787
// 0.870807
0x6F769C05
// 0.960802
0x7AFB8B87
// 0.429307
0x36F38755
// -0.438304
0xC7E5A942
// -0.985860
0x81CF5A32
// -0.673670
0xA9C52B9A
// 0.307075
0x274E3BE8
// 0.987839
0x7E71815B
// 0.542209
0x45671E38
// -0.590811
0xB4604D03
// -0.949963
0x866799C7
// 0.054547
0x06FB627E
// 0.987662
0x7E6BB4F4
// 0.312466
0x27FEE4A7
// -0.910193
0x8B7EC9ED
// -0.466228
0xC452A6DC
// 0.881524
0x70D5C8A0
// 0.432377
0x37582165
// -0.938941
0x87D0C855
// -0.202690
0xE60E3DB9
// 0.999984
0x7FFF7927
// -0.241631
0xE1123BC0
// -0.855104
0x928BF3B1
// 0.781662
0x640D7CEB
// 0.266643
0x22215B09
// -0.982948
0x822EC32F

@ -0,0 +1,82 @@
W
40
// 0.000244
0x00080000
// 0.000732
0x00180000
// 0.001221
0x00280000
// 0.001709
0x00380000
// 0.002197
0x00480000
// 0.002686
0x00580000
// 0.003174
0x00680000
// 0.003662
0x00780000
// 0.004150
0x00880000
// 0.004639
0x00980000
// 0.005127
0x00A80000
// 0.005615
0x00B80000
// 0.006104
0x00C80000
// 0.006592
0x00D80000
// 0.007080
0x00E80000
// 0.007568
0x00F80000
// 0.008057
0x01080000
// 0.008545
0x01180000
// 0.009033
0x01280000
// 0.009521
0x01380000
// 0.010010
0x01480000
// 0.010498
0x01580000
// 0.010986
0x01680000
// 0.011475
0x01780000
// 0.011963
0x01880000
// 0.012451
0x01980000
// 0.012939
0x01A80000
// 0.013428
0x01B80000
// 0.013916
0x01C80000
// 0.014404
0x01D80000
// 0.014893
0x01E80000
// 0.015381
0x01F80000
// 0.015869
0x02080000
// 0.016357
0x02180000
// 0.016846
0x02280000
// 0.017334
0x02380000
// 0.017822
0x02480000
// 0.018311
0x02580000
// 0.018799
0x02680000
// 0.019287
0x02780000

@ -0,0 +1,82 @@
B
40
// 0.999836
0x7F
// 0.997208
0x7F
// 0.984118
0x7E
// 0.945255
0x79
// 0.859251
0x6E
// 0.702426
0x5A
// 0.456301
0x3A
// 0.119531
0x0F
// -0.277482
0xDC
// -0.661314
0xAB
// -0.918537
0x8A
// -0.925695
0x8A
// -0.611097
0xB2
// -0.030945
0xFC
// 0.589481
0x4B
// 0.915804
0x75
// 0.695054
0x59
// -0.004498
0xFF
// -0.712082
0xA5
// -0.829765
0x96
// -0.183298
0xE9
// 0.647457
0x53
// 0.765024
0x62
// -0.024301
0xFD
// -0.770387
0x9D
// -0.447708
0xC7
// 0.521104
0x43
// 0.650064
0x53
// -0.298863
0xDA
// -0.688210
0xA8
// 0.207648
0x1B
// 0.656951
0x54
// -0.253282
0xE0
// -0.570816
0xB7
// 0.398647
0x33
// 0.379176
0x31
// -0.548368
0xBA
// -0.036721
0xFB
// 0.524152
0x43
// -0.358152
0xD2

@ -0,0 +1,84 @@
B
41
// 1.000000
0x7F
// 0.999671
0x7F
// 0.994745
0x7F
// 0.973491
0x7D
// 0.917019
0x75
// 0.801483
0x67
// 0.603369
0x4D
// 0.309233
0x28
// -0.070172
0xF7
// -0.484793
0xC2
// -0.837836
0x95
// -0.999238
0x80
// -0.852151
0x93
// -0.370043
0xD1
// 0.308154
0x27
// 0.870807
0x6F
// 0.960802
0x7B
// 0.429307
0x37
// -0.438304
0xC8
// -0.985860
0x82
// -0.673670
0xAA
// 0.307075
0x27
// 0.987839
0x7E
// 0.542209
0x45
// -0.590811
0xB4
// -0.949963
0x86
// 0.054547
0x07
// 0.987662
0x7E
// 0.312466
0x28
// -0.910193
0x8B
// -0.466228
0xC4
// 0.881524
0x71
// 0.432377
0x37
// -0.938941
0x88
// -0.202690
0xE6
// 0.999984
0x7F
// -0.241631
0xE1
// -0.855104
0x93
// 0.781662
0x64
// 0.266643
0x22
// -0.982948
0x82

@ -0,0 +1,69 @@
#include "InterpolationTestsF32.h"
#include <stdio.h>
#include "Error.h"
#define SNR_THRESHOLD 120
/*
Reference patterns are generated with
a double precision computation.
*/
#define REL_ERROR (8.0e-6)
void InterpolationTestsF32::test_linear_interp_f32()
{
const float32_t *inp = input.ptr();
float32_t *outp = output.ptr();
int nb;
for(nb = 0; nb < input.nbSamples(); nb++)
{
outp[nb] = arm_linear_interp_f32(&S,inp[nb]);
}
ASSERT_EMPTY_TAIL(output);
ASSERT_SNR(output,ref,(float32_t)SNR_THRESHOLD);
ASSERT_REL_ERROR(output,ref,REL_ERROR);
}
void InterpolationTestsF32::setUp(Testing::testID_t id,std::vector<Testing::param_t>& params,Client::PatternMgr *mgr)
{
Testing::nbSamples_t nb=MAX_NB_SAMPLES;
switch(id)
{
case InterpolationTestsF32::TEST_LINEAR_INTERP_F32_1:
input.reload(InterpolationTestsF32::INPUT_F32_ID,mgr,nb);
y.reload(InterpolationTestsF32::YVAL_F32_ID,mgr,nb);
ref.reload(InterpolationTestsF32::REF_LINEAR_F32_ID,mgr,nb);
S.nValues=y.nbSamples(); /**< nValues */
/* Those values must be coherent with the ones in the
Python script generating the patterns */
S.x1=0.0; /**< x1 */
S.xSpacing=1.0; /**< xSpacing */
S.pYData=y.ptr(); /**< pointer to the table of Y values */
break;
}
output.create(ref.nbSamples(),InterpolationTestsF32::OUT_SAMPLES_F32_ID,mgr);
}
void InterpolationTestsF32::tearDown(Testing::testID_t id,Client::PatternMgr *mgr)
{
output.dump(mgr);
}

@ -0,0 +1,62 @@
#include "InterpolationTestsQ15.h"
#include <stdio.h>
#include "Error.h"
#define SNR_THRESHOLD 70
/*
Reference patterns are generated with
a double precision computation.
*/
#define ABS_ERROR_Q15 ((q15_t)2)
void InterpolationTestsQ15::test_linear_interp_q15()
{
const q31_t *inp = input.ptr();
q15_t *outp = output.ptr();
int nb;
for(nb = 0; nb < input.nbSamples(); nb++)
{
outp[nb] = arm_linear_interp_q15(y.ptr(),inp[nb],y.nbSamples());
}
ASSERT_EMPTY_TAIL(output);
ASSERT_SNR(output,ref,(float32_t)SNR_THRESHOLD);
ASSERT_NEAR_EQ(output,ref,ABS_ERROR_Q15);
}
void InterpolationTestsQ15::setUp(Testing::testID_t id,std::vector<Testing::param_t>& params,Client::PatternMgr *mgr)
{
Testing::nbSamples_t nb=MAX_NB_SAMPLES;
switch(id)
{
case InterpolationTestsQ15::TEST_LINEAR_INTERP_Q15_1:
input.reload(InterpolationTestsQ15::INPUT_Q31_ID,mgr,nb);
y.reload(InterpolationTestsQ15::YVAL_Q15_ID,mgr,nb);
ref.reload(InterpolationTestsQ15::REF_LINEAR_Q15_ID,mgr,nb);
break;
}
output.create(ref.nbSamples(),InterpolationTestsQ15::OUT_SAMPLES_Q15_ID,mgr);
}
void InterpolationTestsQ15::tearDown(Testing::testID_t id,Client::PatternMgr *mgr)
{
output.dump(mgr);
}

@ -0,0 +1,62 @@
#include "InterpolationTestsQ31.h"
#include <stdio.h>
#include "Error.h"
#define SNR_THRESHOLD 100
/*
Reference patterns are generated with
a double precision computation.
*/
#define ABS_ERROR_Q31 ((q31_t)5)
void InterpolationTestsQ31::test_linear_interp_q31()
{
const q31_t *inp = input.ptr();
q31_t *outp = output.ptr();
int nb;
for(nb = 0; nb < input.nbSamples(); nb++)
{
outp[nb] = arm_linear_interp_q31(y.ptr(),inp[nb],y.nbSamples());
}
ASSERT_EMPTY_TAIL(output);
ASSERT_SNR(output,ref,(float32_t)SNR_THRESHOLD);
ASSERT_NEAR_EQ(output,ref,ABS_ERROR_Q31);
}
void InterpolationTestsQ31::setUp(Testing::testID_t id,std::vector<Testing::param_t>& params,Client::PatternMgr *mgr)
{
Testing::nbSamples_t nb=MAX_NB_SAMPLES;
switch(id)
{
case InterpolationTestsQ31::TEST_LINEAR_INTERP_Q31_1:
input.reload(InterpolationTestsQ31::INPUT_Q31_ID,mgr,nb);
y.reload(InterpolationTestsQ31::YVAL_Q31_ID,mgr,nb);
ref.reload(InterpolationTestsQ31::REF_LINEAR_Q31_ID,mgr,nb);
break;
}
output.create(ref.nbSamples(),InterpolationTestsQ31::OUT_SAMPLES_Q31_ID,mgr);
}
void InterpolationTestsQ31::tearDown(Testing::testID_t id,Client::PatternMgr *mgr)
{
output.dump(mgr);
}

@ -0,0 +1,62 @@
#include "InterpolationTestsQ7.h"
#include <stdio.h>
#include "Error.h"
#define SNR_THRESHOLD 20
/*
Reference patterns are generated with
a double precision computation.
*/
#define ABS_ERROR_Q7 ((q7_t)2)
void InterpolationTestsQ7::test_linear_interp_q7()
{
const q31_t *inp = input.ptr();
q7_t *outp = output.ptr();
int nb;
for(nb = 0; nb < input.nbSamples(); nb++)
{
outp[nb] = arm_linear_interp_q7(y.ptr(),inp[nb],y.nbSamples());
}
ASSERT_EMPTY_TAIL(output);
ASSERT_SNR(output,ref,(float32_t)SNR_THRESHOLD);
ASSERT_NEAR_EQ(output,ref,ABS_ERROR_Q7);
}
void InterpolationTestsQ7::setUp(Testing::testID_t id,std::vector<Testing::param_t>& params,Client::PatternMgr *mgr)
{
Testing::nbSamples_t nb=MAX_NB_SAMPLES;
switch(id)
{
case InterpolationTestsQ7::TEST_LINEAR_INTERP_Q7_1:
input.reload(InterpolationTestsQ7::INPUT_Q31_ID,mgr,nb);
y.reload(InterpolationTestsQ7::YVAL_Q7_ID,mgr,nb);
ref.reload(InterpolationTestsQ7::REF_LINEAR_Q7_ID,mgr,nb);
break;
}
output.create(ref.nbSamples(),InterpolationTestsQ7::OUT_SAMPLES_Q7_ID,mgr);
}
void InterpolationTestsQ7::tearDown(Testing::testID_t id,Client::PatternMgr *mgr)
{
output.dump(mgr);
}

@ -453,6 +453,75 @@ group Root {
}
group Interpolation Tests{
class = InterpolationTests
folder = Interpolation
suite Interpolation Tests F32{
class = InterpolationTestsF32
folder = InterpolationF32
Pattern INPUT_F32_ID : Input1_f32.txt
Pattern YVAL_F32_ID : YVals1_f32.txt
Pattern REF_LINEAR_F32_ID : Reference1_f32.txt
Output OUT_SAMPLES_F32_ID : Output
Functions {
Test arm_linear_interp_f32:test_linear_interp_f32
}
}
suite Interpolation Tests Q31{
class = InterpolationTestsQ31
folder = InterpolationQ31
Pattern INPUT_Q31_ID : Input1_q31.txt
Pattern YVAL_Q31_ID : YVals1_q31.txt
Pattern REF_LINEAR_Q31_ID : Reference1_q31.txt
Output OUT_SAMPLES_Q31_ID : Output
Functions {
Test arm_linear_interp_q31:test_linear_interp_q31
}
}
suite Interpolation Tests Q15{
class = InterpolationTestsQ15
folder = InterpolationQ15
Pattern INPUT_Q31_ID : Input1_q31.txt
Pattern YVAL_Q15_ID : YVals1_q15.txt
Pattern REF_LINEAR_Q15_ID : Reference1_q15.txt
Output OUT_SAMPLES_Q15_ID : Output
Functions {
Test arm_linear_interp_q15:test_linear_interp_q15
}
}
suite Interpolation Tests Q7{
class = InterpolationTestsQ7
folder = InterpolationQ7
Pattern INPUT_Q31_ID : Input1_q31.txt
Pattern YVAL_Q7_ID : YVals1_q7.txt
Pattern REF_LINEAR_Q7_ID : Reference1_q7.txt
Output OUT_SAMPLES_Q7_ID : Output
Functions {
Test arm_linear_interp_q7:test_linear_interp_q7
}
}
}
group Basic Tests {
class = BasicTests
folder = BasicMaths

@ -79,6 +79,9 @@ processAndRun(BUILDFOLDER,FVP,"SupportBarTestsF32",custom=custom)
msg("Basic Tests")
processAndRun(BUILDFOLDER,FVP,"BasicTests",custom=custom)
msg("Interpolation Tests")
processAndRun(BUILDFOLDER,FVP,"InterpolationTests",custom=custom)
msg("Complex Tests")
processAndRun(BUILDFOLDER,FVP,"ComplexTests",custom=custom)

Loading…
Cancel
Save