From fe3995d33527e8503739b6de3dd555fa3ad35073 Mon Sep 17 00:00:00 2001 From: Qiao Longfei Date: Tue, 18 Dec 2018 07:15:42 +0800 Subject: [PATCH] refine code test=develop --- paddle/fluid/operators/optimizers/adam_op.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/paddle/fluid/operators/optimizers/adam_op.h b/paddle/fluid/operators/optimizers/adam_op.h index 4f212bb69a..f214d8272f 100644 --- a/paddle/fluid/operators/optimizers/adam_op.h +++ b/paddle/fluid/operators/optimizers/adam_op.h @@ -227,7 +227,9 @@ struct SparseAdamFunctor { inline HOSTDEVICE void operator()(size_t i) const { auto row_idx = math::BinarySearch(rows_, row_count_, i / row_numel_); - if (!(lazy_mode_ && row_idx < 0)) { + if (lazy_mode_ && row_idx < 0) { + return; + } else { T g = row_idx >= 0 ? grad_[row_idx * row_numel_ + i % row_numel_] : 0; adam_update(i, g); } -- GitLab