b0b0304d1329181d377c3aab540a1e93af821db8
[platform/upstream/caffeonacl.git] / src / caffe / layers / acl_absval_layer.cpp
1 #ifdef USE_ACL
2 #include <vector>
3
4 #include "caffe/layers/acl_absval_layer.hpp"
5 #include "caffe/util/math_functions.hpp"
6
7 namespace caffe {
8
9 template <typename Dtype>
10 void ACLAbsValLayer<Dtype>::LayerSetUp(const vector<Blob<Dtype>*>& bottom,
11       const vector<Blob<Dtype>*>& top) {
12   AbsValLayer<Dtype>::LayerSetUp(bottom, top);
13   ACLBaseActivationLayer<Dtype>::LayerSetUp(bottom, top);
14   this->force_bypass_acl_path_= bypass_acl_class_layer & FLAGS_ENABLE_ACL_ABSVAL;
15 }
16
17 template <typename Dtype>
18 void ACLAbsValLayer<Dtype>::SetupACLLayer(const vector<Blob<Dtype>*>& bottom,
19       const vector<Blob<Dtype>*>& top,ActivationLayerInfo::ActivationFunction type){
20     ACLBaseActivationLayer<Dtype>::SetupACLLayer(bottom, top,ActivationLayerInfo::ActivationFunction::ABS);
21 }
22
23 template <typename Dtype>
24 void ACLAbsValLayer<Dtype>::Reshape(const vector<Blob<Dtype>*>& bottom,
25       const vector<Blob<Dtype>*>& top) {
26   AbsValLayer<Dtype>::Reshape(bottom, top);
27   ACLBaseActivationLayer<Dtype>::Reshape(bottom, top);
28 }
29
30 template <typename Dtype>
31 void ACLAbsValLayer<Dtype>::Forward_cpu(
32     const vector<Blob<Dtype>*>& bottom, const vector<Blob<Dtype>*>& top) {
33 #ifdef USE_PROFILING
34     logtime_util log_time(ACL_ABSVAL_INFO);
35 #endif //USE_PROFILING
36     if (this->force_bypass_acl_path_) {
37         AbsValLayer<Dtype>::Forward_cpu(bottom,top);
38         return;
39     }
40     ACLBaseActivationLayer<Dtype>::Forward_cpu(bottom,top);
41 }
42
43 template <typename Dtype>
44 void ACLAbsValLayer<Dtype>::Forward_gpu(
45     const vector<Blob<Dtype>*>& bottom, const vector<Blob<Dtype>*>& top) {
46 #ifdef USE_PROFILING
47     logtime_util log_time(ACL_ABSVAL_INFO);
48 #endif //USE_PROFILING
49     if (this->force_bypass_acl_path_) {
50         AbsValLayer<Dtype>::Forward_cpu(bottom,top);
51         return;
52     }
53     ACLBaseActivationLayer<Dtype>::Forward_gpu(bottom,top);
54 }
55
56 template <typename Dtype>
57 ACLAbsValLayer<Dtype>::~ACLAbsValLayer() {
58 }
59
60 INSTANTIATE_CLASS(ACLAbsValLayer);
61
62 }  // namespace caffe
63
64 #endif  // USE_ACL