Skip to main content

//clika-runtime/io.clika.runtime/ClikaRt

ClikaRt

[common]
object ClikaRt

The entry of the binding: the runtime library and the bridge load at the first touch of this object, and load runs the one check every call depends on.

Loading order is the cross-language invariant: the runtime library loads FIRST (through NativeLibraries: the .so ships in an Android app's jniLibs, delivered by the runtime distribution, and on a desktop JVM sits on java.library.path or in a bridge jar), then the bridge, which binds to that already-loaded image. load then compares the version the bridge was built for (builtAgainst) with the version the loaded library answers (version) and refuses a mismatch before the first call. On Android, load through ClikaRtAndroid.load(context) instead, which also places the license credential and the cache root.

Four facts a first program meets. Every call that runs an operator needs the license credential: on a desktop JVM CLIKA_RT_LICENSE in the process environment (the CLIKA1-... text, or the path of a file holding it) or the per-user file clikart-license-init writes; on Android the license argument of ClikaRtAndroid.load; without one the first operator throws a ClikaRtException whose ClikaRtException.codeName is LICENSE_FAILED, and the code name, never the message text, is the thing to branch on. Operators are asynchronous: an Ops call returns before its work runs, and a read waits for the value (Tensor.item, Tensor.toFloatArray, Tensor.summary, Tensor.synchronize). The CPU worker count, CLIKA_RT_NUM_THREADS, is read at the first compute, so it is placed before any tensor exists. This binding is the inference API, not the authoring one: it runs what is ready (an ONNX model or a compiled graph, a tokenizer or a processor, the serving runtime, the readers) and carries a small operator set for an app's own tensors; a model written from the operators (a checkpoint loader, the module tree, a KV cache, the fused attention) is authored in C++ or Python and reaches an app as a served model or a graph. The model library's own loaders (AutoModel, GenerativeModel, the pipelines, the server) are the io.clika.modelverse package of the clika-modelverse artifact, which depends on this one and downloads a hub model inside its fromPretrained.

ClikaRt.load()
println("ClikaRT ${ClikaRt.version()}")

Properties​

NameSummary
builtAgainst[common]
val builtAgainst: String
The runtime version this binding was built for; load holds version to it.
isLoaded[common]
val isLoaded: Boolean
True once load has succeeded in this process.

Functions​

NameSummary
load[common]
fun load()
Check the loaded runtime library against the version this binding was built for; idempotent. Every other entry of the binding runs it first, so a mismatch surfaces at the first call wherever that is.
synchronizeAll[common]
fun synchronizeAll()
Wait for every stream in the runtime to finish: the barrier before a host read of a device result, or around a timed phase.
version[common]
fun version(): String
The loaded runtime library's version string (e.g. "0.6.0").