static*/
| 477 | } |
| 478 | |
| 479 | /*static*/ xla::StatusOr<std::shared_ptr<XrtContext>> XrtContext::Create( |
| 480 | std::shared_ptr<XrtTfContext> tf_context, string device_type) { |
| 481 | auto context = std::make_shared<XrtContext>(tf_context, device_type); |
| 482 | if (context->tf_device_ids().empty()) { |
| 483 | return errors::NotFound("No accelerator devices of type ", device_type, |
| 484 | " are present."); |
| 485 | } |
| 486 | if (device_type == "TPU") { |
| 487 | TF_RETURN_IF_ERROR(context->InitializeTPU()); |
| 488 | } else { |
| 489 | // Fill in a dummy topology mapping for CPU/GPU. |
| 490 | for (int i = 0; i < context->tf_device_ids().size(); ++i) { |
| 491 | context->device_mesh_coordinates_.push_back({}); |
| 492 | context->device_mesh_coordinates_.back().add_value(i); |
| 493 | } |
| 494 | } |
| 495 | return context; |
| 496 | } |
| 497 | |
| 498 | XrtContext::XrtContext(std::shared_ptr<XrtTfContext> tf_context, |
| 499 | string device_type) |