1 command network inference
This commit is contained in:
@@ -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() {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user