conv2d ok, but deconv ha different dim with tensorrt
This commit is contained in:
@@ -166,7 +166,7 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
cudnnFilterDescriptor_t filterDesc;
|
cudnnFilterDescriptor_t filterDesc;
|
||||||
cudnnConvolutionDescriptor_t convDesc;
|
cudnnConvolutionDescriptor_t convDesc;
|
||||||
cudnnConvolutionFwdAlgo_t fwAlgo;
|
cudnnConvolutionFwdAlgo_t algo;
|
||||||
cudnnConvolutionBwdDataAlgo_t bwAlgo;
|
cudnnConvolutionBwdDataAlgo_t bwAlgo;
|
||||||
cudnnTensorDescriptor_t biasTensorDesc;
|
cudnnTensorDescriptor_t biasTensorDesc;
|
||||||
|
|
||||||
|
|||||||
@@ -75,7 +75,6 @@ public:
|
|||||||
|
|
||||||
nvinfer1::ILayer* convert_layer(nvinfer1::ITensor *input, Layer *l);
|
nvinfer1::ILayer* convert_layer(nvinfer1::ITensor *input, Layer *l);
|
||||||
nvinfer1::ILayer* convert_layer(nvinfer1::ITensor *input, Conv2d *l);
|
nvinfer1::ILayer* convert_layer(nvinfer1::ITensor *input, Conv2d *l);
|
||||||
nvinfer1::ILayer* convert_layer(nvinfer1::ITensor *input, DeConv2d *l);
|
|
||||||
nvinfer1::ILayer* convert_layer(nvinfer1::ITensor *input, Activation *l);
|
nvinfer1::ILayer* convert_layer(nvinfer1::ITensor *input, Activation *l);
|
||||||
nvinfer1::ILayer* convert_layer(nvinfer1::ITensor *input, Dense *l);
|
nvinfer1::ILayer* convert_layer(nvinfer1::ITensor *input, Dense *l);
|
||||||
nvinfer1::ILayer* convert_layer(nvinfer1::ITensor *input, Pooling *l);
|
nvinfer1::ILayer* convert_layer(nvinfer1::ITensor *input, Pooling *l);
|
||||||
|
|||||||
+6
-6
@@ -73,10 +73,10 @@ void Conv2d::initCUDNN(bool back) {
|
|||||||
} else {
|
} else {
|
||||||
checkCUDNN( cudnnGetConvolutionForwardAlgorithm(net->cudnnHandle,
|
checkCUDNN( cudnnGetConvolutionForwardAlgorithm(net->cudnnHandle,
|
||||||
srcTensor, filterDesc, convDesc, dstTensor,
|
srcTensor, filterDesc, convDesc, dstTensor,
|
||||||
CUDNN_CONVOLUTION_FWD_PREFER_FASTEST, 0, &fwAlgo) );
|
CUDNN_CONVOLUTION_FWD_PREFER_FASTEST, 0, &algo) );
|
||||||
checkCUDNN(cudnnGetConvolutionForwardWorkspaceSize(net->cudnnHandle,
|
checkCUDNN(cudnnGetConvolutionForwardWorkspaceSize(net->cudnnHandle,
|
||||||
srcTensor, filterDesc, convDesc, dstTensor,
|
srcTensor, filterDesc, convDesc, dstTensor,
|
||||||
fwAlgo, &ws_sizeInBytes));
|
algo, &ws_sizeInBytes));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -93,14 +93,14 @@ void Conv2d::inferCUDNN(dnnType* srcData, bool back) {
|
|||||||
} else {
|
} else {
|
||||||
checkCUDNN(cudnnConvolutionForward(net->cudnnHandle,
|
checkCUDNN(cudnnConvolutionForward(net->cudnnHandle,
|
||||||
&alpha, srcTensorDesc, srcData, filterDesc,
|
&alpha, srcTensorDesc, srcData, filterDesc,
|
||||||
data_d, convDesc, fwAlgo, workSpace, ws_sizeInBytes,
|
data_d, convDesc, algo, workSpace, ws_sizeInBytes,
|
||||||
&beta, dstTensorDesc, dstData));
|
&beta, dstTensorDesc, dstData));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!batchnorm) {
|
if(!batchnorm) {
|
||||||
// bias
|
// bias
|
||||||
alpha = dnnType(1);
|
alpha = dnnType(1);
|
||||||
beta = dnnType(0);
|
beta = dnnType(1);
|
||||||
checkCUDNN( cudnnAddTensor(net->cudnnHandle,
|
checkCUDNN( cudnnAddTensor(net->cudnnHandle,
|
||||||
&alpha, biasTensorDesc, bias_d,
|
&alpha, biasTensorDesc, bias_d,
|
||||||
&beta, dstTensorDesc, dstData) );
|
&beta, dstTensorDesc, dstData) );
|
||||||
@@ -116,7 +116,7 @@ void Conv2d::inferCUDNN(dnnType* srcData, bool back) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Conv2d::Conv2d( Network *net, int out_ch, int kernelH, int kernelW,
|
Conv2d::Conv2d( Network *net, int out_ch, int kernelH, int kernelW,
|
||||||
int strideH, int strideW, int paddingH, int paddingW,
|
int strideH, int strideW, int paddingH, int paddingW,
|
||||||
std::string fname_weights, bool batchnorm, bool deConv) :
|
std::string fname_weights, bool batchnorm, bool deConv) :
|
||||||
|
|
||||||
@@ -156,7 +156,7 @@ Conv2d::Conv2d( Network *net, int out_ch, int kernelH, int kernelW,
|
|||||||
}
|
}
|
||||||
|
|
||||||
Conv2d::~Conv2d() {
|
Conv2d::~Conv2d() {
|
||||||
|
|
||||||
checkCUDNN( cudnnDestroyFilterDescriptor(filterDesc) );
|
checkCUDNN( cudnnDestroyFilterDescriptor(filterDesc) );
|
||||||
checkCUDNN( cudnnDestroyConvolutionDescriptor(convDesc) );
|
checkCUDNN( cudnnDestroyConvolutionDescriptor(convDesc) );
|
||||||
checkCUDNN( cudnnDestroyTensorDescriptor(biasTensorDesc) );
|
checkCUDNN( cudnnDestroyTensorDescriptor(biasTensorDesc) );
|
||||||
|
|||||||
@@ -19,6 +19,8 @@ int main() {
|
|||||||
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);
|
||||||
|
|
||||||
|
net.print();
|
||||||
|
|
||||||
// Load input
|
// Load input
|
||||||
dnnType *data;
|
dnnType *data;
|
||||||
dnnType *input_h;
|
dnnType *input_h;
|
||||||
|
|||||||
Reference in New Issue
Block a user