1 #include <caffe2/ideep/operators/conv_pool_base_op.h>     7   USE_IDEEP_DEF_ALIASES();
     8   USE_IDEEP_CONV_POOL_BASE_FUNCTIONS();
    13             OperatorBase::GetSingleArgument<int>(
"training_mode", 0)),
    15             OperatorBase::GetSingleArgument<int>(
"conv_algorithm", CONV_ALGORITHM_AUTO)) {
    16     OPERATOR_NEEDS_FEATURE(
    17         pad_l() == pad_r() && pad_t() == pad_b(),
    18         "Uneven padding not supported.");
    22   bool RunOnDeviceWithOrderNCHW()
 override {
    23     const auto& X = Input(INPUT);
    24     const auto& filter = Input(FILTER);
    25     auto* Y = Output(OUTPUT);
    26     auto Y_dims = CalcOutputDims(X, filter.get_dim(0));
    28     CAFFE_ENFORCE(4 == X.ndims());
    29     CAFFE_ENFORCE(4 == filter.ndims());
    30     CAFFE_ENFORCE(filter.get_dim(2) == kernel_h());
    31     CAFFE_ENFORCE(filter.get_dim(3) == kernel_w());
    33         X.get_dim(1) == filter.get_dim(1) * group_,
    34         "Convolution op: input channels does not match: # of input channels ",
    36         " is not equal to kernel channels * group:",
    41     ideep::algorithm aalgorithm = ideep::algorithm::convolution_direct;
    42     if (conv_algorithm_ == CONV_ALGORITHM_WINOGRAD) {
    43       aalgorithm = ideep::algorithm::convolution_winograd;
    46     bool weights_changed =
    47         (cached_weights_descriptor_ != filter.get_descriptor());
    48     if (weights_changed && !training_mode_) {
    49       cached_weights_descriptor_ = filter.get_descriptor();
    50       auto filter_in = filter;
    51       filter_in.make_group(group_);
    52       auto expected_descriptor =
    53           ideep::convolution_forward::expected_weights_descriptor(
    55               filter_in.get_data_type(),
    62       filter_.init<ideep::utils::allocator, ideep::convolution_forward>(
    64       ideep::reorder::compute(filter_in, filter_);
    73     if (InputSize() > BIAS) {
    74       ideep::convolution_forward::compute(
    76           training_mode_ ? filter : filter_,
    85           ideep::descriptor_group::attr_t(),
    88       ideep::convolution_forward::compute(
    90           training_mode_ ? filter : filter_,
    98           ideep::descriptor_group::attr_t(),
   106   INPUT_TAGS(INPUT, FILTER, BIAS);
   111   ideep::tensor filter_;
   112   ideep::tensor::descriptor cached_weights_descriptor_;
   117   USE_IDEEP_DEF_ALIASES();
   118   USE_IDEEP_CONV_POOL_BASE_FUNCTIONS();
   122         no_bias_(OperatorBase::GetSingleArgument<int>(
"no_bias", 0)) {
   123     OPERATOR_NEEDS_FEATURE(
   124         pad_l() == pad_r() && pad_t() == pad_b(),
   125         "Uneven padding not supported.");
   127         !(no_bias_ && OutputSize() == 3),
   128         "If bias is not present, you should not have 3 grad output.");
   130         OperatorBase::GetSingleArgument<int>(
"training_mode", 0),
   131         "In order to backward propagate weights correctly, "   132         "please set training_mode=1");
   136   bool RunOnDeviceWithOrderNCHW()
 override {
   137     const auto& X = Input(INPUT);
   138     const auto& filter = Input(FILTER);
   139     const auto& dY = Input(OUTPUT_GRAD);
   140     auto* dfilter = Output(FILTER_GRAD);
   143       ideep::convolution_backward_weights::compute(
   154       auto* dbias = Output(BIAS_OR_INPUT_GRAD);
   155       ideep::convolution_backward_weights::compute(
   168     if (OutputSize() == 3 || (no_bias_ && (OutputSize() == 2))) {
   169       auto* dX = Output(no_bias_ ? BIAS_OR_INPUT_GRAD : INPUT_GRAD);
   170       ideep::convolution_backward_data::compute(
   188   INPUT_TAGS(INPUT, FILTER, OUTPUT_GRAD);
   189   OUTPUT_TAGS(FILTER_GRAD, BIAS_OR_INPUT_GRAD, INPUT_GRAD);
 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 ...