pub struct CostModel { /* private fields */ }Expand description
The main cost model; use CostModel::estimate_graph to get a full
GraphCostSummary.
Implementations§
Source§impl CostModel
impl CostModel
Sourcepub fn new(config: CostModelConfig) -> Self
pub fn new(config: CostModelConfig) -> Self
Create with the supplied config.
Sourcepub fn with_default() -> Self
pub fn with_default() -> Self
Create with default config (f64 elements, no throughput hint).
Sourcepub fn estimate_graph(&self, graph: &EinsumGraph) -> GraphCostSummary
pub fn estimate_graph(&self, graph: &EinsumGraph) -> GraphCostSummary
Estimate costs for the entire graph, returning a GraphCostSummary.
Sourcepub fn estimate_node(
&self,
node: &EinsumNode,
input_shapes: &[Vec<usize>],
) -> NodeCostEstimate
pub fn estimate_node( &self, node: &EinsumNode, input_shapes: &[Vec<usize>], ) -> NodeCostEstimate
Estimate cost for a single node given known input shapes.
Sourcepub fn estimate_einsum_flops(
equation: &str,
input_shapes: &[Vec<usize>],
) -> FlopEstimate
pub fn estimate_einsum_flops( equation: &str, input_shapes: &[Vec<usize>], ) -> FlopEstimate
Estimate FLOPs for an einsum contraction.
Strategy: multiply all unique index dimension sizes together. That product is the number of multiply-add operations.
Sourcepub fn infer_output_shape(
node: &EinsumNode,
input_shapes: &[Vec<usize>],
) -> Vec<usize>
pub fn infer_output_shape( node: &EinsumNode, input_shapes: &[Vec<usize>], ) -> Vec<usize>
Infer the output shape for a node given input shapes.
For einsum, parses the equation to determine output dimension sizes.
For other ops, attempts shape propagation heuristics. Falls back to a
non-empty placeholder [1] when inference is not possible.
Sourcepub fn rank_by_flops(summary: &GraphCostSummary) -> Vec<&NodeCostEstimate>
pub fn rank_by_flops(summary: &GraphCostSummary) -> Vec<&NodeCostEstimate>
Sort nodes by descending FLOP cost.
Auto Trait Implementations§
impl Freeze for CostModel
impl RefUnwindSafe for CostModel
impl Send for CostModel
impl Sync for CostModel
impl Unpin for CostModel
impl UnsafeUnpin for CostModel
impl UnwindSafe for CostModel
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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