test simple
This commit is contained in:
@@ -8,3 +8,4 @@ build/
|
|||||||
*.h5
|
*.h5
|
||||||
*.tar.gz
|
*.tar.gz
|
||||||
*.weights
|
*.weights
|
||||||
|
.idea/
|
||||||
@@ -183,6 +183,7 @@ ILayer* NetworkRT::convert_layer(ITensor *input, Layer *l) {
|
|||||||
if(type == LAYER_UPSAMPLE)
|
if(type == LAYER_UPSAMPLE)
|
||||||
return convert_layer(input, (Upsample*) l);
|
return convert_layer(input, (Upsample*) l);
|
||||||
|
|
||||||
|
std::cout<<l->getLayerName()<<"\n";
|
||||||
FatalError("Layer not implemented in tensorRT");
|
FatalError("Layer not implemented in tensorRT");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ int main() {
|
|||||||
tk::dnn::Activation l1(&net, CUDNN_ACTIVATION_RELU);
|
tk::dnn::Activation l1(&net, CUDNN_ACTIVATION_RELU);
|
||||||
tk::dnn::Conv2d l2(&net, 4, 2, 2, 1, 1, 0, 0, c1_bin);
|
tk::dnn::Conv2d l2(&net, 4, 2, 2, 1, 1, 0, 0, c1_bin);
|
||||||
tk::dnn::Activation l3(&net, CUDNN_ACTIVATION_RELU);
|
tk::dnn::Activation l3(&net, CUDNN_ACTIVATION_RELU);
|
||||||
tk::dnn::Flatten l4(&net);
|
|
||||||
tk::dnn::Dense l5(&net, 4, d2_bin);
|
tk::dnn::Dense l5(&net, 4, d2_bin);
|
||||||
tk::dnn::Activation l6(&net, CUDNN_ACTIVATION_RELU);
|
tk::dnn::Activation l6(&net, CUDNN_ACTIVATION_RELU);
|
||||||
|
|
||||||
@@ -25,23 +24,45 @@ int main() {
|
|||||||
dnnType *input_h;
|
dnnType *input_h;
|
||||||
readBinaryFile(input_bin, dim.tot(), &input_h, &data);
|
readBinaryFile(input_bin, dim.tot(), &input_h, &data);
|
||||||
|
|
||||||
|
// Print input
|
||||||
|
std::cout<<"\n======= INPUT =======\n";
|
||||||
printDeviceVector(dim.tot(), data);
|
printDeviceVector(dim.tot(), data);
|
||||||
dim.print(); //print initial dimension
|
std::cout<<"\n";
|
||||||
|
|
||||||
TIMER_START
|
|
||||||
// Inference
|
|
||||||
data = net.infer(dim, data); dim.print();
|
|
||||||
TIMER_STOP
|
|
||||||
|
|
||||||
// Print result
|
//convert network to tensorRT
|
||||||
std::cout<<"\n======= RESULT =======\n";
|
tk::dnn::NetworkRT netRT(&net, "simple.rt");
|
||||||
printDeviceVector(dim.tot(), data);
|
|
||||||
|
|
||||||
// Print real test
|
dnnType *out_data, *out_data2; // cudnn output, tensorRT output
|
||||||
std::cout<<"\n==== CHECK RESULT ====\n";
|
|
||||||
dnnType *out;
|
tk::dnn::dataDim_t dim1 = dim; //input dim
|
||||||
dnnType *out_h;
|
printCenteredTitle(" CUDNN inference ", '=', 30); {
|
||||||
readBinaryFile(output_bin, dim.tot(), &out_h, &out);
|
dim1.print();
|
||||||
printDeviceVector(dim.tot(), out);
|
TIMER_START
|
||||||
|
out_data = net.infer(dim1, data);
|
||||||
|
TIMER_STOP
|
||||||
|
dim1.print();
|
||||||
|
}
|
||||||
|
|
||||||
|
tk::dnn::dataDim_t dim2 = dim;
|
||||||
|
printCenteredTitle(" TENSORRT inference ", '=', 30); {
|
||||||
|
dim2.print();
|
||||||
|
TIMER_START
|
||||||
|
out_data2 = netRT.infer(dim2, data);
|
||||||
|
TIMER_STOP
|
||||||
|
dim2.print();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::cout<<"\n======= CUDNN =======\n";
|
||||||
|
printDeviceVector(dim.tot(), out_data);
|
||||||
|
std::cout<<"\n======= TENSORRT =======\n";
|
||||||
|
printDeviceVector(dim.tot(), out_data2);
|
||||||
|
|
||||||
|
printCenteredTitle(" CHECK RESULTS ", '=', 30);
|
||||||
|
dnnType *out, *out_h;
|
||||||
|
int out_dim = net.getOutputDim().tot();
|
||||||
|
//readBinaryFile(output_bin, out_dim, &out_h, &out);
|
||||||
|
//std::cout<<"CUDNN vs correct"; checkResult(out_dim, out_data, out);
|
||||||
|
//std::cout<<"TRT vs correct"; checkResult(out_dim, out_data2, out);
|
||||||
|
std::cout<<"CUDNN vs TRT "; checkResult(out_dim, out_data, out_data2);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user