device¶
- class tripy.device(device: str)[source]¶
Bases:
object
Represents the device where a tensor will be allocated.
- Parameters:
device (str) – A string consisting of the device kind and an optional index. The device kind may be one of:
["cpu", "gpu"]
. If the index is provided, it should be separated from the device kind by a colon (:
). If the index is not provided, it defaults to 0.
Example: Default CPU
1cpu = tp.device("cpu")
>>> cpu cpu:0
Example: Second GPU
1gpu_1 = tp.device("gpu:1")
>>> gpu_1 gpu:1