From 9bc1e0a15657123959e9355ad063a3577aaefdee Mon Sep 17 00:00:00 2001 From: Zhang Ting <709968123@qq.com> Date: Sat, 11 Apr 2020 14:13:36 +0800 Subject: [PATCH] fix the CI random failure for dist op (#23743) --- paddle/fluid/operators/dist_op.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/paddle/fluid/operators/dist_op.h b/paddle/fluid/operators/dist_op.h index b35b4ce1d2..ca03400cfd 100644 --- a/paddle/fluid/operators/dist_op.h +++ b/paddle/fluid/operators/dist_op.h @@ -19,6 +19,7 @@ #include #include "paddle/fluid/framework/eigen.h" #include "paddle/fluid/framework/op_registry.h" +#include "paddle/fluid/operators/math/math_function.h" namespace paddle { namespace operators { @@ -169,7 +170,9 @@ static void DistGradFunction(const framework::ExecutionContext& context) { // 1: Lp-norm(z), z = x-y, compute dz if (p == 0) { - grad_t.device(place) = grad_t * static_cast(0); + math::SetConstant set_zero; + auto& dev_ctx = context.template device_context(); + set_zero(dev_ctx, &grad, static_cast(0)); } else if (p == INFINITY || p == -INFINITY) { // p=inf or -inf, Lp-norm = |z_i|, the j-th element of dz tends to 0 if // j!=i, or equals to sign(z_i) * dout if j=i. -- GitLab