From 5e4b419b98225f9aa9c971a7b05205174c6ac34e Mon Sep 17 00:00:00 2001 From: Leo Chen Date: Wed, 17 Nov 2021 12:58:02 +0800 Subject: [PATCH] copy beta pow to same place when skip_update=1 (#37245) * copy beta pow to same place when skip_update=1 * fix xpu --- paddle/fluid/operators/optimizers/adam_op.cu | 4 ++-- paddle/fluid/operators/optimizers/adam_op_npu.cc | 4 ++-- paddle/fluid/operators/optimizers/adam_op_xpu.cc | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/paddle/fluid/operators/optimizers/adam_op.cu b/paddle/fluid/operators/optimizers/adam_op.cu index 5c30962cca8..57231e1135a 100644 --- a/paddle/fluid/operators/optimizers/adam_op.cu +++ b/paddle/fluid/operators/optimizers/adam_op.cu @@ -198,11 +198,11 @@ class AdamOpCUDAKernel : public framework::OpKernel { *mom2, ctx.GetPlace(), ctx.template device_context(), mom2_out); framework::TensorCopy( - *beta1_pow, ctx.GetPlace(), + *beta1_pow, beta1_pow->place(), ctx.template device_context(), beta1_pow_out); framework::TensorCopy( - *beta2_pow, ctx.GetPlace(), + *beta2_pow, beta2_pow->place(), ctx.template device_context(), beta2_pow_out); return; diff --git a/paddle/fluid/operators/optimizers/adam_op_npu.cc b/paddle/fluid/operators/optimizers/adam_op_npu.cc index 1169bc12ac2..91bb9d48bc7 100644 --- a/paddle/fluid/operators/optimizers/adam_op_npu.cc +++ b/paddle/fluid/operators/optimizers/adam_op_npu.cc @@ -84,11 +84,11 @@ class AdamNPUKernel : public framework::OpKernel { *mom2, ctx.GetPlace(), ctx.template device_context(), mom2_out); framework::TensorCopy( - *beta1_pow, ctx.GetPlace(), + *beta1_pow, beta1_pow->place(), ctx.template device_context(), beta1_pow_out); framework::TensorCopy( - *beta2_pow, ctx.GetPlace(), + *beta2_pow, beta2_pow->place(), ctx.template device_context(), beta2_pow_out); return; diff --git a/paddle/fluid/operators/optimizers/adam_op_xpu.cc b/paddle/fluid/operators/optimizers/adam_op_xpu.cc index 318a8f14930..cb06b06824b 100644 --- a/paddle/fluid/operators/optimizers/adam_op_xpu.cc +++ b/paddle/fluid/operators/optimizers/adam_op_xpu.cc @@ -86,11 +86,11 @@ class AdamOpXPUKernel : public framework::OpKernel { mom2, ctx.GetPlace(), ctx.template device_context(), &mom2_out); framework::TensorCopy( - beta1_pow, ctx.GetPlace(), + beta1_pow, beta1_pow.place(), ctx.template device_context(), beta1_pow_out); framework::TensorCopy( - beta2_pow, ctx.GetPlace(), + beta2_pow, beta2_pow.place(), ctx.template device_context(), beta2_pow_out); return; -- GitLab