types.backends.validate_device

types.backends.validate_device(device, backend)

Validate device for given backend.

Parameters

Name Type Description Default
device str Device identifier required
backend Backend Backend being used required

Returns

Name Type Description
Device Validated device

Raises

Name Type Description
ValueError If device incompatible with backend

Examples

>>> validate_device('cuda', 'torch')
'cuda'
>>> validate_device('cuda', 'numpy')  # ValueError - NumPy is CPU-only