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;
17 size_(OperatorBase::GetSingleArgument<int>(
"size", 0)),
18 alpha_(OperatorBase::GetSingleArgument<float>(
"alpha", 0)),
19 beta_(OperatorBase::GetSingleArgument<float>(
"beta", 0)),
20 bias_(OperatorBase::GetSingleArgument<float>(
"bias", 1)),
21 order_(StringToStorageOrder(
22 OperatorBase::GetSingleArgument<string>(
"order",
"NCHW"))),
23 pre_pad_((size_ - 1) / 2) {
25 DCHECK_EQ(size_ % 2, 1);
30 bool RunOnDevice()
override {
32 case StorageOrder::NHWC:
33 return RunOnDeviceWithOrderNHWC();
34 case StorageOrder::NCHW:
35 return RunOnDeviceWithOrderNCHW();
37 LOG(FATAL) <<
"Unknown storage order: " << order_;
43 virtual bool RunOnDeviceWithOrderNCHW() = 0;
44 virtual bool RunOnDeviceWithOrderNHWC() = 0;
51 const StorageOrder order_;
56 template <
typename T,
class Context>
59 USE_OPERATOR_CONTEXT_FUNCTIONS;
63 bool RunOnDeviceWithOrderNCHW()
override;
64 bool RunOnDeviceWithOrderNHWC()
override;
68 OUTPUT_TAGS(OUTPUT, SCALE);
73 template <
typename T,
class Context>
76 USE_OPERATOR_CONTEXT_FUNCTIONS;
80 bool RunOnDeviceWithOrderNCHW()
override;
81 bool RunOnDeviceWithOrderNHWC()
override;
85 INPUT_TAGS(INPUT, OUTPUT, SCALE, OUTPUT_GRAD);
92 #endif // CAFFE2_OPERATORS_LOCAL_RESPONSE_NORMALIZATION_OP_H_
Tensor is the basic class in Caffe2 that stores a contiguous memory with its shape information...
Workspace is a class that holds all the related objects created during runtime: (1) all blobs...
A global dictionary that holds information about what Caffe2 modules have been loaded in the current ...