diff --git a/paddle/fluid/operators/optimizers/adam_op_npu.cc b/paddle/fluid/operators/optimizers/adam_op_npu.cc index d212ce5959291c5b75b8d24aa10d6dbd43bb2d8f..e2d262ff97db1dd3c9cd3d934364b11ce4dc9c47 100644 --- a/paddle/fluid/operators/optimizers/adam_op_npu.cc +++ b/paddle/fluid/operators/optimizers/adam_op_npu.cc @@ -68,12 +68,16 @@ class AdamNPUKernel : public framework::OpKernel { beta1_pow_out->mutable_data(ctx.GetPlace()); TensorFromVector(std::vector{beta1}, ctx.device_context(), beta1_pow_out); + } else { + beta1_pow_out->mutable_data(ctx.GetPlace()); } if (beta2_pow->place() == platform::CPUPlace()) { float beta2 = *beta2_pow->data(); beta2_pow_out->mutable_data(ctx.GetPlace()); TensorFromVector(std::vector{beta2}, ctx.device_context(), beta2_pow_out); + } else { + beta2_pow_out->mutable_data(ctx.GetPlace()); } T beta1 = static_cast(ctx.Attr("beta1"));