pub struct TraceContext { /* private fields */ }Expand description
Mutable owner of one backend-neutral semantic trace.
Values issued by one context cannot be used by another. Consuming
finish freezes the trace into an immutable
TracedGraph.
Implementations§
Source§impl TraceContext
impl TraceContext
Sourcepub fn input(
&mut self,
spec: ProgramInputSpec,
) -> Result<TraceValue, ProgramBuildError>
pub fn input( &mut self, spec: ProgramInputSpec, ) -> Result<TraceValue, ProgramBuildError>
Add one ordered external input.
§Errors
Returns ProgramBuildError::TooManyValues if another value cannot be
represented.
Sourcepub fn input_with_default(
&mut self,
spec: ProgramInputSpec,
tensor: Arc<Tensor>,
) -> Result<TraceValue, ProgramBuildError>
pub fn input_with_default( &mut self, spec: ProgramInputSpec, tensor: Arc<Tensor>, ) -> Result<TraceValue, ProgramBuildError>
Add one ordered input and attach its default tensor.
§Errors
Returns ProgramBuildError::TooManyValues when another input cannot be
represented, ProgramBuildError::BindingTargetNotInput if the new
value is not accepted as an input, or
ProgramBuildError::DuplicateBinding if it is already bound.
Sourcepub fn bind_input(
&mut self,
input: TraceValue,
tensor: Arc<Tensor>,
) -> Result<BindingKey, ProgramBuildError>
pub fn bind_input( &mut self, input: TraceValue, tensor: Arc<Tensor>, ) -> Result<BindingKey, ProgramBuildError>
Attach a tensor default to an existing trace input.
§Errors
Returns ProgramBuildError::ForeignValue for another context’s
value, ProgramBuildError::BindingTargetNotInput for a computed
value, or ProgramBuildError::DuplicateBinding for a repeated
binding.
Sourcepub fn add_op(
&mut self,
op: CoreSemanticOp,
inputs: &[TraceValue],
) -> Result<Box<[TraceValue]>, ProgramBuildError>
pub fn add_op( &mut self, op: CoreSemanticOp, inputs: &[TraceValue], ) -> Result<Box<[TraceValue]>, ProgramBuildError>
Add one canonical core semantic operation.
§Errors
Returns ProgramBuildError::ForeignValue for an input from another
context, ProgramBuildError::Arity for the wrong input count, or
ProgramBuildError::Metadata /
ProgramBuildError::OutputMetadataCount when inference returns
invalid metadata.
Sourcepub fn add_extension(
&mut self,
op: Arc<dyn ExtensionOp>,
inputs: &[TraceValue],
) -> Result<Box<[TraceValue]>, ProgramBuildError>
pub fn add_extension( &mut self, op: Arc<dyn ExtensionOp>, inputs: &[TraceValue], ) -> Result<Box<[TraceValue]>, ProgramBuildError>
Add one extension semantic operation.
§Errors
Returns ProgramBuildError::ForeignValue or
ProgramBuildError::Arity for invalid inputs,
ProgramBuildError::UndeclaredExtensionEffects /
ProgramBuildError::UndeclaredExtensionAliases for an incomplete
extension contract, or ProgramBuildError::Metadata when inference
fails.
Sourcepub fn value_metadata(
&self,
value: TraceValue,
) -> Result<&ProgramValueMetadata, ProgramBuildError>
pub fn value_metadata( &self, value: TraceValue, ) -> Result<&ProgramValueMetadata, ProgramBuildError>
Borrow metadata for a context-owned value.
§Errors
Returns ProgramBuildError::ForeignValue for a value from another
context.
Sourcepub fn extension_caches_mut(&mut self) -> &mut ExtensionCacheStore
pub fn extension_caches_mut(&mut self) -> &mut ExtensionCacheStore
Borrow the generic trace-time extension cache store.
Sourcepub fn finish(
self,
outputs: &[TraceValue],
) -> Result<TracedGraph, ProgramFinishError>
pub fn finish( self, outputs: &[TraceValue], ) -> Result<TracedGraph, ProgramFinishError>
Consume and atomically freeze this context.
Ordered and duplicate outputs are preserved.
§Errors
Returns ProgramFinishError::ForeignOutput if an output belongs to
another context, or a typed structural/binding finalization failure.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TraceContext
impl !RefUnwindSafe for TraceContext
impl Send for TraceContext
impl Sync for TraceContext
impl Unpin for TraceContext
impl UnsafeUnpin for TraceContext
impl !UnwindSafe for TraceContext
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
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