| 342 | } |
| 343 | |
| 344 | Status SingleMachine::ResetSession() { |
| 345 | if (session_) { |
| 346 | LOG(INFO) << "Cleaning up previous session"; |
| 347 | |
| 348 | // Make sure the session is properly closed |
| 349 | TF_RETURN_IF_ERROR(ShutdownSession()); |
| 350 | |
| 351 | // Destroying the object deletes all its variables as well. This is only |
| 352 | // true for DirectSession. |
| 353 | session_.reset(); |
| 354 | } |
| 355 | |
| 356 | LOG(INFO) << "Starting new session"; |
| 357 | |
| 358 | // Create a new threadpool |
| 359 | thread_pool_.reset(new thread::ThreadPool( |
| 360 | Env::Default(), SanitizeThreadSuffix("single_machine"), 2)); |
| 361 | |
| 362 | session_.reset(NewSession(options_)); |
| 363 | if (!session_) { |
| 364 | return errors::Unknown("Failed to create session"); |
| 365 | } |
| 366 | coordinator_.reset(new Coordinator()); |
| 367 | |
| 368 | // Build the DeviceSet. |
| 369 | device_set_.reset(new DeviceSet); |
| 370 | const DeviceMgr* device_mgr; |
| 371 | TF_RETURN_IF_ERROR(session_->LocalDeviceManager(&device_mgr)); |
| 372 | for (auto d : device_mgr->ListDevices()) { |
| 373 | device_set_->AddDevice(d); |
| 374 | // We currently don't care about the client device. |
| 375 | } |
| 376 | |
| 377 | return Status::OK(); |
| 378 | } |
| 379 | |
| 380 | void SingleMachine::MergeCosts(CostGraphDef* graph_costs, |
| 381 | const CostGraphDef& init_costs, |
nothing calls this directly
no test coverage detected