Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions paddle/fluid/operators/npu_op_runner.cc
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,21 @@ NpuOpRunner &NpuOpRunner::AddInputs(const std::vector<Tensor> &tensors) {
return *this;
}

// NOTE(zhiqiu): For operators whose input is a list (such as concat, stack),
// It is needed to set the name of each input tensor.
NpuOpRunner &NpuOpRunner::AddInputNames(const std::vector<std::string> &names) {
PADDLE_ENFORCE_EQ(names.size(), input_descs_.size(),
platform::errors::InvalidArgument(
"The size of input names should be "
"equal to the size of input descs, but got the size "
"of input names is %d, the size of input descs is %d.",
names.size(), input_descs_.size()));
for (size_t i = 0; i < names.size(); ++i) {
aclSetTensorDescName(input_descs_[i], names[i].c_str());
}
return *this;
}

NpuOpRunner &NpuOpRunner::AddOutputs(const std::vector<Tensor> &tensors) {
for (auto tensor : tensors) {
// create aclTensorDesc
Expand Down
2 changes: 2 additions & 0 deletions paddle/fluid/operators/npu_op_runner.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ class NpuOpRunner {

NpuOpRunner &AddInputs(const std::vector<Tensor> &tensors);

NpuOpRunner &AddInputNames(const std::vector<std::string> &names);

NpuOpRunner &AddOutputs(const std::vector<Tensor> &tensors);

aclTensorDesc *GetInputDesc(size_t index);
Expand Down