diff --git a/paddle/fluid/operators/interpolate_op.cu b/paddle/fluid/operators/interpolate_op.cu index f86d2c4ab4e4d3aaa28a37f9d53d9a1224166581..b887878ea2291d6c56fec91738784e338606b84f 100644 --- a/paddle/fluid/operators/interpolate_op.cu +++ b/paddle/fluid/operators/interpolate_op.cu @@ -227,9 +227,8 @@ class InterpolateOpCUDAKernel : public framework::OpKernel { : static_cast(in_h) / out_h; } if (out_w > 1) { - ratio_w = (align_corners && out_w > 1) - ? static_cast(in_w - 1) / (out_w - 1) - : static_cast(in_w) / out_w; + ratio_w = (align_corners) ? static_cast(in_w - 1) / (out_w - 1) + : static_cast(in_w) / out_w; } if (in_h == out_h && in_w == out_w) { @@ -302,9 +301,8 @@ class InterpolateGradOpCUDAKernel : public framework::OpKernel { : static_cast(in_h) / out_h; } if (out_w > 1) { - ratio_w = (align_corners && out_w > 1) - ? static_cast(in_w - 1) / (out_w - 1) - : static_cast(in_w) / out_w; + ratio_w = (align_corners) ? static_cast(in_w - 1) / (out_w - 1) + : static_cast(in_w) / out_w; } if (in_h == out_h && in_w == out_w) { diff --git a/paddle/fluid/operators/interpolate_op.h b/paddle/fluid/operators/interpolate_op.h index acdebf73e0db917c688f5b38f9b76bfc420330f0..c631ad1dd158ce114169602f073d69b2291b5b3b 100644 --- a/paddle/fluid/operators/interpolate_op.h +++ b/paddle/fluid/operators/interpolate_op.h @@ -199,9 +199,8 @@ class InterpolateKernel : public framework::OpKernel { : static_cast(in_h) / out_h; } if (out_w > 1) { - ratio_w = (align_corners && out_w > 1) - ? static_cast(in_w - 1) / (out_w - 1) - : static_cast(in_w) / out_w; + ratio_w = (align_corners) ? static_cast(in_w - 1) / (out_w - 1) + : static_cast(in_w) / out_w; } if ("bilinear" == interp_method) { @@ -258,9 +257,8 @@ class InterpolateGradKernel : public framework::OpKernel { : static_cast(in_h) / out_h; } if (out_w > 1) { - ratio_w = (align_corners && out_w > 1) - ? static_cast(in_w - 1) / (out_w - 1) - : static_cast(in_w) / out_w; + ratio_w = (align_corners) ? static_cast(in_w - 1) / (out_w - 1) + : static_cast(in_w) / out_w; } if ("bilinear" == interp_method) {