-
Notifications
You must be signed in to change notification settings - Fork 18.6k
nd convolution and pooling revision #3515
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
Open
lfz
wants to merge
25
commits into
BVLC:master
Choose a base branch
from
lfz:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
56a0292
Added Nd Convolution and Pooling layers using cuDNN
995b97a
Fix std::vector undefined reference + Various debug
8303fc0
Added factories for Nd operations
60f35c4
Corrected missing REGISTER_LAYER_CLASS
985c5a3
Revert "Corrected missing REGISTER_LAYER_CLASS"
491bf8c
Instantiate virtual forward and backward cpu (Not Implemented)
5edeb6b
Fixed typo in class name
33cf795
Remove Blob dimension if equals to 1
dd02cbc
Made pad_shape and stride_shape optionnal, default to 0 and 1 respect…
6fd06af
Corrected missing parentheses in output shape computation
e03201a
Minor modification to debug usage of cudnn primitives
4d5ef35
Merge branch 'master' into nd-conv-pool
63b7880
Merge branch 'master' into nd-conv-pool
ea9cdaa
Merge remote-tracking branch 'upstream/master' into nd-conv-pool
302e801
merge 2824
lfz 309543e
some vision_layer compatibility
lfz 7cb6df6
blob index issue
lfz 2404676
cudnnAddTensor parameter
lfz 9b6b434
addpara2
lfz bec5ce2
cudnn pos
lfz b4f57c6
legacy
lfz 3bf1fd5
proto id bug
lfz 7a28e56
format
lfz 93ecc55
change scope to pass check
lfz ef7737a
double const fix
lfz 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 hidden or 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 |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| #include <vector> | ||
|
|
||
| #include "caffe/blob.hpp" | ||
| #include "caffe/layer.hpp" | ||
| #include "caffe/proto/caffe.pb.h" | ||
|
|
||
| #include "caffe/layers/conv_layer.hpp" | ||
|
|
||
| namespace caffe { | ||
|
|
||
|
|
||
| template <typename Dtype> | ||
| class CudnnNdConvolutionLayer : public Layer<Dtype> { | ||
| public: | ||
| explicit CudnnNdConvolutionLayer(const LayerParameter& param) | ||
| : Layer<Dtype>(param), handles_setup_(false) {} | ||
| virtual void LayerSetUp(const vector<Blob<Dtype>*>& bottom, | ||
| const vector<Blob<Dtype>*>& top); | ||
| virtual void Reshape(const vector<Blob<Dtype>*>& bottom, | ||
| const vector<Blob<Dtype>*>& top); | ||
| virtual ~CudnnNdConvolutionLayer(); | ||
|
|
||
| virtual inline const char* type() const { return "NdConvolution"; } | ||
|
|
||
| protected: | ||
| virtual void Forward_cpu(const vector<Blob<Dtype>*>& bottom, | ||
| const vector<Blob<Dtype>*>& top); | ||
| virtual void Backward_cpu(const vector<Blob<Dtype>*>& top, | ||
| const vector<bool>& propagate_down, const vector<Blob<Dtype>*>& bottom); | ||
| virtual void Forward_gpu(const vector<Blob<Dtype>*>& bottom, | ||
| const vector<Blob<Dtype>*>& top); | ||
| virtual void Backward_gpu(const vector<Blob<Dtype>*>& top, | ||
| const vector<bool>& propagate_down, const vector<Blob<Dtype>*>& bottom); | ||
|
|
||
| // Compute height_out_ and width_out_ from other parameters. | ||
| virtual void compute_output_shape(); | ||
|
|
||
| vector<int> kernel_shape_; | ||
| vector<int> stride_shape_; | ||
| int num_; | ||
| int channels_; | ||
| vector<int> pad_shape_; | ||
| vector<int> input_shape_; | ||
| int group_; | ||
| int num_output_; | ||
| vector<int> output_shape_; | ||
| bool bias_term_; | ||
|
|
||
| int conv_out_spatial_dim_; | ||
| int kernel_dim_; | ||
| int output_offset_; | ||
|
|
||
| Blob<Dtype> bias_multiplier_; | ||
|
|
||
| bool handles_setup_; | ||
| cudnnHandle_t* handle_; | ||
| cudaStream_t* stream_; | ||
| vector<cudnnTensorDescriptor_t> bottom_descs_, top_descs_; | ||
| cudnnTensorDescriptor_t bias_desc_; | ||
| cudnnFilterDescriptor_t filter_desc_; | ||
| vector<cudnnConvolutionDescriptor_t> conv_descs_; | ||
| int bottom_offset_, top_offset_, weight_offset_, bias_offset_; | ||
| size_t workspaceSizeInBytes; | ||
| void *workspace; | ||
| }; | ||
|
|
||
| } // namespace caffe | ||
|
|
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1,6 +1,5 @@ | ||
| #ifdef USE_CUDNN | ||
| #include <vector> | ||
|
|
||
| #include "caffe/layers/cudnn_conv_layer.hpp" | ||
|
|
||
| namespace caffe { | ||
|
|
||
Oops, something went wrong.
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.
This function takes an additional input arg in CUDNN v4 (or possibly earlier version too)
Something like following will take care of this: