mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
Summary: As GoogleTest `TEST` macro is non-compliant with it as well as `DEFINE_DISPATCH` All changes but the ones to `.clang-tidy` are generated using following script: ``` for i in `find . -type f -iname "*.c*" -or -iname "*.h"|xargs grep cppcoreguidelines-avoid-non-const-global-variables|cut -f1 -d:|sort|uniq`; do sed -i "/\/\/ NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)/d" $i; done ``` Pull Request resolved: https://github.com/pytorch/pytorch/pull/62008 Reviewed By: driazati, r-barnes Differential Revision: D29838584 Pulled By: malfet fbshipit-source-id: 1b2f8602c945bd4ce50a9bfdd204755556e31d13
51 lines
1.6 KiB
C++
51 lines
1.6 KiB
C++
#include "caffe2/operators/conv_transpose_op.h"
|
|
#include "caffe2/operators/conv_transpose_op_impl.h"
|
|
|
|
namespace caffe2 {
|
|
|
|
REGISTER_CPU_OPERATOR(
|
|
ConvTransposeGradient,
|
|
ConvTransposeGradientOp<float, CPUContext>);
|
|
|
|
OPERATOR_SCHEMA(ConvTransposeGradient).NumInputs(3).NumOutputs(1, 3);
|
|
|
|
class GetConvTransposeGradient : public GradientMakerBase {
|
|
using GradientMakerBase::GradientMakerBase;
|
|
vector<OperatorDef> GetGradientDefs() override {
|
|
auto compute_dX =
|
|
!ArgumentHelper::GetSingleArgument(def_, "no_gradient_to_input", false);
|
|
|
|
CAFFE_ENFORCE(3 == def_.input_size() || 2 == def_.input_size());
|
|
if (def_.input_size() == 3 && compute_dX) {
|
|
return SingleGradientDef(
|
|
"ConvTransposeGradient",
|
|
"",
|
|
vector<string>{I(0), I(1), GO(0)},
|
|
vector<string>{GI(1), GI(2), GI(0)});
|
|
} else if (def_.input_size() == 3) {
|
|
return SingleGradientDef(
|
|
"ConvTransposeGradient",
|
|
"",
|
|
vector<string>{I(0), I(1), GO(0)},
|
|
vector<string>{GI(1), GI(2)});
|
|
} else if (compute_dX) {
|
|
return SingleGradientDef(
|
|
"ConvTransposeGradient",
|
|
"",
|
|
vector<string>{I(0), I(1), GO(0)},
|
|
vector<string>{GI(1), GI(0)},
|
|
vector<Argument>{MakeArgument<bool>("no_bias", true)});
|
|
} else {
|
|
return SingleGradientDef(
|
|
"ConvTransposeGradient",
|
|
"",
|
|
vector<string>{I(0), I(1), GO(0)},
|
|
vector<string>{GI(1)},
|
|
vector<Argument>{MakeArgument<bool>("no_bias", true)});
|
|
}
|
|
}
|
|
};
|
|
REGISTER_GRADIENT(ConvTranspose, GetConvTransposeGradient);
|
|
|
|
} // namespace caffe2
|