Refactoring and modularization
Signed-off-by: Micaela Verucchi <micaela.verucchi@unimore.it>
This commit is contained in:
+21
-14
@@ -3,7 +3,10 @@
|
||||
|
||||
#include "utils.h"
|
||||
|
||||
namespace tk { namespace dnn {
|
||||
namespace tk
|
||||
{
|
||||
namespace dnn
|
||||
{
|
||||
|
||||
/**
|
||||
Data rapresentation beetween layers
|
||||
@@ -13,28 +16,31 @@ namespace tk { namespace dnn {
|
||||
w = width (rows)
|
||||
l = lenght (3rd dimension)
|
||||
*/
|
||||
struct dataDim_t {
|
||||
struct dataDim_t
|
||||
{
|
||||
|
||||
int n, c, h, w, l;
|
||||
|
||||
dataDim_t() : n(1), c(1), h(1), w(1), l(1) {};
|
||||
dataDim_t() : n(1), c(1), h(1), w(1), l(1){};
|
||||
|
||||
dataDim_t(int _n, int _c, int _h, int _w, int _l = 1) :
|
||||
n(_n), c(_c), h(_h), w(_w), l(_l) {};
|
||||
dataDim_t(int _n, int _c, int _h, int _w, int _l = 1) : n(_n), c(_c), h(_h), w(_w), l(_l){};
|
||||
|
||||
void print() {
|
||||
std::cout<<"Data dim: "<<n<<" "<<c<<" "<<h<<" "<<w<<" "<<l<<"\n";
|
||||
void print()
|
||||
{
|
||||
std::cout << "Data dim: " << n << " " << c << " " << h << " " << w << " " << l << "\n";
|
||||
}
|
||||
|
||||
int tot() {
|
||||
return n*c*h*w*l;
|
||||
int tot()
|
||||
{
|
||||
return n * c * h * w * l;
|
||||
}
|
||||
};
|
||||
|
||||
class Layer;
|
||||
const int MAX_LAYERS = 256;
|
||||
|
||||
class Network {
|
||||
class Network
|
||||
{
|
||||
|
||||
public:
|
||||
Network(dataDim_t input_dim);
|
||||
@@ -43,7 +49,7 @@ public:
|
||||
/**
|
||||
Do inferece for every added layer
|
||||
*/
|
||||
dnnType* infer(dataDim_t &dim, dnnType* data);
|
||||
dnnType *infer(dataDim_t &dim, dnnType *data);
|
||||
|
||||
bool addLayer(Layer *l);
|
||||
void print();
|
||||
@@ -53,8 +59,8 @@ public:
|
||||
cudnnHandle_t cudnnHandle;
|
||||
cublasHandle_t cublasHandle;
|
||||
|
||||
Layer* layers[MAX_LAYERS]; //contains layers of the net
|
||||
int num_layers; //current number of layers
|
||||
Layer *layers[MAX_LAYERS]; //contains layers of the net
|
||||
int num_layers; //current number of layers
|
||||
|
||||
dataDim_t input_dim;
|
||||
dataDim_t getOutputDim();
|
||||
@@ -62,5 +68,6 @@ public:
|
||||
bool fp16, dla;
|
||||
};
|
||||
|
||||
}}
|
||||
} // namespace dnn
|
||||
} // namespace tk
|
||||
#endif //NETWORK_H
|
||||
|
||||
Reference in New Issue
Block a user