Check if the current device is explicitly set on the device type specified. Arguments: device_type: A string containing `GPU` or `CPU` (case-insensitive). Returns: A boolean indicating if the current device scope is explicitly set on the device type. Raises: ValueErr
(device_type)
| 597 | |
| 598 | |
| 599 | def _is_current_explicit_device(device_type): |
| 600 | """Check if the current device is explicitly set on the device type specified. |
| 601 | |
| 602 | Arguments: |
| 603 | device_type: A string containing `GPU` or `CPU` (case-insensitive). |
| 604 | |
| 605 | Returns: |
| 606 | A boolean indicating if the current device scope is explicitly set on the |
| 607 | device type. |
| 608 | |
| 609 | Raises: |
| 610 | ValueError: If the `device_type` string indicates an unsupported device. |
| 611 | """ |
| 612 | device_type = device_type.upper() |
| 613 | if device_type not in ['CPU', 'GPU']: |
| 614 | raise ValueError('`device_type` should be either "CPU" or "GPU".') |
| 615 | device = _get_current_tf_device() |
| 616 | return device is not None and device.device_type == device_type.upper() |
| 617 | |
| 618 | |
| 619 | def _get_available_gpus(): |
no test coverage detected