Skip to content

Commit

Permalink
Fix CPU implementation of roi_align_op backward (PaddlePaddle#18728)
Browse files Browse the repository at this point in the history
  • Loading branch information
qingqing01 committed Jul 23, 2019
1 parent b9eae52 commit cf846b8
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions paddle/fluid/operators/roi_align_op.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ class CPUROIAlignOpKernel : public framework::OpKernel<T> {
int width = in_dims[3];
int rois_num = rois->dims()[0];

if (rois_num == 0) return;

auto in_stride = framework::stride(in_dims);
auto roi_stride = framework::stride(rois->dims());
auto out_stride = framework::stride(out->dims());
Expand Down Expand Up @@ -278,6 +280,10 @@ class CPUROIAlignGradOpKernel : public framework::OpKernel<T> {
const T* out_grad_data = out_grad->data<T>();
T* in_grad_data = in_grad->mutable_data<T>(ctx.GetPlace());

auto& dev_ctx = ctx.template device_context<DeviceContext>();
math::SetConstant<DeviceContext, T> set_zero;
set_zero(dev_ctx, in_grad, static_cast<T>(0));

auto in_stride = framework::stride(in->dims());
auto roi_stride = framework::stride(rois->dims());
auto out_stride = framework::stride(out_grad->dims());
Expand Down

0 comments on commit cf846b8

Please sign in to comment.