| 76 | // Get pooling layer according to engine. |
| 77 | template <typename Dtype> |
| 78 | shared_ptr<Layer<Dtype> > GetPoolingLayer(const LayerParameter& param) { |
| 79 | PoolingParameter_Engine engine = param.pooling_param().engine(); |
| 80 | if (engine == PoolingParameter_Engine_DEFAULT) { |
| 81 | engine = PoolingParameter_Engine_CAFFE; |
| 82 | #ifdef USE_CUDNN |
| 83 | engine = PoolingParameter_Engine_CUDNN; |
| 84 | #endif |
| 85 | } |
| 86 | if (engine == PoolingParameter_Engine_CAFFE) { |
| 87 | return shared_ptr<Layer<Dtype> >(new PoolingLayer<Dtype>(param)); |
| 88 | #ifdef USE_CUDNN |
| 89 | } else if (engine == PoolingParameter_Engine_CUDNN) { |
| 90 | if (param.top_size() > 1) { |
| 91 | LOG(INFO) << "cuDNN does not support multiple tops. " |
| 92 | << "Using Caffe's own pooling layer."; |
| 93 | return shared_ptr<Layer<Dtype> >(new PoolingLayer<Dtype>(param)); |
| 94 | } |
| 95 | // CuDNN assumes layers are not being modified in place, thus |
| 96 | // breaking our index tracking for updates in some cases in Caffe. |
| 97 | // Until there is a workaround in Caffe (index management) or |
| 98 | // cuDNN, use Caffe layer to max pooling, or don't use in place |
| 99 | // layers after max pooling layers |
| 100 | if (param.pooling_param().pool() == PoolingParameter_PoolMethod_MAX) { |
| 101 | return shared_ptr<Layer<Dtype> >(new PoolingLayer<Dtype>(param)); |
| 102 | } else { |
| 103 | return shared_ptr<Layer<Dtype> >(new CuDNNPoolingLayer<Dtype>(param)); |
| 104 | } |
| 105 | #endif |
| 106 | } else { |
| 107 | LOG(FATAL) << "Layer " << param.name() << " has unknown engine."; |
| 108 | throw; // Avoids missing return warning |
| 109 | } |
| 110 | } |
| 111 | |
| 112 | REGISTER_LAYER_CREATOR(Pooling, GetPoolingLayer); |
| 113 |
nothing calls this directly
no outgoing calls
no test coverage detected