Skip to content

Commit d0100ba

Browse files
thatguymikeshelhamer
authored andcommitted
Workaround for inplace max pooling issue
1 parent cff6f3d commit d0100ba

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

src/caffe/layer_factory.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,16 @@ shared_ptr<Layer<Dtype> > GetPoolingLayer(const LayerParameter& param) {
9191
<< "Using Caffe's own pooling layer.";
9292
return shared_ptr<Layer<Dtype> >(new PoolingLayer<Dtype>(param));
9393
}
94-
return shared_ptr<Layer<Dtype> >(new CuDNNPoolingLayer<Dtype>(param));
94+
// CuDNN assumes layers are not being modified in place, thus
95+
// breaking our index tracking for updates in some cases in Caffe.
96+
// Until there is a workaround in Caffe (index management) or
97+
// cuDNN, use Caffe layer to max pooling, or don't use in place
98+
// layers after max pooling layers
99+
if (param.pooling_param().pool() == PoolingParameter_PoolMethod_MAX) {
100+
return shared_ptr<Layer<Dtype> >(new PoolingLayer<Dtype>(param));
101+
} else {
102+
return shared_ptr<Layer<Dtype> >(new CuDNNPoolingLayer<Dtype>(param));
103+
}
95104
#endif
96105
} else {
97106
LOG(FATAL) << "Layer " << param.name() << " has unknown engine.";

0 commit comments

Comments
 (0)