Expand description
A binary serialization of functions.
The format starts with the magic bytes RXIR and a format version.
Variables are numbered in order of first appearance, so functions that
differ only in variable ids serialize to the same bytes (usable as cache
keys); they get fresh ids when read back. Primitives are stored by name
and resolved with a lookup function (normally ruxla_prims::by_name).
§Examples
use ruxla_ir::{AVal, DType, Function, Var, serialize};
let x = Var::new(AVal::new([2], DType::F32));
let f = Function { invars: vec![x.clone()], outvars: vec![x.into()], ..Function::default() };
let g = serialize::from_bytes(&serialize::to_bytes(&f), &|_| None).unwrap();
assert_eq!(g.to_string(), f.to_string());Constants§
- FORMAT_
VERSION - The version of the format written by
to_bytes.
Functions§
- from_
bytes - Reads a function written by
to_bytes, resolving primitives by name. - to_
bytes - Serializes a function.