diff --git a/paddle/cinn/hlir/framework/instruction.cc b/paddle/cinn/hlir/framework/instruction.cc index 01fb89aa2ac0d8..09d644e8533abd 100644 --- a/paddle/cinn/hlir/framework/instruction.cc +++ b/paddle/cinn/hlir/framework/instruction.cc @@ -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) { diff --git a/paddle/cinn/hlir/framework/instruction.h b/paddle/cinn/hlir/framework/instruction.h index 23da5c532c4cd3..cc64c4e64bbe39 100644 --- a/paddle/cinn/hlir/framework/instruction.h +++ b/paddle/cinn/hlir/framework/instruction.h @@ -132,13 +132,17 @@ class Instruction { int size() { return fn_ptrs_.size(); } - std::string DumpInstruction(); + std::string DumpInstruction() const; - std::vector> GetInArgs() { return in_args_; } - std::vector> GetOutArgs() { return out_args_; } + const std::vector>& GetInArgs() const { + return in_args_; + } + const std::vector>& GetOutArgs() const { + return out_args_; + } void ClearInArgs() { in_args_.clear(); } void ClearOutArgs() { out_args_.clear(); } - std::vector GetFnNames() { return fn_names_; } + const std::vector& GetFnNames() const { return fn_names_; } void AddInArgs(const std::vector& in_args) { in_args_.push_back(in_args); } diff --git a/paddle/cinn/hlir/framework/program.cc b/paddle/cinn/hlir/framework/program.cc index 95799e05fcca6f..eadbfdf4d7d2c8 100644 --- a/paddle/cinn/hlir/framework/program.cc +++ b/paddle/cinn/hlir/framework/program.cc @@ -140,9 +140,9 @@ void Program::Export(const std::vector& 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 all_args(in_args[i].begin(), in_args[i].end()); all_args.insert(