Caffe2 - C++ API
A deep learning, cross platform ML framework
roi_pool_f_op.h
1 
17 #ifndef ROI_POOL_F_OP_H_
18 #define ROI_POOL_F_OP_H_
19 
20 #include "caffe2/core/context.h"
21 #include "caffe2/core/logging.h"
22 #include "caffe2/core/operator.h"
23 #include "caffe2/utils/math.h"
24 
25 namespace caffe2 {
26 
27 template <typename T, class Context>
28 class RoIPoolFOp final : public Operator<Context> {
29  public:
30  RoIPoolFOp(const OperatorDef& operator_def, Workspace* ws)
31  : Operator<Context>(operator_def, ws),
32  spatial_scale_(this->template GetSingleArgument<float>(
33  "spatial_scale", 1.)),
34  pooled_height_(this->template GetSingleArgument<int>("pooled_h", 1)),
35  pooled_width_(this->template GetSingleArgument<int>("pooled_w", 1)) {
36  DCHECK_GT(spatial_scale_, 0);
37  DCHECK_GT(pooled_height_, 0);
38  DCHECK_GT(pooled_width_, 0);
39  }
40  USE_OPERATOR_CONTEXT_FUNCTIONS;
41 
42  bool RunOnDevice() override {
43  // No CPU implementation for now
44  CAFFE_NOT_IMPLEMENTED;
45  }
46 
47  protected:
48  float spatial_scale_;
49  int pooled_height_;
50  int pooled_width_;
51 };
52 
53 template <typename T, class Context>
54 class RoIPoolFGradientOp final : public Operator<Context> {
55  public:
56  RoIPoolFGradientOp(const OperatorDef& def, Workspace* ws)
57  : Operator<Context>(def, ws),
58  spatial_scale_(this->template GetSingleArgument<float>(
59  "spatial_scale", 1.)),
60  pooled_height_(this->template GetSingleArgument<int>("pooled_h", 1)),
61  pooled_width_(this->template GetSingleArgument<int>("pooled_w", 1)) {
62  DCHECK_GT(spatial_scale_, 0);
63  DCHECK_GT(pooled_height_, 0);
64  DCHECK_GT(pooled_width_, 0);
65  }
66  USE_OPERATOR_CONTEXT_FUNCTIONS;
67 
68  bool RunOnDevice() override {
69  // No CPU implementation for now
70  CAFFE_NOT_IMPLEMENTED;
71  }
72 
73  protected:
74  float spatial_scale_;
75  int pooled_height_;
76  int pooled_width_;
77 };
78 
79 } // namespace caffe2
80 
81 #endif // ROI_POOL_F_OP_H_
Workspace is a class that holds all the related objects created during runtime: (1) all blobs...
Definition: workspace.h:47
A global dictionary that holds information about what Caffe2 modules have been loaded in the current ...
Definition: blob.h:13