Skip to content

declearn.utils.get_device_policy

Return a copy of the current global device policy.

This method is meant to be used:

  • By end-users that wish to check the current device policy.
  • By the backend code of framework-specific objects so as to take the required steps towards implementing that policy.

To update the current policy, use declearn.utils.set_device_policy.

Returns:

Name Type Description
policy DevicePolicy

DevicePolicy dataclass instance, wrapping parameters that specify the device policy to be enforced by Model and Vector to properly place data and computations.

Source code in declearn/utils/_device_policy.py
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
def get_device_policy() -> DevicePolicy:
    """Return a copy of the current global device policy.

    This method is meant to be used:

    - By end-users that wish to check the current device policy.
    - By the backend code of framework-specific objects so as to
      take the required steps towards implementing that policy.

    To update the current policy, use `declearn.utils.set_device_policy`.

    Returns
    -------
    policy: DevicePolicy
        DevicePolicy dataclass instance, wrapping parameters that specify
        the device policy to be enforced by Model and Vector to properly
        place data and computations.
    """
    return DevicePolicy(**dataclasses.asdict(DEVICE_POLICY))