Add Yolov3 (COCO80) and Yolov3-tiny (COCO80), TensorRT for tiny not working
Signed-off-by: Micaela Verucchi <micaelaverucchi@gmail.com>
This commit is contained in:
+5
-2
@@ -209,7 +209,9 @@ ILayer* NetworkRT::convert_layer(ITensor *input, Dense *l) {
|
||||
|
||||
|
||||
ILayer* NetworkRT::convert_layer(ITensor *input, Conv2d *l) {
|
||||
//std::cout<<"convert conv2D\n";
|
||||
std::cout<<"convert conv2D\n";
|
||||
printf("%d %d %d %d %d\n", l->kernelH, l->kernelW, l->inputs, l->outputs, l->batchnorm);
|
||||
|
||||
|
||||
void *data_b, *bias_b, *power_b, *mean_b, *variance_b, *scales_b;
|
||||
if(dtRT == DataType::kHALF) {
|
||||
@@ -274,7 +276,8 @@ ILayer* NetworkRT::convert_layer(ITensor *input, Conv2d *l) {
|
||||
}
|
||||
|
||||
ILayer* NetworkRT::convert_layer(ITensor *input, Pooling *l) {
|
||||
//std::cout<<"convert Pooling\n";
|
||||
std::cout<<"convert Pooling\n";
|
||||
// printf("%d %d\n", l->winW, l->winH);
|
||||
|
||||
PoolingType ptype;
|
||||
if(l->pool_mode == tkdnnPoolingMode_t::POOLING_MAX) ptype = PoolingType::kMAX;
|
||||
|
||||
+19
-3
@@ -26,6 +26,9 @@ Pooling::Pooling( Network *net, int winH, int winW, int strideH, int strideW,
|
||||
int w = input_dim.w;
|
||||
int l = input_dim.l;
|
||||
|
||||
printf("before: %d %d\n", h, w);
|
||||
|
||||
|
||||
poolOn3d = false;
|
||||
|
||||
if(l > 1) {
|
||||
@@ -38,6 +41,8 @@ Pooling::Pooling( Network *net, int winH, int winW, int strideH, int strideW,
|
||||
n = l;
|
||||
}
|
||||
|
||||
|
||||
|
||||
checkCUDNN( cudnnSetPooling2dDescriptor(poolingDesc, cudnnPoolingMode_t(pool_mode),
|
||||
CUDNN_NOT_PROPAGATE_NAN, winH, winW, paddingH, paddingW, strideH, strideW) );
|
||||
|
||||
@@ -45,12 +50,23 @@ Pooling::Pooling( Network *net, int winH, int winW, int strideH, int strideW,
|
||||
net->tensorFormat, net->dataType, n, c, h, w) );
|
||||
|
||||
//get out dim
|
||||
checkCUDNN( cudnnGetPooling2dForwardOutputDim(poolingDesc, srcTensorDesc, &n, &c, &h, &w));
|
||||
//h = (h + winH*this->paddingH)/strideH;
|
||||
//w = (w + winW*this->paddingW)/strideW;
|
||||
// checkCUDNN( cudnnGetPooling2dForwardOutputDim(poolingDesc, srcTensorDesc, &n, &c, &h, &w));
|
||||
|
||||
//compute w and h as in darknet
|
||||
|
||||
int padH = paddingH == 0? winH -1 : paddingH;
|
||||
int padW = paddingW == 0? winW -1 : paddingW;
|
||||
|
||||
h = (h + padH - winH)/strideH +1;
|
||||
w = (w + padW - winW)/strideW +1;
|
||||
|
||||
// h = (h + winH*this->paddingH)/strideH;
|
||||
// w = (w + winW*this->paddingW)/strideW;
|
||||
|
||||
checkCUDNN( cudnnSetTensor4dDescriptor(dstTensorDesc,
|
||||
net->tensorFormat, net->dataType, n, c, h, w) );
|
||||
|
||||
printf("after: %d %d\n", h, w);
|
||||
|
||||
output_dim.n = n;
|
||||
output_dim.c = c;
|
||||
|
||||
+5
-3
@@ -15,14 +15,16 @@ Yolo::Yolo(Network *net, int classes, int num, std::string fname_weights) :
|
||||
Layer(net) {
|
||||
|
||||
this->classes = classes;
|
||||
this->num = num;
|
||||
this->num = 3;
|
||||
|
||||
// load anchors
|
||||
if(fname_weights != "") {
|
||||
int seek = 0;
|
||||
readBinaryFile(fname_weights, num, &mask_h, &mask_d, seek);
|
||||
seek += num;
|
||||
readBinaryFile(fname_weights, 3, &mask_h, &mask_d, seek);
|
||||
seek += 3;
|
||||
readBinaryFile(fname_weights, 3*num*2, &bias_h, &bias_d, seek);
|
||||
for(int i=0; i<3*num*2; i++)
|
||||
printf("%f\n", bias_h[i]);
|
||||
}
|
||||
|
||||
// init default classes name
|
||||
|
||||
@@ -38,7 +38,9 @@ void readBinaryFile(std::string fname, int size, dnnType** data_h, dnnType** dat
|
||||
dataFile.seekg(seek * sizeof(dnnType), dataFile.cur);
|
||||
}
|
||||
|
||||
// printf("data_h %d size_b %d\n", *data_h,size_b);
|
||||
if (!dataFile.read((char *) *data_h, size_b)) {
|
||||
|
||||
error_s << "Error reading file " << fname;
|
||||
FatalError(error_s.str());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user