1 #ifndef CAFFE2_OPERATORS_PAD_OP_H_ 2 #define CAFFE2_OPERATORS_PAD_OP_H_ 4 #include "caffe2/core/context.h" 5 #include "caffe2/core/logging.h" 6 #include "caffe2/core/operator.h" 7 #include "caffe2/operators/conv_pool_op_base.h" 8 #include "caffe2/utils/math.h" 19 CAFFE2_API PadMode StringToPadMode(
const string&);
21 template <
typename T,
class Context>
24 USE_CONV_POOL_BASE_FUNCTIONS(Context);
25 template <
class... Args>
28 mode_(StringToPadMode(
29 this->
template GetSingleArgument<string>(
"mode",
"constant"))),
30 value_(static_cast<T>(
31 this->
template GetSingleArgument<float>(
"value", 0.0))) {
33 legacy_pad_ == LegacyPadding::NOTSET,
34 "Padding layer only supports explicit pad values.");
36 dilation_h() == 1 && dilation_w() == 1,
37 "Pooling op does not support dilation right now.");
39 stride_h() == 1 && stride_w() == 1,
40 "Pooling op does not support stride right now.");
43 kernel_.assign(pads_.size() / 2, 1);
47 bool RunOnDeviceWithOrderNCHW()
override;
48 bool RunOnDeviceWithOrderNHWC()
override;
50 static std::vector<TensorShape> PadTensorInference(
51 const OperatorDef& def,
52 const vector<TensorShape>& in);
62 template <
typename T,
class Context>
65 USE_CONV_POOL_BASE_FUNCTIONS(Context);
66 template <
class... Args>
69 mode_(StringToPadMode(
70 this->
template GetSingleArgument<string>(
"mode",
"constant"))) {
72 legacy_pad_ == LegacyPadding::NOTSET,
73 "Padding layer only supports explicit pad values.");
75 dilation_h() == 1 && dilation_w() == 1,
76 "Pooling op does not support dilation right now.");
79 kernel_.assign(pads_.size() / 2, 1);
81 ~PadImageGradientOp() {}
83 bool RunOnDeviceWithOrderNCHW()
override;
84 bool RunOnDeviceWithOrderNHWC()
override;
94 #endif // CAFFE2_OPERATORS_PAD_OP_H_
A global dictionary that holds information about what Caffe2 modules have been loaded in the current ...