MCPcopy Create free account
hub / github.com/PaddlePaddle/Paddle / CreateVarNameMap

Function CreateVarNameMap

test/cpp/imperative/test_prepare_op.cc:43–76  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

41 const NameVarMap<egr::EagerVariable>& outs);
42
43static 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
78using vb_vector = std::vector<std::shared_ptr<imperative::VarBase>>;
79

Callers 2

TESTFunction · 0.85
TestPrepareDataSamePlaceFunction · 0.85

Calls 10

inputsMethod · 0.45
ProtoMethod · 0.45
outputsMethod · 0.45
findMethod · 0.45
nameMethod · 0.45
endMethod · 0.45
reserveMethod · 0.45
sizeMethod · 0.45
emplace_backMethod · 0.45
NameMethod · 0.45

Tested by

no test coverage detected