Skip to content

Commit

Permalink
Fix for wrong conditions between forward and backward in elementwise_…
Browse files Browse the repository at this point in the history
…add_grad op (#38176)
  • Loading branch information
arlesniak authored Dec 21, 2021
1 parent a4afb97 commit d9780a2
Showing 1 changed file with 1 addition and 10 deletions.
11 changes: 1 addition & 10 deletions paddle/fluid/operators/elementwise/elementwise_op.h
Original file line number Diff line number Diff line change
Expand Up @@ -319,16 +319,7 @@ class ElementwiseOpGrad : public framework::OperatorWithKernel {
ctx, framework::GradVarName("Out"));

#ifdef PADDLE_WITH_MKLDNN
// If broadcasting is needed, use native implementation
auto CanMKLDNNElementwiseGradBeUsed = [&]() {
auto dx_dims = ctx.Input<Tensor>("X")->dims();
auto dy_dims = ctx.Input<Tensor>("Y")->dims();
// No broadcast or broadcasting of data on inner dims is supported
return (dx_dims[dx_dims.size() - 1] == dy_dims[dy_dims.size() - 1]);
};

if (this->CanMKLDNNBeUsed(ctx, input_data_type) &&
CanMKLDNNElementwiseGradBeUsed()) {
if (this->CanMKLDNNBeUsed(ctx, input_data_type)) {
return framework::OpKernelType(input_data_type, ctx.GetPlace(),
framework::DataLayout::kMKLDNN,
framework::LibraryType::kMKLDNN);
Expand Down

0 comments on commit d9780a2

Please sign in to comment.