Struct Context
pub struct Context<H> {
pub tensors: HashMap<TensorId, TensorIr>,
pub handles: HandleContainer<H>,
pub scalars: HashMap<ScalarId, ScalarIr>,
pub shapes_relative2global: HashMap<usize, usize>,
pub ranges: Vec<Slice>,
}Expand description
The context contains the relative graph tensor mapping so that a relative tensor id can be mapped to an existing tensor that can be fetched and updated with the handle container.
It also contains all scalar values, which can change even for the same graph. They are sorted in the order in which they appear in the graph.
Fields§
§tensors: HashMap<TensorId, TensorIr>The tensor mapping where local tensor id points to the updated tensor representation.
handles: HandleContainer<H>Handle container to retrieve tensors based on their representation.
scalars: HashMap<ScalarId, ScalarIr>Scalars found in the graph in the order they appeared.
shapes_relative2global: HashMap<usize, usize>Shape mapping from relative shape ids to global (real) shape ids.
ranges: Vec<Slice>Concrete slice ranges found in the graph, indexed by the placeholder id assigned during
relativization (the value carried in a relativized range’s start field). Ranges can change
for the same relative graph — like scalars — so they are kept out of the relative form and
rebound per invocation.
Implementations§
§impl<H> Context<H>where
H: Clone,
impl<H> Context<H>where
H: Clone,
pub fn fork(&self) -> Context<H>
pub fn fork(&self) -> Context<H>
Fork the context into an independent owned copy. Used by autotuning to give each
benchmark run a sandbox — mutations stay local until the caller merges new handles
back. HandleContainer::fork clones the id→handle map; actual GPU buffers are
refcounted so only the map itself is duplicated.
Auto Trait Implementations§
impl<H> Freeze for Context<H>
impl<H> RefUnwindSafe for Context<H>where
H: RefUnwindSafe,
impl<H> Send for Context<H>where
H: Send,
impl<H> Sync for Context<H>where
H: Sync,
impl<H> Unpin for Context<H>where
H: Unpin,
impl<H> UnsafeUnpin for Context<H>
impl<H> UnwindSafe for Context<H>where
H: UnwindSafe,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<K, Q> Comparable<Q> for K
impl<K, Q> Comparable<Q> for K
§impl<K, Q> Equivalent<Q> for K
impl<K, Q> Equivalent<Q> for K
§fn equivalent(&self, key: &Q) -> bool
fn equivalent(&self, key: &Q) -> bool
key and return true if they are equal.impl<T> ErasedDestructor for Twhere
T: 'static,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
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>
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