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

Function InitializeVariable

paddle/fluid/framework/variable_helper.cc:28–60  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

26namespace paddle::framework {
27
28void InitializeVariable(Variable *var, proto::VarType::Type var_type) {
29 if (var_type == proto::VarType::DENSE_TENSOR) {
30 var->GetMutable<DenseTensor>();
31 } else if (var_type == proto::VarType::SELECTED_ROWS) {
32 var->GetMutable<phi::SelectedRows>();
33 } else if (var_type == proto::VarType::FEED_MINIBATCH) {
34 var->GetMutable<FeedList>();
35 } else if (var_type == proto::VarType::FETCH_LIST) {
36 var->GetMutable<FetchList>();
37 } else if (var_type == proto::VarType::STEP_SCOPES) {
38 var->GetMutable<std::vector<framework::Scope *>>();
39 } else if (var_type == proto::VarType::DENSE_TENSOR_ARRAY) {
40 var->GetMutable<phi::TensorArray>();
41 } else if (var_type == proto::VarType::STRINGS) {
42 var->GetMutable<Strings>();
43 } else if (var_type == proto::VarType::VOCAB) {
44 var->GetMutable<Vocab>();
45 } else if (var_type == proto::VarType::PLACE_LIST) {
46 var->GetMutable<phi::PlaceList>();
47 } else if (var_type == proto::VarType::READER) {
48 var->GetMutable<ReaderHolder>();
49 } else if (var_type == proto::VarType::RAW) {
50 // GetMutable will be called in operator
51 } else if (var_type == proto::VarType::SPARSE_COO) {
52 var->GetMutable<phi::SparseCooTensor>();
53 } else {
54 PADDLE_THROW(common::errors::Unavailable(
55 "Variable type %d is not in "
56 "[DENSE_TENSOR, SELECTED_ROWS, FEED_MINIBATCH, FETCH_LIST, "
57 "LOD_RANK_TABLE, PLACE_LIST, READER, RAW].",
58 var_type));
59 }
60}
61
62void CopyVariable(const Variable &src_var, Variable *dst_var) {
63 // only support cpu now

Callers 13

CreateVariablesMethod · 0.70
CreateDeviceResourceMethod · 0.70
CopyParametersMethod · 0.70
CreatePinVarMethod · 0.70
CreateVariablesMethod · 0.70
InitTrainerEnvMethod · 0.70
CreateThreadScopeMethod · 0.70
LoadFromPaddleModelMethod · 0.50
ApplyImplMethod · 0.50
BuildVariableScopeFunction · 0.50
TransferLayoutFunction · 0.50
TransferDtypeFunction · 0.50

Calls

no outgoing calls

Tested by

no test coverage detected