//clika-runtime/io.clika.runtime/Device
Device
[common]
data class Device(val api: ComputeApi, val index: Int) : Placement
A compute device: a backend api plus a device index. An accelerator index is zero-based and names one physical device; a CPU index names a SOCKET, with the whole machine at WHOLE_MACHINE, so CPU uses every core and Device.cpu(0) confines work to socket 0.
val cpu = Device.CPU
val gpu0 = Device.parse("cuda:0")
val t = Tensors.zeros(longArrayOf(2, 3), where = gpu0)
Constructors
| Device | [common] constructor(api: ComputeApi) A backend's default device: the whole machine on CPU, device 0 elsewhere. constructor(api: ComputeApi, index: Int) |
Types
| Name | Summary |
|---|---|
| Companion | [common] object Companion |
Properties
| Name | Summary |
|---|---|
| api | [common] val api: ComputeApi |
| index | [common] val index: Int |
Functions
| Name | Summary |
|---|---|
| currentSeed | [common] fun currentSeed(): Long The current seed of this device's generator (0 until seeded). |
| manualSeed | [common] fun manualSeed(seed: Long) Seed this device's random-number generator, so later random ops reproduce. |
| memoryStats | [common] fun memoryStats(): MemoryStats A point-in-time snapshot of this device's memory: the physical figures and the runtime pool's counters. |
| properties | [common] fun properties(): DeviceProperties The static capabilities of this device: its name, kind, driver and runtime versions, compute geometry, memory and the dtypes the hardware accelerates. |
| releaseCachedMemory | [common] fun releaseCachedMemory() Return the runtime pool's idle memory for this device to the driver or the OS. Memory still in use is never touched. A closed model's bytes stay in the pool until this call or memory pressure; the Modelverse binding calls it at a model's close, and a program that closes a model of its own and loads another calls it in between. |
| resetPeakMemoryStats | [common] fun resetPeakMemoryStats() Restart the pool's high-water marks from the present occupancy; the measuring idiom's first step. |
| synchronize | [common] fun synchronize() Wait for every operation queued on this device's lanes. |
| toString | [common] open override fun toString(): String |