Device
classin packageklyn.math.nn
public class Device
Device

Immutable execution-device selector or concrete device. gpu/npu denote automatic selection within one category, not multi-device execution. Indices are stable within a process. NVIDIA requires only a compatible GPU and its driver; no CUDA Toolkit is required. NPU execution is reserved and currently raises ValueException when explicitly selected.

Example

model.to(Device.gpu[0]); print(model.device)

Properties
Modifier and Type Member Description
public static readonly property auto
auto as Device = Device(0, -1l, "auto")
Automatic selection according to operation support and estimated work.
public static readonly property cpu
cpu as Device = Device(1, -1l, "CPU")
CPU execution only.
public static readonly property gpu
gpu as Device = Device(2, -1l, "GPU")
Automatically chooses one supported GPU.
public readonly property index
index as Long
Concrete GPU ordinal, or -1 for CPU/automatic selectors.
public readonly property kind
kind as String
Category: auto, cpu, gpu or npu.
public readonly property name
name as String
Human-readable name, without exposing the backend ABI.
public static readonly property npu
npu as Device = Device(3, -1l, "NPU")
Reserved NPU selector; execution is not implemented yet.
Methods
Modifier and Type Member Description
public static list
list() as ArrayList<Device>
Lists the CPU and detected NVIDIA GPUs; CPU is always present.
public override toString
toString() as String
Returns the category, ordinal and device name.
Operators
Modifier and Type Member Description
public operator[](index as Long) as Device Selects a concrete device in the GPU/NPU category.