Return explicit device of current context, otherwise returns `None`. Returns: If the current device scope is explicitly set, it returns a string with the device (`CPU` or `GPU`). If the scope is not explicitly set, it will return `None`.
()
| 583 | |
| 584 | |
| 585 | def _get_current_tf_device(): |
| 586 | """Return explicit device of current context, otherwise returns `None`. |
| 587 | |
| 588 | Returns: |
| 589 | If the current device scope is explicitly set, it returns a string with |
| 590 | the device (`CPU` or `GPU`). If the scope is not explicitly set, it will |
| 591 | return `None`. |
| 592 | """ |
| 593 | graph = get_graph() |
| 594 | op = _TfDeviceCaptureOp() |
| 595 | graph._apply_device_functions(op) |
| 596 | return tfdev.DeviceSpec.from_string(op.device) |
| 597 | |
| 598 | |
| 599 | def _is_current_explicit_device(device_type): |
no test coverage detected