| 26 | namespace paddle::framework { |
| 27 | |
| 28 | void 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 | |
| 62 | void CopyVariable(const Variable &src_var, Variable *dst_var) { |
| 63 | // only support cpu now |
no outgoing calls
no test coverage detected