| 54 | } |
| 55 | |
| 56 | std::unique_ptr<framework::proto::ProgramDesc> LoadProgram( |
| 57 | const std::string &path, const lite_api::CxxModelBuffer &model_buffer) { |
| 58 | std::unique_ptr<framework::proto::ProgramDesc> main_program( |
| 59 | new framework::proto::ProgramDesc); |
| 60 | if (model_buffer.is_empty()) { |
| 61 | model_parser::BinaryFileReader file(path); |
| 62 | main_program->ParseFromString(file.ReadToString(file.length())); |
| 63 | } else { |
| 64 | main_program->ParseFromString(model_buffer.get_program()); |
| 65 | } |
| 66 | return main_program; |
| 67 | } |
| 68 | |
| 69 | // Load directly to CPU, and latter transfer to other devices. |
| 70 | void LoadParam(const std::string &path, Variable *out) { |