6b38eb28d6ffead2b8cbe2c056b85a60a3e66c80
[platform/upstream/caffeonacl.git] / include / caffe / layers / acl_base_conv_layer.hpp
1 #ifndef CAFFE_ACL_BASE_CONV_LAYER_HPP_
2 #define CAFFE_ACL_BASE_CONV_LAYER_HPP_
3
4 #include <vector>
5
6 #include "caffe/blob.hpp"
7 #include "caffe/layer.hpp"
8 #include "caffe/proto/caffe.pb.h"
9
10 #include "caffe/layers/conv_layer.hpp"
11
12 #ifdef USE_ACL
13 #include "caffe/acl_layer.hpp"
14 #endif
15
16 namespace caffe {
17
18 #ifdef USE_ACL
19 /*
20  * @brief ACL implementation of ConvolutionLayer.
21  *        Fallback to ConvolutionLayer for some corner cases.
22  *
23 */
24 template <typename Dtype,typename GPUConvLayer,typename CPUConvLayer>
25 class ACLConvolutionLayer : public ACLBaseLayer<GPUConvLayer,CPUConvLayer>,public ConvolutionLayer<Dtype> {
26  public:
27   explicit ACLConvolutionLayer(const LayerParameter& param)
28       : ConvolutionLayer<Dtype>(param) {}
29   virtual void LayerSetUp(const vector<Blob<Dtype>*>& bottom,
30       const vector<Blob<Dtype>*>& top);
31   virtual void Reshape(const vector<Blob<Dtype>*>& bottom,
32       const vector<Blob<Dtype>*>& top);
33   virtual ~ACLConvolutionLayer();
34
35  protected:
36   virtual void Forward_gpu(const vector<Blob<Dtype>*>& bottom,
37       const vector<Blob<Dtype>*>& top);
38   virtual void Forward_cpu(const vector<Blob<Dtype>*>& bottom,
39       const vector<Blob<Dtype>*>& top);
40   virtual void Backward_gpu(const vector<Blob<Dtype>*>& top,
41       const vector<bool>& propagate_down, const vector<Blob<Dtype>*>& bottom){
42                   NOT_IMPLEMENTED;
43       }
44   virtual void Backward_cpu(const vector<Blob<Dtype>*>& top,
45       const vector<bool>& propagate_down, const vector<Blob<Dtype>*>& bottom){
46                   NOT_IMPLEMENTED;
47       }
48   virtual void SetupACLLayer(const vector<Blob<Dtype>*>& bottom,
49       const vector<Blob<Dtype>*>& top);
50
51 };
52 #endif
53
54 }  // namespace caffe
55
56 // Instantiate a class with float and double specifications.
57 #define INSTANTIATE_CONV_CLASS(classname,GPUConvLayer,CPUConvLayer) \
58   template class classname<float,GPUConvLayer,CPUConvLayer>; \
59   template class classname<double,GPUConvLayer,CPUConvLayer>
60
61 #endif  // CAFFE_ACL_BASE_CONV_LAYER_HPP_