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

Function SetFeedVariable

paddle/fluid/framework/feed_fetch_method.cc:46–76  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

44}
45
46void SetFeedVariable(Scope* scope,
47 const DenseTensor& input,
48 const std::string& var_name,
49 size_t index) {
50 // If var_name Variable is not found in GlobalScope, a new variable will
51 // be created.
52 VLOG(3) << "SetFeedVariable name=" << var_name << " index=" << index;
53 if (FLAGS_enable_pir_in_executor) {
54 // shared data with input tensor
55 auto feed_ele = scope->Var(var_name);
56 if (!feed_ele->IsType<DenseTensor>()) {
57 VLOG(3) << "Reset " << var_name << " to DenseTensor";
58 feed_ele->Clear();
59 }
60 auto val = feed_ele->GetMutable<DenseTensor>();
61 val->ShareDataWith(input);
62 // set lod
63 val->set_lod(input.lod());
64 } else {
65 Variable* g_feed_value = scope->Var(var_name);
66 auto& feed_inputs = *(g_feed_value->GetMutable<FeedList>());
67 if (index >= feed_inputs.size()) {
68 feed_inputs.resize(index + 1);
69 }
70 // shared data with input tensor
71 auto& val = feed_inputs[index];
72 val.ShareDataWith(input);
73 // set lod
74 val.set_lod(input.lod());
75 }
76}
77
78FetchType& GetFetchVariable(const Scope& scope,
79 const std::string& var_name,

Callers 2

RunPreparedContextMethod · 0.85
SetFeedMethod · 0.85

Calls 6

VarMethod · 0.45
ClearMethod · 0.45
set_lodMethod · 0.45
lodMethod · 0.45
sizeMethod · 0.45
resizeMethod · 0.45

Tested by

no test coverage detected