Skip to main content

Cost

Struct Cost 

Source
#[non_exhaustive]
pub struct Cost { pub compute_us: f64, pub memory_us: f64, pub transfer_us: f64, pub launch_us: f64, pub bytes_moved: u64, }
Expand description

A cost estimate for running a kernel, consumed by the placement cost model (docs/ORT2.md §6). All time fields are in microseconds; a fuller model (roofline, calibration) lands in onnx-runtime-cost-model (Phase 2).

The struct is #[non_exhaustive]: the Phase-2 cost model may add fields (e.g. energy, occupancy) without breaking EP crates. Construct it via Cost::ZERO, Cost::new, or the with_* builders rather than a struct literal so those additions stay source-compatible.

The three time components (compute_us, memory_us, transfer_us) map onto the design’s compute, memory-traffic, and layout/transfer estimates; launch_us captures fixed dispatch latency (§6.2 launch_overhead) and bytes_moved carries the raw memory-traffic figure a roofline model needs (§6.3, mirroring the design Cost::memory_bytes).

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§compute_us: f64

Estimated compute time (µs).

§memory_us: f64

Estimated memory-traffic time (µs).

§transfer_us: f64

Estimated layout-conversion / cross-device copy time at boundaries (µs).

§launch_us: f64

Fixed kernel-launch / dispatch latency (µs), independent of size.

§bytes_moved: u64

Estimated bytes of memory traffic (for roofline / bandwidth models).

Implementations§

Source§

impl Cost

Source

pub const ZERO: Cost

The zero cost (free op).

Source

pub fn new(compute_us: f64, memory_us: f64, transfer_us: f64) -> Self

A cost from its three time components; launch_us and bytes_moved default to zero (set them via the builders).

Source

pub fn with_launch_us(self, launch_us: f64) -> Self

Set the fixed launch/dispatch latency.

Source

pub fn with_bytes_moved(self, bytes_moved: u64) -> Self

Set the estimated memory-traffic volume.

Source

pub fn total_us(&self) -> f64

Total estimated wall time (µs): the sum of all time components.

Trait Implementations§

Source§

impl Clone for Cost

Source§

fn clone(&self) -> Cost

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Cost

Source§

impl Debug for Cost

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Cost

Source§

fn default() -> Cost

Returns the “default value” for a type. Read more
Source§

impl PartialEq for Cost

Source§

fn eq(&self, other: &Cost) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Cost

Auto Trait Implementations§

§

impl Freeze for Cost

§

impl RefUnwindSafe for Cost

§

impl Send for Cost

§

impl Sync for Cost

§

impl Unpin for Cost

§

impl UnsafeUnpin for Cost

§

impl UnwindSafe for Cost

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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.