1 #ifndef CAFFE2_OPERATORS_LOCAL_RESPONSE_NORMALIZATION_OP_H_ 2 #define CAFFE2_OPERATORS_LOCAL_RESPONSE_NORMALIZATION_OP_H_ 4 #include "caffe2/core/context.h" 5 #include "caffe2/core/logging.h" 6 #include "caffe2/core/operator.h" 7 #include "caffe2/utils/math.h" 11 template <
typename T,
class Context>
14 USE_OPERATOR_CONTEXT_FUNCTIONS;
15 template <
class... Args>
18 size_(this->
template GetSingleArgument<int>(
"size", 0)),
19 alpha_(this->
template GetSingleArgument<float>(
"alpha", 0)),
20 beta_(this->
template GetSingleArgument<float>(
"beta", 0)),
21 bias_(this->
template GetSingleArgument<float>(
"bias", 1)),
22 order_(StringToStorageOrder(
23 this->
template GetSingleArgument<string>(
"order",
"NCHW"))),
24 pre_pad_((size_ - 1) / 2) {
26 DCHECK_EQ(size_ % 2, 1);
31 bool RunOnDevice()
override {
33 case StorageOrder::NHWC:
34 return RunOnDeviceWithOrderNHWC();
35 case StorageOrder::NCHW:
36 return RunOnDeviceWithOrderNCHW();
38 LOG(FATAL) <<
"Unknown storage order: " << order_;
44 virtual bool RunOnDeviceWithOrderNCHW() = 0;
45 virtual bool RunOnDeviceWithOrderNHWC() = 0;
52 const StorageOrder order_;
57 template <
typename T,
class Context>
60 USE_OPERATOR_CONTEXT_FUNCTIONS;
61 template <
class... Args>
62 explicit LRNOp(Args&&... args)
65 bool RunOnDeviceWithOrderNCHW()
override;
66 bool RunOnDeviceWithOrderNHWC()
override;
70 OUTPUT_TAGS(OUTPUT, SCALE);
72 Tensor local_scale_tensor_{Context::GetDeviceType()};
75 template <
typename T,
class Context>
78 USE_OPERATOR_CONTEXT_FUNCTIONS;
79 template <
class... Args>
83 bool RunOnDeviceWithOrderNCHW()
override;
84 bool RunOnDeviceWithOrderNHWC()
override;
88 INPUT_TAGS(INPUT, OUTPUT, SCALE, OUTPUT_GRAD);
90 Tensor local_scale_tensor_{Context::GetDeviceType()};
95 #endif // CAFFE2_OPERATORS_LOCAL_RESPONSE_NORMALIZATION_OP_H_
A global dictionary that holds information about what Caffe2 modules have been loaded in the current ...