| 378 | void TFE_DeleteContextOptions(TFE_ContextOptions* options) { delete options; } |
| 379 | |
| 380 | TFE_Context* TFE_NewContext(const TFE_ContextOptions* opts, TF_Status* status) { |
| 381 | std::vector<std::unique_ptr<tensorflow::Device>> devices; |
| 382 | status->status = tensorflow::DeviceFactory::AddDevices( |
| 383 | opts->session_options.options, "/job:localhost/replica:0/task:0", |
| 384 | &devices); |
| 385 | if (!status->status.ok()) return nullptr; |
| 386 | std::unique_ptr<tensorflow::DeviceMgr> device_mgr( |
| 387 | new tensorflow::DeviceMgr(std::move(devices))); |
| 388 | |
| 389 | tensorflow::Rendezvous* r = |
| 390 | new tensorflow::IntraProcessRendezvous(device_mgr.get()); |
| 391 | |
| 392 | return new TFE_Context(opts->session_options.options, |
| 393 | opts->device_placement_policy, opts->mirroring_policy, |
| 394 | opts->async, device_mgr.release(), |
| 395 | /*device_mgr_owned*/ true, r, |
| 396 | tensorflow::GetDefaultCustomKernelCreator()); |
| 397 | } |
| 398 | |
| 399 | TFE_Context* TFE_NewContextFromSession(const TFE_ContextOptions* opts, |
| 400 | TF_Session* sess, TF_Status* status) { |