Skip to content

Commit

Permalink
Merge pull request #103 from thatguymike/maxpool_workaround
Browse files Browse the repository at this point in the history
Cleaner workaround for max pool
  • Loading branch information
drnikolaev committed Jan 20, 2016
2 parents b3a4a1a + 3724101 commit 4d58e6d
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/caffe/layer_factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,14 @@ shared_ptr<Layer<Dtype> > GetPoolingLayer(const LayerParameter& param) {
} else if (engine == PoolingParameter_Engine_CUDNN) {
PoolingParameter p_param = param.pooling_param();

// FIXME We assume that precision issue will be fixed in cuDNN v5.0
#if CUDNN_VERSION >= 5000
return shared_ptr<Layer<Dtype> >(new CuDNNPoolingLayer<Dtype>(param));
#else
return shared_ptr<Layer<Dtype> >(new PoolingLayer<Dtype>(param));
#endif

// CuDNN handles tie breaks differently than Caffe for MaxPooling.
// Until there is a workaround in Caffe (index management) or cuDNN,
// use Caffe layer to max pooling
if (param.pooling_param().pool() == PoolingParameter_PoolMethod_MAX) {
return shared_ptr<Layer<Dtype> >(new PoolingLayer<Dtype>(param));
} else {
return shared_ptr<Layer<Dtype> >(new CuDNNPoolingLayer<Dtype>(param));
}
#endif
} else {
LOG(FATAL) << "Layer " << param.name() << " has unknown engine.";
Expand Down

0 comments on commit 4d58e6d

Please sign in to comment.