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

Class BaseConvolutionLayer

include/caffe/layers/base_conv_layer.hpp:18–170  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16 */
17template <typename Dtype>
18class BaseConvolutionLayer : public Layer<Dtype> {
19 public:
20 explicit BaseConvolutionLayer(const LayerParameter& param)
21 : Layer<Dtype>(param) {}
22 virtual void LayerSetUp(const vector<Blob<Dtype>*>& bottom,
23 const vector<Blob<Dtype>*>& top);
24 virtual void Reshape(const vector<Blob<Dtype>*>& bottom,
25 const vector<Blob<Dtype>*>& top);
26
27 virtual inline int MinBottomBlobs() const { return 1; }
28 virtual inline int MinTopBlobs() const { return 1; }
29 virtual inline bool EqualNumBottomTopBlobs() const { return true; }
30
31 protected:
32 // Helper functions that abstract away the column buffer and gemm arguments.
33 // The last argument in forward_cpu_gemm is so that we can skip the im2col if
34 // we just called weight_cpu_gemm with the same input.
35 void forward_cpu_gemm(const Dtype* input, const Dtype* weights,
36 Dtype* output, bool skip_im2col = false);
37 void forward_cpu_bias(Dtype* output, const Dtype* bias);
38 void backward_cpu_gemm(const Dtype* input, const Dtype* weights,
39 Dtype* output);
40 void weight_cpu_gemm(const Dtype* input, const Dtype* output, Dtype*
41 weights);
42 void backward_cpu_bias(Dtype* bias, const Dtype* input);
43
44#ifndef CPU_ONLY
45 void forward_gpu_gemm(const Dtype* col_input, const Dtype* weights,
46 Dtype* output, bool skip_im2col = false);
47 void forward_gpu_bias(Dtype* output, const Dtype* bias);
48 void backward_gpu_gemm(const Dtype* input, const Dtype* weights,
49 Dtype* col_output);
50 void weight_gpu_gemm(const Dtype* col_input, const Dtype* output, Dtype*
51 weights);
52 void backward_gpu_bias(Dtype* bias, const Dtype* input);
53#endif
54
55 /// @brief The spatial dimensions of the input.
56 inline int input_shape(int i) {
57 return (*bottom_shape_)[channel_axis_ + i];
58 }
59 // reverse_dimensions should return true iff we are implementing deconv, so
60 // that conv helpers know which dimensions are which.
61 virtual bool reverse_dimensions() = 0;
62 // Compute height_out_ and width_out_ from other parameters.
63 virtual void compute_output_shape() = 0;
64
65 /// @brief The spatial dimensions of a filter kernel.
66 Blob<int> kernel_shape_;
67 /// @brief The spatial dimensions of the stride.
68 Blob<int> stride_;
69 /// @brief The spatial dimensions of the padding.
70 Blob<int> pad_;
71 /// @brief The spatial dimensions of the dilation.
72 Blob<int> dilation_;
73 /// @brief The spatial dimensions of the convolution input.
74 Blob<int> conv_input_shape_;
75 /// @brief The spatial dimensions of the col_buffer.

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected