Skip to main content

TraceContext

Struct TraceContext 

Source
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

Source

pub fn new() -> Self

Construct an empty trace context.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn extension_caches_mut(&mut self) -> &mut ExtensionCacheStore

Borrow the generic trace-time extension cache store.

Source

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§

Source§

impl Default for TraceContext

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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.
§

impl<T> MaybeSend for T
where T: Send,

§

impl<T> MaybeSendSync for T
where T: Send + Sync,

§

impl<T> MaybeSync for T
where T: Sync,