-
Notifications
You must be signed in to change notification settings - Fork 5.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add conv3d_trans_cudnn_op #5603
Merged
chengduoZH
merged 6 commits into
PaddlePaddle:develop
from
chengduoZH:Add_conv3d_transpose_cudnn_op
Nov 17, 2017
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
3a507b4
add conv3d_trans_cudnn_op
chengduoZH 6fb4bb8
add conv3d_trans_cudnn_op unit test
chengduoZH c5330fa
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
chengduoZH 74912c7
fix data layout
chengduoZH 0bc2f41
remove conflict
chengduoZH c359e39
add double type kernel
chengduoZH File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,15 +54,21 @@ class CudnnConvTransposeOpKernel : public framework::OpKernel<T> { | |
ScopedTensorDescriptor output_desc; | ||
ScopedFilterDescriptor filter_desc; | ||
ScopedConvolutionDescriptor conv_desc; | ||
DataLayout layout = DataLayout::kNCHW; | ||
DataLayout layout; | ||
|
||
if (strides.size() == 2U) { | ||
layout = DataLayout::kNCHW; | ||
} else { | ||
layout = DataLayout::kNCDHW; | ||
} | ||
|
||
// N, M, H, W | ||
// (N, M, H, W) or (N, M, D, H, W) | ||
cudnnTensorDescriptor_t cudnn_input_desc = input_desc.descriptor<T>( | ||
layout, framework::vectorize2int(input->dims())); | ||
// N, C, O_h, O_w | ||
// (N, C, O_h, O_w) or (N, C, O_d, O_h, O_w) | ||
cudnnTensorDescriptor_t cudnn_output_desc = output_desc.descriptor<T>( | ||
layout, framework::vectorize2int(output->dims())); | ||
// M, C, K_h, K_w | ||
// (M, C, K_h, K_w) or (M, C, K_d, K_h, K_w) | ||
cudnnFilterDescriptor_t cudnn_filter_desc = filter_desc.descriptor<T>( | ||
layout, framework::vectorize2int(filter->dims())); | ||
cudnnConvolutionDescriptor_t cudnn_conv_desc = | ||
|
@@ -136,13 +142,13 @@ class CudnnConvTransposeGradOpKernel : public framework::OpKernel<T> { | |
ScopedConvolutionDescriptor conv_desc; | ||
DataLayout layout = DataLayout::kNCHW; | ||
|
||
// Input: (N, M, H, W) | ||
// Input: (N, M, H, W) or (N, M, D, H, W) | ||
cudnnTensorDescriptor_t cudnn_input_desc = input_desc.descriptor<T>( | ||
layout, framework::vectorize2int(input->dims())); | ||
// Output: (N, C, O_H, O_W) | ||
// Output: (N, C, O_h, O_w) or (N, C, O_d, O_h, O_w) | ||
cudnnTensorDescriptor_t cudnn_output_desc = output_desc.descriptor<T>( | ||
layout, framework::vectorize2int(output_grad->dims())); | ||
// Filter (M, C, K_H, K_W) | ||
// Filter (M, C, K_h, K_w) or (M, C, K_d K_h, K_w) | ||
cudnnFilterDescriptor_t cudnn_filter_desc = filter_desc.descriptor<T>( | ||
layout, framework::vectorize2int(filter->dims())); | ||
|
||
|
@@ -200,8 +206,7 @@ class CudnnConvTransposeGradOpKernel : public framework::OpKernel<T> { | |
T alpha = 1.0f, beta = 0.0f; | ||
if (input_grad) { | ||
T* input_grad_data = input_grad->mutable_data<T>(ctx.GetPlace()); | ||
math::set_constant(ctx.device_context(), input_grad, 0); | ||
|
||
// Because beta is zero, it is unnecessary to reset input_grad. | ||
PADDLE_ENFORCE(platform::dynload::cudnnConvolutionForward( | ||
handle, &alpha, cudnn_output_desc, output_grad_data, | ||
cudnn_filter_desc, filter_data, cudnn_conv_desc, data_algo, | ||
|
@@ -212,8 +217,7 @@ class CudnnConvTransposeGradOpKernel : public framework::OpKernel<T> { | |
// ------------------- cudnn conv backward filter --------------------- | ||
if (filter_grad) { | ||
T* filter_grad_data = filter_grad->mutable_data<T>(ctx.GetPlace()); | ||
math::set_constant(ctx.device_context(), filter_grad, 0); | ||
|
||
// Because beta is zero, it is unnecessary to reset filter_grad. | ||
// Gradient with respect to the filter | ||
PADDLE_ENFORCE(platform::dynload::cudnnConvolutionBackwardFilter( | ||
handle, &alpha, cudnn_output_desc, output_grad_data, cudnn_input_desc, | ||
|
@@ -234,3 +238,8 @@ REGISTER_OP_GPU_KERNEL(conv2d_transpose_cudnn, | |
ops::CudnnConvTransposeOpKernel<float>); | ||
REGISTER_OP_GPU_KERNEL(conv2d_transpose_cudnn_grad, | ||
ops::CudnnConvTransposeGradOpKernel<float>); | ||
|
||
REGISTER_OP_GPU_KERNEL(conv3d_transpose_cudnn, | ||
ops::CudnnConvTransposeOpKernel<float>); | ||
REGISTER_OP_GPU_KERNEL(conv3d_transpose_cudnn_grad, | ||
ops::CudnnConvTransposeGradOpKernel<float>); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is no double for these ops. Please add in next PR. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
REGISTER double for these ops.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done