Skip to main content

Calibrator

Struct Calibrator 

Source
pub struct Calibrator<'g> { /* private fields */ }
Expand description

Compiled calibration harness. The graph is owned by the caller — we hold a reference and the compiled artifacts (arena + schedule). The caller writes inputs and parameters into arena_mut() between batches.

Implementations§

Source§

impl<'g> Calibrator<'g>

Source

pub fn new(graph: &'g Graph, taps: Vec<NodeId>) -> Self

Build a calibrator over graph that records max-abs at each tap after every step(). The graph must already have those taps in its outputs list (so the memory planner keeps their arena slots alive to end-of-execution); this constructor asserts the precondition.

Source

pub fn arena_mut(&mut self) -> &mut Arena

Mutable arena access — for writing inputs/params before each step() and (typically once at startup) for filling Op::Constant data via rlx_runtime’s loader.

Source

pub fn arena(&self) -> &Arena

Read-only arena view — for reading the tap values manually if the caller wants something fancier than max-abs.

Source

pub fn step(&mut self)

Run one forward batch, then update each tap’s running max-abs.

Source

pub fn max_abs(&self) -> &[f32]

Per-tap max-abs accumulated so far (in input order).

Source

pub fn scales(&self) -> Vec<f32>

Per-tap scale = max_abs / 127.0, clamped up to 1e-6. Use directly as the scale for Op::Quantize / Op::Dequantize or rlx_opt::CalibrationEntry::per_tensor.

Source

pub fn graph(&self) -> &Graph

Borrow the inner graph (for the caller to re-look-up NodeIds after compilation).

Auto Trait Implementations§

§

impl<'g> Freeze for Calibrator<'g>

§

impl<'g> !RefUnwindSafe for Calibrator<'g>

§

impl<'g> Send for Calibrator<'g>

§

impl<'g> Sync for Calibrator<'g>

§

impl<'g> Unpin for Calibrator<'g>

§

impl<'g> UnsafeUnpin for Calibrator<'g>

§

impl<'g> !UnwindSafe for Calibrator<'g>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.