~ruther/guix-local

ref: next-master guix-local/gnu/packages/patches/kissfft-tflite-micro.patch -rw-r--r-- 6.7 KiB
b989e013 — Andy Tai gnu: koboldcpp: Update to 1.106.2. 30 days ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
diff --git a/Makefile b/Makefile
index 96f43d3..d8e9be2 100644
--- a/Makefile
+++ b/Makefile
@@ -8,11 +8,11 @@ doc:
 
 testall:
 	# The simd and int32_t types may or may not work on your machine 
-	make -C test DATATYPE=simd CFLAGADD="$(CFLAGADD)" test
-	make -C test DATATYPE=int32_t CFLAGADD="$(CFLAGADD)" test
-	make -C test DATATYPE=int16_t CFLAGADD="$(CFLAGADD)" test
-	make -C test DATATYPE=float CFLAGADD="$(CFLAGADD)" test
-	make -C test DATATYPE=double CFLAGADD="$(CFLAGADD)" test
+	#make -C test DATATYPE=simd CFLAGADD="$(CFLAGADD)" test
+	#make -C test DATATYPE=int32_t CFLAGADD="$(CFLAGADD)" test
+	#make -C test DATATYPE=int16_t CFLAGADD="$(CFLAGADD)" test
+	#make -C test DATATYPE=float CFLAGADD="$(CFLAGADD)" test
+	#make -C test DATATYPE=double CFLAGADD="$(CFLAGADD)" test
 	echo "all tests passed"
 
 tarball: clean
diff --git a/_kiss_fft_guts.h b/_kiss_fft_guts.h
index ba66144..1a0f4c2 100644
--- a/_kiss_fft_guts.h
+++ b/_kiss_fft_guts.h
@@ -1,3 +1,6 @@
+#ifndef _KISS_FFT_GUTS_H
+#define _KISS_FFT_GUTS_H
+
 /*
 Copyright (c) 2003-2010, Mark Borgerding
 
@@ -135,7 +138,7 @@ struct kiss_fft_state{
 #else
 #  define KISS_FFT_COS(phase) (kiss_fft_scalar) cos(phase)
 #  define KISS_FFT_SIN(phase) (kiss_fft_scalar) sin(phase)
-#  define HALF_OF(x) ((x)*.5)
+#  define HALF_OF(x) ((x)*(kiss_fft_scalar).5)
 #endif
 
 #define  kf_cexp(x,phase) \
@@ -162,3 +165,4 @@ struct kiss_fft_state{
 #define  KISS_FFT_TMP_ALLOC(nbytes) KISS_FFT_MALLOC(nbytes)
 #define  KISS_FFT_TMP_FREE(ptr) KISS_FFT_FREE(ptr)
 #endif
+#endif // _KISS_FFT_GUTS_H
diff --git a/kiss_fft.c b/kiss_fft.c
index 465d6c9..9133a01 100644
--- a/kiss_fft.c
+++ b/kiss_fft.c
@@ -375,7 +375,7 @@ void kiss_fft_stride(kiss_fft_cfg st,const kiss_fft_cpx *fin,kiss_fft_cpx *fout,
         //It just performs an out-of-place FFT into a temp buffer
         kiss_fft_cpx * tmpbuf = (kiss_fft_cpx*)KISS_FFT_TMP_ALLOC( sizeof(kiss_fft_cpx)*st->nfft);
         kf_work(tmpbuf,fin,1,in_stride, st->factors,st);
-        memcpy(fout,tmpbuf,sizeof(kiss_fft_cpx)*st->nfft);
+        /* memcpy(fout,tmpbuf,sizeof(kiss_fft_cpx)*st->nfft); */
         KISS_FFT_TMP_FREE(tmpbuf);
     }else{
         kf_work( fout, fin, 1,in_stride, st->factors,st );
diff --git a/kiss_fft.h b/kiss_fft.h
index 64c50f4..24e4d0c 100644
--- a/kiss_fft.h
+++ b/kiss_fft.h
@@ -7,7 +7,7 @@
 #include <string.h>
 
 #ifdef __cplusplus
-extern "C" {
+extern "C++" {
 #endif
 
 /*
@@ -29,13 +29,13 @@ extern "C" {
 #define KISS_FFT_MALLOC(nbytes) _mm_malloc(nbytes,16)
 #define KISS_FFT_FREE _mm_free
 #else	
-#define KISS_FFT_MALLOC malloc
-#define KISS_FFT_FREE free
+#define KISS_FFT_MALLOC(X) (void*)(0x0) /* Patched. */
+#define KISS_FFT_FREE(X) /* Patched. */
 #endif	
 
 
 #ifdef FIXED_POINT
-#include <sys/types.h>	
+#include <stdint.h> /* Patched. */
 # if (FIXED_POINT == 32)
 #  define kiss_fft_scalar int32_t
 # else	
diff --git a/test/Makefile b/test/Makefile
index c204511..d2fe0ea 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -3,7 +3,7 @@ WARNINGS=-W -Wall -Wstrict-prototypes -Wmissing-prototypes -Waggregate-return \
     -Wcast-align -Wcast-qual -Wnested-externs -Wshadow -Wbad-function-cast \
     -Wwrite-strings
 
-CFLAGS=-O3 -I.. -I../tools $(WARNINGS)
+CFLAGS=-O3 -I.. -I../tools $(WARNINGS) -ggdb -O0
 CFLAGS+=-ffast-math -fomit-frame-pointer 
 #CFLAGS+=-funroll-loops
 #CFLAGS+=-march=prescott 
diff --git a/test/testkiss.py b/test/testkiss.py
index af75065..cae8494 100755
--- a/test/testkiss.py
+++ b/test/testkiss.py
@@ -5,7 +5,7 @@ import sys
 import os
 import random
 import struct
-import popen2
+import subprocess
 import getopt
 import numpy
 
@@ -35,11 +35,11 @@ elif datatype=='float':
 else:
     sys.stderr.write('unrecognized datatype %s\n' % datatype)
     sys.exit(1)
- 
+
 
 def dopack(x,cpx=1):
     x = numpy.reshape( x, ( numpy.size(x),) )
-    
+
     if cpx:
         s = ''.join( [ struct.pack(fmt*2,c.real,c.imag) for c in x ] )
     else:
@@ -89,7 +89,7 @@ def test_fft(ndims):
         xver = numpy.fft.rfftn(x)
     else:
         xver = numpy.fft.fftn(x)
-    
+
     open('/tmp/fftexp.dat','w').write(dopack( flatten(xver) , True ) )
 
     x2=dofft(x,doreal)
@@ -99,14 +99,14 @@ def test_fft(ndims):
     errpow = numpy.vdot(errf,errf)+1e-10
     sigpow = numpy.vdot(xverf,xverf)+1e-10
     snr = 10*math.log10(abs(sigpow/errpow) )
-    print 'SNR (compared to NumPy) : %.1fdB' % float(snr)
+    print( 'SNR (compared to NumPy) : %.1fdB' % float(snr))
 
     if snr<minsnr:
-        print 'xver=',xver
-        print 'x2=',x2
-        print 'err',err
+        print ('xver=',xver)
+        print ('x2=',x2)
+        print ('err',err)
         sys.exit(1)
- 
+
 def dofft(x,isreal):
     dims=list( numpy.shape(x) )
     x = flatten(x)
@@ -124,8 +124,8 @@ def dofft(x,isreal):
     if doreal:
         cmd += ' -R '
 
-    print cmd
-    p = popen2.Popen3(cmd )
+    print(cmd)
+    p = subprocess.Popen([cmd],stdin=subprocess.PIPE,stdout=subprocess.PIPE)
 
     open('/tmp/fftin.dat','w').write(dopack( x , isreal==False ) )
 
@@ -150,9 +150,9 @@ def main():
     doreal = opts.has_key('-r')
 
     if doreal:
-        print 'Testing multi-dimensional real FFTs'
+        print('Testing multi-dimensional real FFTs')
     else:
-        print 'Testing multi-dimensional FFTs'
+        print('Testing multi-dimensional FFTs')
 
     for dim in range(1,4):
         test_fft( dim )
diff --git a/tools/kiss_fftr.c b/tools/kiss_fftr.c
index b8e238b..0d22a04 100644
--- a/tools/kiss_fftr.c
+++ b/tools/kiss_fftr.c
@@ -31,7 +31,7 @@ kiss_fftr_cfg kiss_fftr_alloc(int nfft,int inverse_fft,void * mem,size_t * lenme
     size_t subsize, memneeded;
 
     if (nfft & 1) {
-        fprintf(stderr,"Real FFT optimization must be even.\n");
+        /* fprintf(stderr,"Real FFT optimization must be even.\n"); */
         return NULL;
     }
     nfft >>= 1;
@@ -71,8 +71,8 @@ void kiss_fftr(kiss_fftr_cfg st,const kiss_fft_scalar *timedata,kiss_fft_cpx *fr
     kiss_fft_cpx fpnk,fpk,f1k,f2k,tw,tdc;
 
     if ( st->substate->inverse) {
-        fprintf(stderr,"kiss fft usage error: improper alloc\n");
-        exit(1);
+        /* fprintf(stderr,"kiss fft usage error: improper alloc\n"); */
+        return; /* exit(1); */
     }
 
     ncfft = st->substate->nfft;
@@ -126,8 +126,8 @@ void kiss_fftri(kiss_fftr_cfg st,const kiss_fft_cpx *freqdata,kiss_fft_scalar *t
     int k, ncfft;
 
     if (st->substate->inverse == 0) {
-        fprintf (stderr, "kiss fft usage error: improper alloc\n");
-        exit (1);
+        /* fprintf (stderr, "kiss fft usage error: improper alloc\n"); */
+        return; /* exit (1); */
     }
 
     ncfft = st->substate->nfft;
diff --git a/tools/kiss_fftr.h b/tools/kiss_fftr.h
index 72e5a57..b888a28 100644
--- a/tools/kiss_fftr.h
+++ b/tools/kiss_fftr.h
@@ -3,7 +3,7 @@
 
 #include "kiss_fft.h"
 #ifdef __cplusplus
-extern "C" {
+extern "C++" {
 #endif