Skip to main content

CachingCompiler

Struct CachingCompiler 

Source
pub struct CachingCompiler { /* private fields */ }

Implementations§

Source§

impl CachingCompiler

Source

pub fn new<F>(capacity: usize, compile_fn: F) -> Self
where F: Fn(&TLExpr) -> Result<EinsumGraph, String> + Send + Sync + 'static,

Create a CachingCompiler with a custom compile function and cache capacity.

§Arguments
  • capacity – Maximum number of entries held in the LRU cache.
  • compile_fn – A closure (or function) that compiles a TLExpr into an EinsumGraph, returning Err(String) on failure.
Source

pub fn compile(&mut self, expr: &TLExpr) -> Result<EinsumGraph, String>

Compile an expression, returning the cached result when available.

§Errors

Propagates any error produced by the underlying compile function on a cache miss.

Source

pub fn compile_batch( &mut self, exprs: &[TLExpr], ) -> Vec<Result<EinsumGraph, String>>

Compile multiple expressions in order, sharing the cache across all of them.

Returns one Result per input expression in the same order.

Source

pub fn cache_stats(&self) -> &CacheStats

Returns a reference to the current cache statistics.

Source

pub fn invalidate(&mut self, expr: &TLExpr) -> bool

Invalidate the cached result for a specific expression.

Returns true if an entry was present and removed.

Source

pub fn fingerprint(expr: &TLExpr) -> ExprFingerprint

Compute a structural ExprFingerprint for an expression.

Two structurally identical expressions will produce equal fingerprints.

Auto Trait Implementations§

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, 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.