Skip to content

Commit

Permalink
[NPU] set constant before copy data (#35335)
Browse files Browse the repository at this point in the history
  • Loading branch information
FeixLiu authored Sep 1, 2021
1 parent c56d697 commit bee511d
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions paddle/fluid/operators/coalesce_tensor_op.cc
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,12 @@ class CoalesceTensorOpKernel : public framework::OpKernel<T> {
auto out_tensors = context.MultiOutput<framework::LoDTensor>("Output");
size_t offset = 0;
if (context.Attr<bool>("copy_data")) {
#ifdef PADDLE_WITH_ASCEND_CL
framework::VisitDataType(
dtype,
FillConstantVisitor<DeviceContext>(
dev_ctx, fused_tensor, static_cast<float>(0.0), dtype, context));
#endif
for (size_t i = 0; i < in_var_names.size(); ++i) {
size_t len = static_cast<size_t>(in_tensors[i]->numel());
auto sub_tensor = fused_tensor->Slice(
Expand Down

0 comments on commit bee511d

Please sign in to comment.