Skip to main content

Additional examples

Two sets of example programs ship with a release, and both are downloads of the platform (Get ClikaRT). The release archive for a desktop platform carries the runtime's own examples under examples/src: each is a standalone find_package(ClikaRT CONFIG) project on the public API only, each builds its topic up one chapter at a time, starting at 00_hello_world, and every example directory has its own README.md walk-through; this page catalogs that set first. The examples archive, ClikaRT-<version>-examples.tar.xz, is the other: complete programs in C++, Python and Kotlin, three Android apps and a voice translator, each beside its recorded output, under one examples/ directory whose README.md and AGENTS.md index them.

The runtime's own examples, inside the archive​

Read roughly top to bottom; each row assumes a little of the ones above it.

ExampleWhat it showsChapters
versionThe smallest consumer: link the bundle, print GetVersionInfo()00_hello_world
computeThe tensor/op engine: tensors and dtypes, device properties, data movement, the ops:: library, the async model, zero-copy .to(device), hardware probes, a distributed matmul, the profiler, cast chains00_hello_world · 01_tensors · 02_devices · 03_data_movement · 04_operators · 05_async · 06_zero_copy · 07_hardware · 08_distributed_matmul · 09_profiler · 10_cast_chain
asyncThe async execution model in depth: dispatch vs ready, safe host reads, on_complete, the synchronous scope, tracing00_dispatch_vs_ready · 01_safe_reads · 02_on_complete · 03_sync_scope · 04_tracing_scope
runtimeThe serving runtime: nodes and phases, per-session state, continuous batching, pipelines, vision models, the interface layer, a two-stage model, an encoder with a stateful decoder00_functional_api · 01_model_api · 02_stateful_functional_api · 03_stateful_model_api · 04_pipeline · 05_simple_vision_model · 06_interface · 07_two_stage_vision_model · 08_encoder_and_stateful_decoder
nnNeural-network modules: make with plain counts, bind weights, forward; Linear, Conv, and a KV cache bound straight into the attention op00_linear · 01_conv · 02_attention_kvcache
processorImage and audio pre-processing: resize, rescale and normalize a generated image; log-mel features from a synthesized waveform00_image · 01_audio
jsonA small JSON value for payloads: parse, typed getters, build with operator[], dump round trip00_hello_world
errorsThe failure vocabulary: unwrap, CLIKART_TRY capture, CLIKART_TRY_OR_RETURN propagation, and code_name(), the stable machine-readable failure name00_result
cliTyped argument parsing: options and flags, subcommands, validators, shell completion00_hello_world · 01_args · 02_subcommands · 03_completion
loggingStructured logging: levels, the level filter, named subsystem loggers00_hello_world · 01_levels · 02_named
progressTerminal progress: bars (bytes, ETA, rate), spinners, multi-bar groups00_hello_world · 01_bytes_eta_rate · 02_spinner · 03_group
templatingJinja2-compatible rendering: variables, logic, filters, chat prompts00_hello_world · 01_logic · 02_filters · 03_chat_prompts
tokenizerText to token ids and back: HF tokenizer.json, byte offsets, batching and vocab, chat templates00_hello_world · 01_offsets · 02_batch_and_vocab · 03_huggingface
tablesA columnar dataframe: CSV, dtypes, select/filter/sort, group-by/join, transforms, GPU acceleration, a row cursor00_hello_world · 01_columns_and_dtypes · 02_csv · 03_select_filter_sort · 04_groupby_join · 05_transform · 06_acceleration · 07_rows
tables_benchmarkThe pandas-vs-ClikaRT performance sibling of tablesone standalone project
ioLoading data and weights: NumPy .npy, safetensors, GGUF, images, and the ONNX model stack (guide)00_hello_world · 01_safetensors · 02_gguf · 03_image · 04_onnx
http_serverAn HTTP service: routing, JSON APIs, middleware, a templated site, SSE streaming, an image-upload endpoint that runs compute00_hello_world · 01_routing · 02_json_api · 03_middleware · 04_serve_a_website · 05_sse · 06_image_compute
downloadA download tool combining CLI, progress bar and HTTP client00_hello_world · 01_multi_file
flash_attentionA hand-written CUDA kernel on ClikaRT streams: upstream Flash Attention ported, not rewritten, dispatched through the custom-op interfaceone project (main.cpp + the ported kernel)

Build and run​

cmake -S "$CLIKART_BUNDLE_DIR/examples/src/compute" -B build-compute \
-DClikaRT_DIR="$CLIKART_BUNDLE_DIR/cmake"
cmake --build build-compute
./build-compute/compute_00_hello_world

Or build them all at once from the top-level project: cmake -S "$CLIKART_BUNDLE_DIR/examples/src" -B build -DClikaRT_DIR="$CLIKART_BUNDLE_DIR/cmake". The top-level project adapts to the distribution it is built against; it skips an example the distribution cannot build rather than failing.

On platforms where the archive carries pre-built example binaries (examples/bin), run them in place; they find the libraries through a relative rpath, with no library paths to set.

The examples archive​

ClikaRT-<version>-examples.tar.xz extracts to one examples/ directory. Every program in it runs on its own against a release, and every tutorial and how-to program sits beside its recorded output (.out), the text the release printed when the recording was made. examples/README.md is the front door, one table per language; examples/AGENTS.md is the index written for a reader or an AI assistant: the facts a first run needs, a task table, the commands, the download call in each language, and what each binding carries. Nothing in the archive reaches outside it.

Each language's programs name the one distribution they need, taken from the same release:

DirectoryProgramsNeedsBuild and run
cpp/clika_rt/, the engine one topic per directory in chapters; tutorial/, the getting-started programs; howto/, one directory per how-to page; modelverse/, programs over the model library (the Modelverse catalog)the release archive for your platform, extracted, with CLIKART_BUNDLE_DIR naming its directorycmake -S cpp -B build -DClikaRT_DIR="$CLIKART_BUNDLE_DIR/cmake" && cmake --build build, then the binary under build/; cpp/README.md
python/clika_rt/, self-asserting chapters over the wheel, from the NumPy boundary through nn.Module, ONNX compile-and-run, tokenizers, processors and tracing; tutorial/ and howto/ as the C++ tree has them, with the Python-only pages (a model authored in Python, PyTorch interoperation, pytrees)the clika-runtime wheel for your interpreter and platform, installed with pip install <wheel>python3 <program>; python/README.md
kotlin/clika_rt/, instrumented tests that run the operator surface and the device facts on a connected Android device; tutorial/, the getting-started programs on a desktop JVM; howto/, the vision-task programs on a desktop JVMthe Kotlin artifact, clika-runtime-maven-<version>.zip, extracted anywhere and named to gradle as -PclikaRtMavenRepo=<dir>; a desktop run also takes the release archive's lib/ on java.library.pathgradle connectedAndroidTest -PclikaRtMavenRepo=<dir> in a chapter's directory; kotlin/README.md
android/three sample apps, one screen each: hello loads the runtime and prints the version, the backends and one operator's result; chat loads a chat model and streams its replies; serve hosts a loaded model for the network from a foreground servicethe Kotlin artifact, as above, and an Android SDKone gradle build beside shared/; android/README.md
voice_translate/a live voice translator as one Compose Multiplatform app for Android and the desktop JVM: speech to text, translation and text to speech over the model library's Kotlin bindingthe Kotlin artifact and, per platform, the release archives the build lays outvoice_translate/README.md

Every program here runs compute, so every one of them needs a license credential in CLIKA_RT_LICENSE or in the per-user file clikart-license-init writes (Get ClikaRT); without one a call is refused with the code name LICENSE_FAILED. A model program names a checkpoint from the local hub cache or takes one as an argument; clikart-cli fetch <source> downloads it once, with no credential.

The tutorial programs this documentation shows (Your first program onward) are the archive's cpp/tutorial/, python/tutorial/ and kotlin/tutorial/ programs, with the output recorded beside them. Use ClikaRT from Python walks the first steps of the Python lane; Language bindings says what each binding carries.