1 #ifndef CAFFE2_OPERATORS_CONV_OP_H_ 2 #define CAFFE2_OPERATORS_CONV_OP_H_ 4 #include "caffe2/core/context.h" 5 #include "caffe2/core/operator.h" 6 #include "caffe2/operators/conv_op_shared.h" 7 #include "caffe2/operators/conv_pool_op_base.h" 9 C10_DECLARE_bool(caffe2_force_shared_col_buffer);
13 template <
typename T,
class Context>
16 USE_CONV_POOL_BASE_FUNCTIONS(Context);
22 (group_ == 1 || order_ == StorageOrder::NCHW ||
23 std::is_same<Context, CPUContext>::value),
24 "Group convolution only supports NCHW order or CPUContext right now.");
28 if (FLAGS_caffe2_force_shared_col_buffer || shared_buffer_) {
29 createSharedBuffer<Context>(ws_);
34 bool RunOnDeviceWithOrderNCHW()
override;
35 bool RunOnDeviceWithOrderNHWC()
override;
38 bool Run1x1ConvOnDeviceWithOrderNCHW(
48 bool Run1x1ConvOnDeviceWithOrderNHWC(
58 Tensor col_buffer_{Context::GetDeviceType()};
59 Tensor bias_multiplier_{Context::GetDeviceType()};
60 Tensor img_shape_device_{Context::GetDeviceType()};
61 Tensor col_buffer_shape_device_{Context::GetDeviceType()};
64 INPUT_TAGS(INPUT, FILTER, BIAS);
67 template <
typename T,
class Context>
70 USE_CONV_POOL_BASE_FUNCTIONS(Context);
73 no_bias_(this->
template GetSingleArgument<int>(
"no_bias", 0)) {
75 !(no_bias_ && OutputSize() == 3),
76 "If bias is not present, you should not have 3 grad output.");
78 (group_ == 1 || order_ == StorageOrder::NCHW ||
79 std::is_same<Context, CPUContext>::value),
80 "Group convolution only supports NCHW order or CPUContext right now.");
84 bool RunOnDeviceWithOrderNCHW()
override;
85 bool RunOnDeviceWithOrderNHWC()
override;
90 Tensor img_shape_device_{Context::GetDeviceType()};
91 Tensor col_buffer_shape_device_{Context::GetDeviceType()};
95 INPUT_TAGS(INPUT, FILTER, OUTPUT_GRAD);
96 OUTPUT_TAGS(FILTER_GRAD, BIAS_OR_INPUT_GRAD, INPUT_GRAD);
101 #endif // CAFFE2_OPERATORS_CONV_OP_H_
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 ...