| 393 | } |
| 394 | |
| 395 | of::Maybe<void> Graph::GraphImpl::LoadCheckpoint() { |
| 396 | for (const auto& variable_op_name_and_tensor : variable_op_name_to_tensor_) { |
| 397 | const auto& variable_op_name = variable_op_name_and_tensor.first; |
| 398 | const auto& variable_tensor = variable_op_name_and_tensor.second; |
| 399 | const std::string variable_filename = model_path_ + "/" + variable_op_name + "/out"; |
| 400 | const std::string buffer = [&]() { |
| 401 | std::ifstream variable_file(variable_filename, std::ios::binary); |
| 402 | CHECK(variable_file.is_open()); |
| 403 | std::stringstream ss; |
| 404 | ss << variable_file.rdbuf(); |
| 405 | return ss.str(); |
| 406 | }(); |
| 407 | const auto& callback = [&](of::ep::Stream* stream, |
| 408 | const std::shared_ptr<of::vm::EagerBlobObject>& eager_blob_object) { |
| 409 | of::AutoMemcpy(stream, eager_blob_object->mut_dptr(), buffer.data(), |
| 410 | variable_tensor->shape()->elem_cnt() |
| 411 | * of::GetSizeOfDataType(variable_tensor->dtype()->data_type()), |
| 412 | eager_blob_object->mem_case(), of::memory::MakeHostMemCase()); |
| 413 | }; |
| 414 | JUST(of::one::SyncAccessTensorWithTimeOut(variable_tensor, callback, "mut")); |
| 415 | } |
| 416 | const auto& pair = Unzip(variable_op_name_to_tensor_); |
| 417 | JUST(of::FillVariableTensorMgr(pair.first, pair.second)); |
| 418 | return of::Maybe<void>::Ok(); |
| 419 | } |
| 420 | |
| 421 | of::Maybe<void> Graph::GraphImpl::RegisterTensors(const std::vector<Tensor>& inputs) { |
| 422 | { |
nothing calls this directly
no test coverage detected