diff --git a/paddle/operators/clip_op.h b/paddle/operators/clip_op.h index 5ca32da41ad85379d9358fa86ddd163d9906dde4..8ed05cb9e2fbb9dd6b1e0e5e4d9d360269b9d1f4 100644 --- a/paddle/operators/clip_op.h +++ b/paddle/operators/clip_op.h @@ -47,10 +47,7 @@ class ClipGradFunctor { public: explicit ClipGradFunctor(const T min, const T max) : min_(min), max_(max) {} HOSTDEVICE T operator()(const T& x, const T& y) const { - if (y > min_ && y < max_) - return x; - else - return 0; + return (y > min_ && y < max_) ? x : 0; } private: @@ -68,7 +65,7 @@ class ClipKernel : public framework::OpKernel { auto* out = context.Output("Out"); T* out_data = out->mutable_data(context.GetPlace()); const T* x_data = x->data(); - int numel = x->numel(); + int64_t numel = x->numel(); Transform trans; trans(context.device_context(), x_data, x_data + numel, out_data, ClipFunctor(min, max));