Skip to content

Commit 362794b

Browse files
committed
[NPU] set constant before copy data (PaddlePaddle#35335)
1 parent 7466524 commit 362794b

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

paddle/fluid/operators/coalesce_tensor_op.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,12 @@ class CoalesceTensorOpKernel : public framework::OpKernel<T> {
107107
auto out_tensors = context.MultiOutput<framework::LoDTensor>("Output");
108108
size_t offset = 0;
109109
if (context.Attr<bool>("copy_data")) {
110+
#ifdef PADDLE_WITH_ASCEND_CL
111+
framework::VisitDataType(
112+
dtype,
113+
FillConstantVisitor<DeviceContext>(
114+
dev_ctx, fused_tensor, static_cast<float>(0.0), dtype, context));
115+
#endif
110116
for (size_t i = 0; i < in_var_names.size(); ++i) {
111117
size_t len = static_cast<size_t>(in_tensors[i]->numel());
112118
auto sub_tensor = fused_tensor->Slice(

0 commit comments

Comments
 (0)