MCPcopy Create free account
hub / github.com/BVLC/caffe / GetConvolutionLayer

Function GetConvolutionLayer

src/caffe/layer_factory.cpp:38–72  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

36// Get convolution layer according to engine.
37template <typename Dtype>
38shared_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
74REGISTER_LAYER_CREATOR(Convolution, GetConvolutionLayer);
75

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected