Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refine interface of hlir::framework::Instruction #56123

Merged
merged 2 commits into from
Aug 10, 2023
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
2 changes: 1 addition & 1 deletion paddle/cinn/hlir/framework/instruction.cc
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ void Instruction::Run(
// }
}

std::string Instruction::DumpInstruction() {
std::string Instruction::DumpInstruction() const {
std::stringstream ss;
ss << "Instruction {" << std::endl;
for (size_t i = 0; i < fn_names_.size(); ++i) {
Expand Down
12 changes: 8 additions & 4 deletions paddle/cinn/hlir/framework/instruction.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,17 @@ class Instruction {

int size() { return fn_ptrs_.size(); }

std::string DumpInstruction();
std::string DumpInstruction() const;

std::vector<std::vector<std::string>> GetInArgs() { return in_args_; }
std::vector<std::vector<std::string>> GetOutArgs() { return out_args_; }
const std::vector<std::vector<std::string>>& GetInArgs() const {
return in_args_;
}
const std::vector<std::vector<std::string>>& GetOutArgs() const {
return out_args_;
}
void ClearInArgs() { in_args_.clear(); }
void ClearOutArgs() { out_args_.clear(); }
std::vector<std::string> GetFnNames() { return fn_names_; }
const std::vector<std::string>& GetFnNames() const { return fn_names_; }
void AddInArgs(const std::vector<std::string>& in_args) {
in_args_.push_back(in_args);
}
Expand Down
6 changes: 3 additions & 3 deletions paddle/cinn/hlir/framework/program.cc
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,9 @@ void Program::Export(const std::vector<std::string>& persistent_vars,
int instplaceholder = writeplaceholder(4 * 3, insnum, f);
int findex = 0;
for (auto& ins : instrs_) {
auto in_args = ins->GetInArgs();
auto out_args = ins->GetOutArgs();
auto fn_names = ins->GetFnNames();
auto& in_args = ins->GetInArgs();
auto& out_args = ins->GetOutArgs();
auto& fn_names = ins->GetFnNames();
for (int i = 0; i < fn_names.size(); i++, findex++) {
std::vector<std::string> all_args(in_args[i].begin(), in_args[i].end());
all_args.insert(
Expand Down