Caffe2 - C++ API
A deep learning, cross platform ML framework
roi_pool_f_op.cc
1 
17 #include "roi_pool_f_op.h"
18 
19 namespace caffe2 {
20 
21 REGISTER_CPU_OPERATOR(RoIPoolF, RoIPoolFOp<float, CPUContext>);
22 REGISTER_CPU_OPERATOR(RoIPoolFGradient, RoIPoolFGradientOp<float, CPUContext>);
23 
24 OPERATOR_SCHEMA(RoIPoolF)
25  .NumInputs(2)
26  .NumOutputs(2)
27  .SetDoc(R"DOC(
28 Region of Interest (RoI) pooling operation as used in Fast R-CNN.
29 )DOC")
30  .Arg(
31  "spatial_scale",
32  "(float) default 1.0; Spatial scale of the input feature map X "
33  "relative to the input image. E.g., 0.0625 if X has a stride of 16 "
34  "w.r.t. the input image.")
35  .Arg(
36  "pooled_h",
37  "(int) default 1; Pooled output Y's height.")
38  .Arg(
39  "pooled_w",
40  "(int) default 1; Pooled output Y's width.")
41  .Input(
42  0,
43  "X",
44  "4D feature map input of shape (N, C, H, W).")
45  .Input(
46  1,
47  "RoIs",
48  "2D input of shape (R, 5) specifying R RoIs with five columns "
49  "representing: batch index in [0, N - 1], x1, y1, x2, y2. The RoI "
50  "coordinates are in the coordinate system of the input image.")
51  .Output(
52  0,
53  "Y",
54  "4D output of shape (R, C, pooled_h, pooled_w). The r-th batch element "
55  "is a pooled feature map cooresponding to the r-th RoI.")
56  .Output(
57  1,
58  "argmaxes",
59  "4D output of shape (R, C, pooled_h, pooled_w). Same as Y, except it "
60  "records the argmax indices rather than the max pooled values.");
61 
62 OPERATOR_SCHEMA(RoIPoolFGradient)
63  .NumInputs(4)
64  .NumOutputs(1)
65  .Input(
66  0,
67  "X",
68  "See RoIPoolF.")
69  .Input(
70  1,
71  "RoIs",
72  "See RoIPoolF.")
73  .Input(
74  2,
75  "argmaxes",
76  "See RoIPoolF.")
77  .Input(
78  3,
79  "dY",
80  "Gradient of forward output 0 (Y)")
81  .Output(
82  0,
83  "dX",
84  "Gradient of forward input 0 (X)");
85 
86 class GetRoIPoolFGradient : public GradientMakerBase {
87  using GradientMakerBase::GradientMakerBase;
88  vector<OperatorDef> GetGradientDefs() override {
89  return SingleGradientDef(
90  "RoIPoolFGradient",
91  "",
92  vector<string>{I(0), I(1), O(1), GO(0)},
93  vector<string>{GI(0)});
94  }
95 };
96 
97 REGISTER_GRADIENT(RoIPoolF, GetRoIPoolFGradient);
98 
99 } // namespace caffe2
A global dictionary that holds information about what Caffe2 modules have been loaded in the current ...
Definition: blob.h:13