Skip to content
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

fix cudnn conv bug which occurs in image classfication demo in GTX GPU #107

Merged
merged 2 commits into from
Sep 23, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions paddle/gserver/layers/CudnnConvLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ bool CudnnConvLayer::init(const LayerMap &layerMap,
biasOffset_ = numFilters_ / groups_[0];
}

batchNum_ = 0;
isSelectAlgo_ = false;
return true;
}
Expand Down Expand Up @@ -132,6 +133,9 @@ void CudnnConvLayer::reshape(int batchSize) {
getOutput().setFrameHeight(outputH_);
getOutput().setFrameWidth(outputW_);

isSelectAlgo_ = (batchSize == batchNum_);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add some comment.

batchNum_ = batchSize;

size_t maxWorkSpace = 0;
for (size_t i = 0; i < inputLayers_.size(); i++) {
CHECK_EQ(inputLayers_[i]->getOutput().value->getWidth(),
Expand Down Expand Up @@ -160,6 +164,10 @@ void CudnnConvLayer::reshape(int batchSize) {

maxWorkSpace = std::max(fwdLimitBytes_[i], bwdDataLimitBytes_[i]);
maxWorkSpace = std::max(maxWorkSpace, bwdFilterLimitBytes_[i]);

VLOG(3) << getName() << " Fwd / BwdData / BwdFilter algo: " << fwdAlgo_[i]
<< " / " << bwdDataAlgo_[i]
<< " / " << bwdFilterAlgo_[i];
}
}

Expand Down
4 changes: 4 additions & 0 deletions paddle/gserver/layers/CudnnConvLayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ class CudnnConvLayer : public ConvBaseLayer {
/// Is or not select conv algorihtm.
bool isSelectAlgo_;

/// batchNum is used to record batch size. If the batch size is changed,
/// the selection algorithm will be called.
int batchNum_;

public:
explicit CudnnConvLayer(const LayerConfig& config) : ConvBaseLayer(config) {}

Expand Down