| 36 | // Get convolution layer according to engine. |
| 37 | template <typename Dtype> |
| 38 | shared_ptr<Layer<Dtype> > GetConvolutionLayer( |
| 39 | const LayerParameter& param) { |
| 40 | ConvolutionParameter conv_param = param.convolution_param(); |
| 41 | ConvolutionParameter_Engine engine = conv_param.engine(); |
| 42 | #ifdef USE_CUDNN |
| 43 | bool use_dilation = false; |
| 44 | for (int i = 0; i < conv_param.dilation_size(); ++i) { |
| 45 | if (conv_param.dilation(i) > 1) { |
| 46 | use_dilation = true; |
| 47 | } |
| 48 | } |
| 49 | #endif |
| 50 | if (engine == ConvolutionParameter_Engine_DEFAULT) { |
| 51 | engine = ConvolutionParameter_Engine_CAFFE; |
| 52 | #ifdef USE_CUDNN |
| 53 | if (!use_dilation) { |
| 54 | engine = ConvolutionParameter_Engine_CUDNN; |
| 55 | } |
| 56 | #endif |
| 57 | } |
| 58 | if (engine == ConvolutionParameter_Engine_CAFFE) { |
| 59 | return shared_ptr<Layer<Dtype> >(new ConvolutionLayer<Dtype>(param)); |
| 60 | #ifdef USE_CUDNN |
| 61 | } else if (engine == ConvolutionParameter_Engine_CUDNN) { |
| 62 | if (use_dilation) { |
| 63 | LOG(FATAL) << "CuDNN doesn't support the dilated convolution at Layer " |
| 64 | << param.name(); |
| 65 | } |
| 66 | return shared_ptr<Layer<Dtype> >(new CuDNNConvolutionLayer<Dtype>(param)); |
| 67 | #endif |
| 68 | } else { |
| 69 | LOG(FATAL) << "Layer " << param.name() << " has unknown engine."; |
| 70 | throw; // Avoids missing return warning |
| 71 | } |
| 72 | } |
| 73 | |
| 74 | REGISTER_LAYER_CREATOR(Convolution, GetConvolutionLayer); |
| 75 |
nothing calls this directly
no outgoing calls
no test coverage detected