1 #ifndef CAFFE2_OPERATORS_INSTANCE_NORM_OP_H_ 2 #define CAFFE2_OPERATORS_INSTANCE_NORM_OP_H_ 4 #include "caffe2/core/context.h" 5 #include "caffe2/core/operator.h" 6 #include "caffe2/utils/math.h" 10 template <
typename T,
class Context>
13 USE_OPERATOR_CONTEXT_FUNCTIONS;
16 epsilon_(OperatorBase::GetSingleArgument<T>(
"epsilon", 1e-5f)),
17 order_(StringToStorageOrder(
18 OperatorBase::GetSingleArgument<string>(
"order",
"NCHW"))) {
19 CAFFE_ENFORCE(epsilon_ >= 0,
"Must pass a nonnegative epsilon.");
25 case StorageOrder::NHWC:
26 return RunOnDeviceWithOrderNHWC();
27 case StorageOrder::NCHW:
28 return RunOnDeviceWithOrderNCHW();
30 CAFFE_THROW(
"Unknown storage order: ", order_);
34 bool RunOnDeviceWithOrderNHWC();
35 bool RunOnDeviceWithOrderNCHW();
46 INPUT_TAGS(INPUT, SCALE, BIAS);
47 OUTPUT_TAGS(OUTPUT, MEAN, INV_STDEV);
50 template <
typename T,
class Context>
53 USE_OPERATOR_CONTEXT_FUNCTIONS;
56 epsilon_(OperatorBase::GetSingleArgument<T>(
"epsilon", 1e-5f)),
57 order_(StringToStorageOrder(
58 OperatorBase::GetSingleArgument<string>(
"order",
"NCHW"))) {
59 CAFFE_ENFORCE(epsilon_ >= 0,
"Must pass a nonnegative epsilon.");
65 case StorageOrder::NHWC:
66 return RunOnDeviceWithOrderNHWC();
67 case StorageOrder::NCHW:
68 return RunOnDeviceWithOrderNCHW();
70 CAFFE_THROW(
"Unknown storage order: ", order_);
74 bool RunOnDeviceWithOrderNHWC();
75 bool RunOnDeviceWithOrderNCHW();
87 INPUT_TAGS(INPUT, SCALE, BIAS, OUTPUT_GRAD, MEAN, INV_STDEV);
88 OUTPUT_TAGS(INPUT_GRAD, SCALE_GRAD, BIAS_GRAD);
93 #endif // CAFFE2_OPERATORS_INSTANCE_NORM_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 ...