Skip to main content

Additional examples

The bundle ships the public examples under examples/src. Each example is a standalone find_package(ClikaRT CONFIG) project on the public API only, and each builds its topic up one chapter at a time, starting at 00_hello_world. Every example directory has its own README.md walk-through.

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 acceleration00_hello_world · 01_columns_and_dtypes · 02_csv · 03_select_filter_sort · 04_groupby_join · 05_transform · 06_acceleration
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)

Beyond C++

The binding lanes carry their own chapter sets, written to the same standard (each chapter teaches one thing and asserts its own results):

  • Python: sixteen self-asserting scripts over the clika-runtime wheel, from the NumPy boundary through nn.Module, ONNX compile-and-run, tokenizers, processors, and tracing. The set doubles as a smoke suite for an installed wheel.
  • C: one narrated strict-C99 chapter over the raw ABI (dlopen, the api-table handshake, ops, typed errors), the same program the Kotlin and Rust hello chapters run through their bindings.
  • Kotlin and Rust: six chapters each, from the ABI hello through tensor ops, an nn MLP, and consuming or authoring ONNX graphs.

Use ClikaRT from Python and Call ClikaRT from C walk the first steps of those lanes.

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 bundle carries pre-built example binaries (examples/bin), run them in place: they find the libraries through a relative rpath and need no environment setup.