-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.hpp
More file actions
62 lines (51 loc) · 1.14 KB
/
utils.hpp
File metadata and controls
62 lines (51 loc) · 1.14 KB
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
#ifndef __STANN_HLS_UTILS_HPP__
#define __STANN_HLS_UTILS_HPP__
#include "stann.hpp"
/**
* Total number of bits in fixed point values.
*/
#define FIXED_TOTAL_SIZE 32
/**
* Number of bits in the integer part of fixed point values.
*/
#define FIXED_INT_SIZE 12
/**
* Fixed point datatype.
*/
typedef ap_fixed<FIXED_TOTAL_SIZE,FIXED_INT_SIZE,AP_RND> fixed_t;
/**
* Data type used as default value for template parameters of functions
* that can be used as fixed of floating point.
*/
#define DEFAULT_DATATYPE float
/**
* Constants for activation functions.
*/
typedef enum {
NONE = 1,
LIN_TANH = 2,
LEAKY_RELU = 3,
SIGMOID = 4,
TANH = 5,
SOFTMAX = 6,
RELU = 7
} activation_t;
template<int M, int N>
void print_mat(float *mat) {
for (int m = 0; m < M; m++) {
for (int n = 0; n < N; n++) {
printf("%f ", mat[m * N + n]);
}
printf("\n");
}
}
template<int M, int N>
void print_mat(float *mat, float scale) {
for (int m = 0; m < M; m++) {
for (int n = 0; n < N; n++) {
printf("%f ", mat[m * N + n] / scale);
}
printf("\n");
}
}
#endif