Skip to main content

Rust API

Safe Rust API for the ClikaRT on-device inference runtime, over the versioned C core ABI.

Api::load opens the runtime shared library at run time and performs the two-arm handshake, the cross-language load-time invariant: the abi version first (clika_rt_get_api answers NULL for a version the runtime cannot serve), then the api-table layout fingerprint (the served table's fingerprint must equal the C header this crate compiled against and LAYOUT_FINGERPRINT, the value the generated surface was emitted from). Either refusal is a readable error before the first call. Runtime failures map to Error carrying the machine-readable code_name (which survives release obfuscation; branch on it, never on the message text).

The surface, by layer:

  • generated: one wrapper per api-table member: the f_<member> Result primaries, their panicking twins, the Tensor operator methods, and the <Op>Options structs (re-exported at the root).
  • ops: +, -, *, /, unary - over tensors and scalars.
  • index: subscripting: x.i((.., 0, 1..3)).
  • nn: Module, Linear, Sequential, and VarBuilder dotted-key weight loading.
  • data: typed slice entry (Element, the F16 / BF16 bit carriers).
  • onnx: builders for the graph-authoring dimension / attribute values.

This crate is the ONLY consumer of clika-rt-sys (the raw, bindgen-generated FFI, re-exported as sys for constants such as the dtype values); dependent crates use this crate and never the raw FFI.

NameKind
Apistruct
Errorstruct
Tensorstruct
datamodule
generatedmodule
indexmodule
nnmodule
onnxmodule
opsmodule