1 command network inference

This commit is contained in:
Francesco Gatti
2017-07-02 20:47:14 +02:00
parent cfa43a8580
commit ea59d7ca53
4 changed files with 43 additions and 1 deletions
+3
View File
@@ -12,6 +12,9 @@ Layer::Layer(Network *net, dataDim_t in_dim) {
checkCUDNN( cudnnCreateTensorDescriptor(&srcTensorDesc) );
checkCUDNN( cudnnCreateTensorDescriptor(&dstTensorDesc) );
if(!net->addLayer(this))
FatalError("Net reached max number of layers");
}
Layer::~Layer() {
+20
View File
@@ -1,6 +1,7 @@
#include <iostream>
#include "Network.h"
#include "Layer.h"
namespace tkDNN {
@@ -12,6 +13,8 @@ Network::Network() {
checkCUDNN( cudnnCreate(&cudnnHandle) );
checkERROR( cublasCreate(&cublasHandle) );
num_layers = 0;
}
Network::~Network() {
@@ -20,4 +23,21 @@ Network::~Network() {
checkERROR( cublasDestroy(cublasHandle) );
}
value_type* Network::infer(dataDim_t &dim, value_type* data) {
//do infer for every layer
for(int i=0; i<num_layers; i++)
data = layers[i]->infer(dim, data);
return data;
}
bool Network::addLayer(Layer *l) {
if(num_layers == MAX_LAYERS)
return false;
layers[num_layers++] = l;
return true;
}
}