Skip to content

Commit ffc8a9b

Browse files
author
Anirudh B H
committed
Utility functions for the convolutional layers
1 parent 3bf6668 commit ffc8a9b

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

c_reference/include/conv_utils.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#ifndef __CONVLAYER_UTILS__
2+
#define __CONVLAYER_UTILS__
3+
4+
#include <math.h>
5+
#include <float.h>
6+
7+
int prepareLowRankConvMat(float* out, float* W1, float* W2, unsigned rank, unsigned I, unsigned J);
8+
9+
#endif

c_reference/src/conv_utils.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#include"conv_utils.h"
2+
#include <math.h>
3+
#include <float.h>
4+
5+
int prepareLowRankConvMat(float* out, float* W1, float* W2, unsigned rank, unsigned I, unsigned J){
6+
for(i = 0 ; i < I, i++){
7+
for(j = 0 ; j < J, j++){
8+
float sum = 0;
9+
for(k = 0; k < rank ; k++){
10+
sum += (W1[i * rank + k] * W2[k * J + j]);
11+
}
12+
out[i * J + j] = sum;
13+
}
14+
}
15+
}

0 commit comments

Comments
 (0)