From 12440509cc10092f79b81d76eba34c23b980d42b Mon Sep 17 00:00:00 2001 From: wanghaoshuang Date: Thu, 21 Sep 2017 09:55:30 +0800 Subject: [PATCH] Fix some inssues --- paddle/operators/clip_op.h | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/paddle/operators/clip_op.h b/paddle/operators/clip_op.h index 5ca32da41a..8ed05cb9e2 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)); -- GitLab