File tree Expand file tree Collapse file tree 5 files changed +143
-1
lines changed Expand file tree Collapse file tree 5 files changed +143
-1
lines changed Original file line number Diff line number Diff line change @@ -9,11 +9,13 @@ evconvert (TensorFlow/ONNX/... to Caffe Converter) related
99atan_layer
1010batch_to_space_nd_layer
1111broadcast_to_layer
12- crop_and_resize
12+ crop_and_resize_layer
13+ ceil_layer
1314depth_to_space_layer
1415div_layer
1516expand_dims_nd_layer
1617floor_div_layer
18+ floor_layer
1719floor_mod_layer
1820gather_layer
1921gather_nd_layer
Original file line number Diff line number Diff line change 1+ #ifndef CAFFE_CEIL_LAYER_HPP_
2+ #define CAFFE_CEIL_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+ namespace caffe {
11+
12+ template <typename Dtype>
13+ class CeilLayer : public Layer <Dtype> {
14+ public:
15+ explicit CeilLayer (const LayerParameter& param) :
16+ Layer<Dtype>(param) {}
17+ virtual void Reshape (const vector<Blob<Dtype>*>& bottom,
18+ const vector<Blob<Dtype>*>& top);
19+
20+ virtual inline const char * type () const {return " Ceil" ;}
21+ virtual inline int ExactBottomBlobs () const {return 1 ;}
22+ virtual inline int ExactNumTopBlobs () const {return 1 ;}
23+
24+ protected:
25+ virtual void Forward_cpu (const vector<Blob<Dtype>*>& bottom,
26+ const vector<Blob<Dtype>*>& top);
27+ virtual void Backward_cpu (const vector<Blob<Dtype>*>& top,
28+ const vector<bool >& propagate_down,
29+ const vector<Blob<Dtype>*>& bottom) {
30+ NOT_IMPLEMENTED;
31+ }
32+
33+ };
34+
35+ } // namespace caffe
36+
37+ #endif // CAFFE_CEIL_LAYER_HPP_
Original file line number Diff line number Diff line change 1+ #ifndef CAFFE_FLOOR_LAYER_HPP_
2+ #define CAFFE_FLOOR_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+ namespace caffe {
11+
12+ template <typename Dtype>
13+ class FloorLayer : public Layer <Dtype> {
14+ public:
15+ explicit FloorLayer (const LayerParameter& param) :
16+ Layer<Dtype>(param) {}
17+ virtual void Reshape (const vector<Blob<Dtype>*>& bottom,
18+ const vector<Blob<Dtype>*>& top);
19+
20+ virtual inline const char * type () const {return " Floor" ;}
21+ virtual inline int ExactBottomBlobs () const {return 1 ;}
22+ virtual inline int ExactNumTopBlobs () const {return 1 ;}
23+
24+ protected:
25+ virtual void Forward_cpu (const vector<Blob<Dtype>*>& bottom,
26+ const vector<Blob<Dtype>*>& top);
27+ virtual void Backward_cpu (const vector<Blob<Dtype>*>& top,
28+ const vector<bool >& propagate_down,
29+ const vector<Blob<Dtype>*>& bottom) {
30+ NOT_IMPLEMENTED;
31+ }
32+
33+ };
34+
35+ } // namespace caffe
36+
37+ #endif // CAFFE_FLOOR_LAYER_HPP_
Original file line number Diff line number Diff line change 1+ #include < algorithm>
2+ #include < functional>
3+ #include < utility>
4+ #include < vector>
5+
6+ #include " caffe/layers/ceil_layer.hpp"
7+
8+ namespace caffe {
9+ template <typename Dtype>
10+ void CeilLayer<Dtype>::Reshape(const vector<Blob<Dtype>*>& bottom,
11+ const vector<Blob<Dtype>*>& top) {
12+ const int count = bottom[0 ]->count ();
13+ // CHECK_NE(top[0], bottom[0]) << this->type() << " Layer does not "
14+ // "allow in-place computation.";
15+ top[0 ]->ReshapeLike (*bottom[0 ]);
16+ CHECK_EQ (count, top[0 ]->count ());
17+ }
18+
19+ template <typename Dtype>
20+ void CeilLayer<Dtype>::Forward_cpu(const vector<Blob<Dtype>*>& bottom,
21+ const vector<Blob<Dtype>*>& top) {
22+ const Dtype* bottom_data = bottom[0 ]->cpu_data ();
23+ Dtype* top_data = top[0 ]->mutable_cpu_data ();
24+ const int count = bottom[0 ]->count ();
25+ for (int i = 0 ; i < count; ++i) {
26+ top_data[i] = ceil (bottom_data[i]);
27+ }
28+ }
29+
30+ INSTANTIATE_CLASS (CeilLayer);
31+ REGISTER_LAYER_CLASS (Ceil);
32+
33+ } // namespace caffe
Original file line number Diff line number Diff line change 1+ #include < algorithm>
2+ #include < functional>
3+ #include < utility>
4+ #include < vector>
5+
6+ #include " caffe/layers/floor_layer.hpp"
7+
8+ namespace caffe {
9+ template <typename Dtype>
10+ void FloorLayer<Dtype>::Reshape(const vector<Blob<Dtype>*>& bottom,
11+ const vector<Blob<Dtype>*>& top) {
12+ const int count = bottom[0 ]->count ();
13+ // CHECK_NE(top[0], bottom[0]) << this->type() << " Layer does not "
14+ // "allow in-place computation.";
15+ top[0 ]->ReshapeLike (*bottom[0 ]);
16+ CHECK_EQ (count, top[0 ]->count ());
17+ }
18+
19+ template <typename Dtype>
20+ void FloorLayer<Dtype>::Forward_cpu(const vector<Blob<Dtype>*>& bottom,
21+ const vector<Blob<Dtype>*>& top) {
22+ const Dtype* bottom_data = bottom[0 ]->cpu_data ();
23+ Dtype* top_data = top[0 ]->mutable_cpu_data ();
24+ const int count = bottom[0 ]->count ();
25+ for (int i = 0 ; i < count; ++i) {
26+ top_data[i] = floor (bottom_data[i]);
27+ }
28+ }
29+
30+ INSTANTIATE_CLASS (FloorLayer);
31+ REGISTER_LAYER_CLASS (Floor);
32+
33+ } // namespace caffe
You can’t perform that action at this time.
0 commit comments