#[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
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.compute_us: f64Estimated compute time (µs).
memory_us: f64Estimated memory-traffic time (µs).
transfer_us: f64Estimated layout-conversion / cross-device copy time at boundaries (µs).
launch_us: f64Fixed kernel-launch / dispatch latency (µs), independent of size.
bytes_moved: u64Estimated bytes of memory traffic (for roofline / bandwidth models).
Implementations§
Source§impl Cost
impl Cost
Sourcepub fn new(compute_us: f64, memory_us: f64, transfer_us: f64) -> Self
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).
Sourcepub fn with_launch_us(self, launch_us: f64) -> Self
pub fn with_launch_us(self, launch_us: f64) -> Self
Set the fixed launch/dispatch latency.
Sourcepub fn with_bytes_moved(self, bytes_moved: u64) -> Self
pub fn with_bytes_moved(self, bytes_moved: u64) -> Self
Set the estimated memory-traffic volume.