Skip to main content

module onnx

Builders for the ONNX graph-authoring values: dimension entries (dim, named_dim) and node attributes (attr_int, attr_float, attr_str, and the array forms). Each returns the raw sys value the authoring calls take slices of.

Name and string payloads are BORROWED by the returned value (pointer + length, no copy). The safe builders therefore take &'static str; the literal case, which is every ONNX attribute and dimension name in practice; a computed string can enter via Box::leak. The array forms borrow caller slices and are unsafe, with the outlive contract on each.

use clika_rt::onnx;
let batch = onnx::named_dim("batch", None, Some(1), Some(64));
let width = onnx::dim(32);
let alpha = onnx::attr_float("alpha", 0.5);
assert_eq!(width.int_value, 32);
assert_eq!(batch.dim_opt, 1);
assert_eq!(alpha.double_value, 0.5);

attr_float

fn attr_float(name: &str, value: f64) -> clika_rt_onnx_attr

A floating-point node attribute.

attr_floats

unsafe fn attr_floats(name: &str, values: &[f64]) -> clika_rt_onnx_attr

A floating-point-array node attribute.

Safety

The returned attribute borrows values as a raw pointer the borrow checker cannot see: values must stay alive and unmoved until the authoring call consuming the attribute returns.

attr_int

fn attr_int(name: &str, value: i64) -> clika_rt_onnx_attr

An integer node attribute.

attr_ints

unsafe fn attr_ints(name: &str, values: &[i64]) -> clika_rt_onnx_attr

An integer-array node attribute.

Safety

The returned attribute borrows values as a raw pointer the borrow checker cannot see: values must stay alive and unmoved until the authoring call consuming the attribute returns.

attr_str

fn attr_str(name: &str, value: &str) -> clika_rt_onnx_attr

A string node attribute. The value's bytes are borrowed by the returned attribute, so both strings are 'static (the literal case); a computed value can enter via Box::leak.

dim

fn dim(value: i64) -> clika_rt_dim_or_int

A concrete dimension extent.

named_dim

fn named_dim(name: &str, min: Option<i64>, typical: Option<i64>, max: Option<i64>) -> clika_rt_dim_or_int

A named (dynamic) dimension, with optional min / typical / max bounds. Slots naming the same dimension share the size.