Skip to content

Commit fdb7496

Browse files
Test files for average pool
1 parent 66c3b41 commit fdb7496

File tree

3 files changed

+40
-2
lines changed

3 files changed

+40
-2
lines changed

c_reference/tests/Makefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ INCLUDE_DIR=../include
77
SRC_DIR=../src
88
IFLAGS = -I $(INCLUDE_DIR)
99

10-
all: test_conv1d test_conv1d_depth test_conv1d_lr test_conv1d_lr_depth test_fastgrnn_lr test_rnnpool test_quantized_utils test_quantized_fastgrnn test_quantized_rnnpool test_quantized_mbconv
10+
all: test_avg_pool test_conv1d test_conv1d_depth test_conv1d_lr test_conv1d_lr_depth test_fastgrnn_lr test_rnnpool test_quantized_utils test_quantized_fastgrnn test_quantized_rnnpool test_quantized_mbconv
1111

1212
CONV1D_DIR=conv1d
1313
test_conv1d: $(CONV1D_DIR)/conv1d_regular/test_conv1d.c $(SRC_DIR)/conv_utils.o $(SRC_DIR)/conv1d.o
@@ -18,6 +18,8 @@ test_conv1d_lr: $(CONV1D_DIR)/conv1d_lr/test_conv1d_lr.c $(SRC_DIR)/conv_utils.o
1818
$(CC) -o $@ $^ $(IFLAGS) $(CFLAGS) -lm
1919
test_conv1d_lr_depth: $(CONV1D_DIR)/conv1d_lr_depthwise/test_conv1d_lr_depth.c $(SRC_DIR)/conv_utils.o $(SRC_DIR)/conv1d.o
2020
$(CC) -o $@ $^ $(IFLAGS) $(CFLAGS) -lm
21+
test_avg_pool: $(CONV1D_DIR)/avg_pool/test_avg_pool.c $(SRC_DIR)/conv_utils.o $(SRC_DIR)/conv1d.o
22+
$(CC) -o $@ $^ $(IFLAGS) $(CFLAGS) -lm
2123

2224
FASTGRNN_DIR=fastgrnn
2325
test_fastgrnn_lr: $(FASTGRNN_DIR)/test_fastgrnn_lr.c $(SRC_DIR)/utils.o $(SRC_DIR)/fastgrnn.o $(SRC_DIR)/classifier.o
@@ -42,7 +44,7 @@ test_quantized_mbconv: $(MBCONV_DIR)/test_quantized_mbconv.c $(SRC_DIR)/quantize
4244
.PHONY: clean cleanest
4345

4446
clean:
45-
rm -f *.o *.gch test_conv1d test_conv1d_depth test_conv1d_lr test_conv1d_lr_depth test_fastgrnn_lr test_rnnpool test_quantized_utils test_quantized_fastgrnn test_quantized_rnnpool test_quantized_mbconv
47+
rm -f *.o *.gch test_avg_pool test_conv1d test_conv1d_depth test_conv1d_lr test_conv1d_lr_depth test_fastgrnn_lr test_rnnpool test_quantized_utils test_quantized_fastgrnn test_quantized_rnnpool test_quantized_mbconv
4648

4749
cleanest: clean
4850
rm *~

c_reference/tests/conv1d/avg_pool/avg_io.h

Lines changed: 13 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#include<stdio.h>
2+
#include<stdlib.h>
3+
4+
#include"avg_io.h"
5+
#include"conv1d.h"
6+
#include"conv_utils.h"
7+
8+
int main(){
9+
10+
float pred[O_T * O_F] = {};
11+
AvgPool1D(pred, O_T, INPUT, I_T, I_F, PAD, FILT, ACT);
12+
float error = 0;
13+
for(int t = 0 ; t < O_T ; t++){
14+
for(int d = 0 ; d < O_F ; d++){
15+
error += ((pred[t * O_F + d] - OUTPUT[t * O_F + d]) * (pred[t * O_F + d] - OUTPUT[t * O_F + d]));
16+
}
17+
}
18+
float avg_error = error/(O_T*O_F);
19+
printf("Testing Average Pool\n");
20+
printf("Squared Error : %f \t ; MSE : %f \n", error, avg_error);
21+
22+
return 0 ;
23+
}

0 commit comments

Comments
 (0)