Skip to content

Commit 1456955

Browse files
minor modifications to conv test files
1 parent a053baa commit 1456955

File tree

6 files changed

+33
-20
lines changed

6 files changed

+33
-20
lines changed

c_reference/tests/Makefile

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,27 +10,27 @@ IFLAGS = -I $(INCLUDE_DIR)
1010
all: test_rnn test_postcnn test_avg_pool test_conv1d test_conv1d_depth test_conv1d_lr test_conv1d_lr_depth test_dscnn_lr test_dscnn_lr_depth_point test_fastgrnn_lr test_rnnpool test_quantized_utils test_quantized_fastgrnn test_quantized_rnnpool test_quantized_mbconv
1111

1212
KWS_DIR=kws
13-
test_postcnn: $(KWS_DIR)/test_postcnn.c $(SRC_DIR)/conv_utils.o $(SRC_DIR)/conv1d.o $(SRC_DIR)/dscnn.o
13+
test_postcnn: $(KWS_DIR)/test_postcnn.c $(SRC_DIR)/conv_utils.o $(SRC_DIR)/utils.o $(SRC_DIR)/conv1d.o $(SRC_DIR)/dscnn.o
1414
$(CC) -o $@ $^ $(IFLAGS) $(CFLAGS) -lm
1515
test_rnn: $(KWS_DIR)/test_rnn.c $(SRC_DIR)/fastgrnn.o $(SRC_DIR)/utils.o
1616
$(CC) -o $@ $^ $(IFLAGS) $(CFLAGS) -lm
1717

1818
DSCNN_DIR=dscnn
19-
test_dscnn_lr: $(DSCNN_DIR)/test_dscnn_lr.c $(SRC_DIR)/conv_utils.o $(SRC_DIR)/conv1d.o $(SRC_DIR)/dscnn.o
19+
test_dscnn_lr: $(DSCNN_DIR)/test_dscnn_lr.c $(SRC_DIR)/conv_utils.o $(SRC_DIR)/utils.o $(SRC_DIR)/conv1d.o $(SRC_DIR)/dscnn.o
2020
$(CC) -o $@ $^ $(IFLAGS) $(CFLAGS) -lm
21-
test_dscnn_lr_depth_point : $(DSCNN_DIR)/test_dscnn_lr_depth_point.c $(SRC_DIR)/conv_utils.o $(SRC_DIR)/conv1d.o $(SRC_DIR)/dscnn.o
21+
test_dscnn_lr_depth_point : $(DSCNN_DIR)/test_dscnn_lr_depth_point.c $(SRC_DIR)/utils.o $(SRC_DIR)/conv_utils.o $(SRC_DIR)/conv1d.o $(SRC_DIR)/dscnn.o
2222
$(CC) -o $@ $^ $(IFLAGS) $(CFLAGS) -lm
2323

2424
CONV1D_DIR=conv1d
25-
test_conv1d: $(CONV1D_DIR)/conv1d_regular/test_conv1d.c $(SRC_DIR)/conv_utils.o $(SRC_DIR)/conv1d.o
25+
test_conv1d: $(CONV1D_DIR)/conv1d_regular/test_conv1d.c $(SRC_DIR)/conv_utils.o $(SRC_DIR)/conv1d.o $(SRC_DIR)/utils.o
2626
$(CC) -o $@ $^ $(IFLAGS) $(CFLAGS) -lm
27-
test_conv1d_depth: $(CONV1D_DIR)/conv1d_depthwise/test_conv1d_depth.c $(SRC_DIR)/conv_utils.o $(SRC_DIR)/conv1d.o
27+
test_conv1d_depth: $(CONV1D_DIR)/conv1d_depthwise/test_conv1d_depth.c $(SRC_DIR)/conv_utils.o $(SRC_DIR)/conv1d.o $(SRC_DIR)/utils.o
2828
$(CC) -o $@ $^ $(IFLAGS) $(CFLAGS) -lm
29-
test_conv1d_lr: $(CONV1D_DIR)/conv1d_lr/test_conv1d_lr.c $(SRC_DIR)/conv_utils.o $(SRC_DIR)/conv1d.o
29+
test_conv1d_lr: $(CONV1D_DIR)/conv1d_lr/test_conv1d_lr.c $(SRC_DIR)/conv_utils.o $(SRC_DIR)/conv1d.o $(SRC_DIR)/utils.o
3030
$(CC) -o $@ $^ $(IFLAGS) $(CFLAGS) -lm
31-
test_conv1d_lr_depth: $(CONV1D_DIR)/conv1d_lr_depthwise/test_conv1d_lr_depth.c $(SRC_DIR)/conv_utils.o $(SRC_DIR)/conv1d.o
31+
test_conv1d_lr_depth: $(CONV1D_DIR)/conv1d_lr_depthwise/test_conv1d_lr_depth.c $(SRC_DIR)/conv_utils.o $(SRC_DIR)/conv1d.o $(SRC_DIR)/utils.o
3232
$(CC) -o $@ $^ $(IFLAGS) $(CFLAGS) -lm
33-
test_avg_pool: $(CONV1D_DIR)/avg_pool/test_avg_pool.c $(SRC_DIR)/conv_utils.o $(SRC_DIR)/conv1d.o
33+
test_avg_pool: $(CONV1D_DIR)/avg_pool/test_avg_pool.c $(SRC_DIR)/conv_utils.o $(SRC_DIR)/conv1d.o $(SRC_DIR)/utils.o
3434
$(CC) -o $@ $^ $(IFLAGS) $(CFLAGS) -lm
3535

3636
FASTGRNN_DIR=fastgrnn

c_reference/tests/conv1d/avg_pool/test_avg_pool.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,22 @@
33

44
#include"avg_io.h"
55
#include"conv1d.h"
6-
#include"conv_utils.h"
76

87
int main(){
98

109
float pred[O_T * O_F] = {};
1110
AvgPool1D(pred, O_T, INPUT, I_T, I_F, PAD, FILT, ACT);
1211
float error = 0;
12+
float denom = 0;
1313
for(int t = 0 ; t < O_T ; t++){
1414
for(int d = 0 ; d < O_F ; d++){
1515
error += ((pred[t * O_F + d] - OUTPUT[t * O_F + d]) * (pred[t * O_F + d] - OUTPUT[t * O_F + d]));
16+
denom += OUTPUT[t * O_F + d] * OUTPUT[t * O_F + d] ;
1617
}
1718
}
1819
float avg_error = error/(O_T*O_F);
1920
printf("Testing Average Pool\n");
2021
printf("Squared Error : %f \t ; MSE : %f \n", error, avg_error);
21-
22+
printf("Relative Squared Error : %f", error/denom)
2223
return 0 ;
2324
}

c_reference/tests/conv1d/conv1d_depthwise/test_conv1d_depth.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,16 @@ int main(){
1515
float pred[O_T * I_F] = {};
1616
Conv1D_Depth(pred, O_T, INPUT, I_T, I_F, PAD, FILT, &conv_params, ACT);
1717
float error = 0;
18+
float denom = 0;
1819
for(int t = 0 ; t < O_T ; t++){
19-
for(int d = 0 ; d < I_F ; d++){
20-
error += ((pred[t * I_F + d] - OUTPUT[t * I_F + d]) * (pred[t * I_F + d] - OUTPUT[t * I_F + d]));
20+
for(int d = 0 ; d < O_F ; d++){
21+
error += ((pred[t * O_F + d] - OUTPUT[t * O_F + d]) * (pred[t * O_F + d] - OUTPUT[t * O_F + d]));
22+
denom += OUTPUT[t * O_F + d] * OUTPUT[t * O_F + d] ;
2123
}
2224
}
2325
float avg_error = error/(O_T*I_F);
26+
printf("Testing Depthwise Convolution\n");
2427
printf("Squared Error : %f \t ; MSE : %f \n", error, avg_error);
25-
28+
printf("Relative Squared Error : %f", error/denom)
2629
return 0 ;
2730
}

c_reference/tests/conv1d/conv1d_lr/test_conv1d_lr.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,16 @@ int main(){
1717
float pred[O_T * O_F] = {};
1818
Conv1D_LR(pred, O_T, O_F, INPUT, I_T, I_F, PAD, FILT, &conv_params, ACT);
1919
float error = 0;
20+
float denom = 0;
2021
for(int t = 0 ; t < O_T ; t++){
21-
for(int d = 0 ; d < I_F ; d++){
22-
error += ((pred[t * I_F + d] - OUTPUT[t * I_F + d]) * (pred[t * I_F + d] - OUTPUT[t * I_F + d]));
22+
for(int d = 0 ; d < O_F ; d++){
23+
error += ((pred[t * O_F + d] - OUTPUT[t * O_F + d]) * (pred[t * O_F + d] - OUTPUT[t * O_F + d]));
24+
denom += OUTPUT[t * O_F + d] * OUTPUT[t * O_F + d] ;
2325
}
2426
}
2527
float avg_error = error/(O_T*I_F);
28+
printf("Testing Low Rank Convolution\n");
2629
printf("Squared Error : %f \t ; MSE : %f \n", error, avg_error);
27-
30+
printf("Relative Squared Error : %f", error/denom)
2831
return 0 ;
2932
}

c_reference/tests/conv1d/conv1d_lr_depthwise/test_conv1d_lr_depth.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,16 @@ int main(){
1717
float pred[O_T * O_F] = {};
1818
Conv1D_Depth_LR(pred, O_T, INPUT, I_T, I_F, PAD, FILT, &conv_params, ACT);
1919
float error = 0;
20+
float denom = 0;
2021
for(int t = 0 ; t < O_T ; t++){
21-
for(int d = 0 ; d < I_F ; d++){
22-
error += ((pred[t * I_F + d] - OUTPUT[t * I_F + d]) * (pred[t * I_F + d] - OUTPUT[t * I_F + d]));
22+
for(int d = 0 ; d < O_F ; d++){
23+
error += ((pred[t * O_F + d] - OUTPUT[t * O_F + d]) * (pred[t * O_F + d] - OUTPUT[t * O_F + d]));
24+
denom += OUTPUT[t * O_F + d] * OUTPUT[t * O_F + d] ;
2325
}
2426
}
2527
float avg_error = error/(O_T*I_F);
28+
printf("Testing Low Rank Depthwise Convolution\n");
2629
printf("Squared Error : %f \t ; MSE : %f \n", error, avg_error);
27-
30+
printf("Relative Squared Error : %f", error/denom)
2831
return 0 ;
2932
}

c_reference/tests/conv1d/conv1d_regular/test_conv1d.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,16 @@ int main(){
1515
float pred[O_T * O_F] = {};
1616
Conv1D(pred, O_T, O_F, INPUT, I_T, I_F, PAD, FILT, &conv_params, ACT);
1717
float error = 0;
18+
float denom = 0;
1819
for(int t = 0 ; t < O_T ; t++){
1920
for(int d = 0 ; d < O_F ; d++){
2021
error += ((pred[t * O_F + d] - OUTPUT[t * O_F + d]) * (pred[t * O_F + d] - OUTPUT[t * O_F + d]));
22+
denom += OUTPUT[t * O_F + d] * OUTPUT[t * O_F + d] ;
2123
}
2224
}
2325
float avg_error = error/(O_T*O_F);
26+
printf("Testing Regular Convolution\n");
2427
printf("Squared Error : %f \t ; MSE : %f \n", error, avg_error);
25-
28+
printf("Relative Squared Error : %f", error/denom)
2629
return 0 ;
2730
}

0 commit comments

Comments
 (0)