| 41 | const NameVarMap<egr::EagerVariable>& outs); |
| 42 | |
| 43 | static framework::VariableNameMap CreateVarNameMap( |
| 44 | const framework::OpInfo& op_info, |
| 45 | const std::string& op_type, |
| 46 | const NameVarBaseMap& varbase_map, |
| 47 | bool is_input) { |
| 48 | if (op_info.proto_ == nullptr) { |
| 49 | return {}; |
| 50 | } |
| 51 | |
| 52 | framework::VariableNameMap result; |
| 53 | |
| 54 | for (auto& var : |
| 55 | is_input ? op_info.Proto().inputs() : op_info.Proto().outputs()) { |
| 56 | auto it = varbase_map.find(var.name()); |
| 57 | if (it == varbase_map.end()) { |
| 58 | PADDLE_ENFORCE_EQ( |
| 59 | var.dispensable(), |
| 60 | true, |
| 61 | common::errors::NotFound("Variable %s is not dispensable and " |
| 62 | "there are no such var in inputs", |
| 63 | var.name())); |
| 64 | result[var.name()] = {}; |
| 65 | } else { |
| 66 | auto& var_vector = it->second; |
| 67 | std::vector<std::string> args; |
| 68 | args.reserve(var_vector.size()); |
| 69 | for (auto& var_base : var_vector) { |
| 70 | args.emplace_back(var_base->Name()); |
| 71 | } |
| 72 | result[var.name()] = std::move(args); |
| 73 | } |
| 74 | } |
| 75 | return result; |
| 76 | } |
| 77 | |
| 78 | using vb_vector = std::vector<std::shared_ptr<imperative::VarBase>>; |
| 79 | |