From 96604fda1016bd91c25ace7e7510f0a746ed3797 Mon Sep 17 00:00:00 2001 From: Qiao Longfei Date: Mon, 17 Dec 2018 16:59:20 +0800 Subject: [PATCH] fix gpu data test=develop --- paddle/fluid/operators/optimizers/adam_op.h | 3 ++- paddle/fluid/platform/for_range.h | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/paddle/fluid/operators/optimizers/adam_op.h b/paddle/fluid/operators/optimizers/adam_op.h index e8b977e2d..01d3d6005 100644 --- a/paddle/fluid/operators/optimizers/adam_op.h +++ b/paddle/fluid/operators/optimizers/adam_op.h @@ -361,9 +361,10 @@ class AdamOpKernel : public framework::OpKernel { if (lazy_mode) { std::vector id_vector; size_t row_count = grad_merge.rows().size(); + std::vector cpu_rows(grad_merge.rows()); for (size_t row_index = 0; row_index < row_count; ++row_index) { for (size_t offset = 0; offset < row_numel; ++offset) { - size_t i = rows[row_index] * row_numel + offset; + size_t i = cpu_rows[row_index] * row_numel + offset; id_vector.push_back(i); } } diff --git a/paddle/fluid/platform/for_range.h b/paddle/fluid/platform/for_range.h index a767bf929..ab00d8b8f 100644 --- a/paddle/fluid/platform/for_range.h +++ b/paddle/fluid/platform/for_range.h @@ -128,7 +128,7 @@ struct ForRangeIn { int grid_size = (range_.size() + num_threads - 1) / num_threads; ForRangeInElemwiseOp<<>>( - func, range_.data(), range_size); + func, range_.CUDAData(dev_ctx_.GetPlace()), range_size); } const CUDADeviceContext& dev_ctx_; -- GitLab