pub struct InferenceFact {
    pub datum_type: GenericFactoid<DatumType>,
    pub shape: ShapeFactoid,
    pub value: GenericFactoid<Arc<Tensor>>,
}
Expand description

Partial information about a tensor.

The task of the analyser is to tag every edge in the graph with information about the tensors that flow through it - specifically their datum_type, their shape and possibly their value. During the analysis, however, we might only know some of that information (say, for instance, that an edge only carries tensors of rank 4, but without knowing their precise dimension).

This is where tensor facts come in: they hold partial information about the datum_type, shape and value of tensors that might flow through an edge of the graph. The analyser will first tag each edge with a fact, starting with the most general one and specializing it at each iteration. Eventually, it will reach a fixed point that - hopefully - holds enough information.

Fields§

§datum_type: GenericFactoid<DatumType>§shape: ShapeFactoid§value: GenericFactoid<Arc<Tensor>>

Implementations§

source§

impl InferenceFact

source

pub fn new() -> InferenceFact

Constructs the most general tensor fact possible.

source

pub fn any() -> InferenceFact

source

pub fn dt(dt: DatumType) -> InferenceFact

source

pub fn dt_shape<S>(dt: DatumType, shape: S) -> InferenceFactwhere S: Into<ShapeFactoid>,

source

pub fn shape<S>(shape: S) -> InferenceFactwhere S: Into<ShapeFactoid>,

source

pub fn with_datum_type(self, dt: DatumType) -> InferenceFact

source

pub fn without_datum_type(self) -> InferenceFact

source

pub fn with_shape<S>(self, shape: S) -> InferenceFactwhere S: Into<ShapeFactoid>,

source

pub fn format_dt_shape(&self) -> String

source

pub fn dt_shape_from_tensor(t: &Tensor) -> InferenceFact

source

pub fn without_value(self) -> InferenceFact

Trait Implementations§

source§

impl Clone for InferenceFact

source§

fn clone(&self) -> InferenceFact

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for InferenceFact

source§

fn fmt(&self, formatter: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
source§

impl Default for InferenceFact

source§

fn default() -> InferenceFact

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

impl Fact for InferenceFact

source§

fn to_typed_fact(&self) -> Result<Cow<'_, TypedFact>, Error>

source§

fn matches( &self, t: &Tensor, symbols: Option<&SymbolValues> ) -> Result<bool, Error>

source§

fn same_as(&self, other: &(dyn Fact + 'static)) -> bool

source§

fn compatible_with(&self, other: &(dyn Fact + 'static)) -> bool

Ensure that self is same type as another fact or a subtype
source§

fn datum_type(&self) -> Option<DatumType>

source§

impl Factoid for InferenceFact

source§

fn concretize(&self) -> Option<<InferenceFact as Factoid>::Concrete>

Tries to transform the fact into a concrete value.

source§

fn unify(&self, other: &InferenceFact) -> Result<InferenceFact, Error>

Tries to unify the fact with another fact of the same type.

§

type Concrete = Arc<Tensor>

source§

fn is_concrete(&self) -> bool

Returns whether the value is fully determined.
source§

fn unify_with(&mut self, other: &Self) -> Result<bool, Error>

Tries to unify the fact with another fact of the same type and update self. Read more
source§

fn unify_with_mut(&mut self, other: &mut Self) -> Result<bool, Error>

Tries to unify the fact with another fact of the same type and update both of them. Read more
source§

fn unify_all(facts: &mut [&mut Self]) -> Result<bool, Error>

Tries to unify all facts in the list. Read more
source§

impl<'a> From<&'a Arc<Tensor>> for InferenceFact

source§

fn from(t: &'a Arc<Tensor>) -> InferenceFact

Converts to this type from the input type.
source§

impl<'a> From<&'a InferenceFact> for InferenceFact

source§

fn from(t: &'a InferenceFact) -> InferenceFact

Converts to this type from the input type.
source§

impl<'a> From<&'a Tensor> for InferenceFact

source§

fn from(t: &'a Tensor) -> InferenceFact

Converts to this type from the input type.
source§

impl<'a> From<&'a TypedFact> for InferenceFact

source§

fn from(t: &'a TypedFact) -> InferenceFact

Converts to this type from the input type.
source§

impl From<Arc<Tensor>> for InferenceFact

source§

fn from(t: Arc<Tensor>) -> InferenceFact

Converts to this type from the input type.
source§

impl From<Tensor> for InferenceFact

source§

fn from(t: Tensor) -> InferenceFact

Converts to this type from the input type.
source§

impl From<TypedFact> for InferenceFact

source§

fn from(t: TypedFact) -> InferenceFact

Converts to this type from the input type.
source§

impl Hash for InferenceFact

source§

fn hash<__H>(&self, state: &mut __H)where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl PartialEq<InferenceFact> for InferenceFact

source§

fn eq(&self, other: &InferenceFact) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl SpecialOps<InferenceFact, Box<dyn InferenceOp + 'static, Global>> for Graph<InferenceFact, Box<dyn InferenceOp + 'static, Global>>

source§

fn is_source(op: &Box<dyn InferenceOp + 'static, Global>) -> bool

source§

fn create_dummy(&self) -> Box<dyn InferenceOp + 'static, Global>

source§

fn create_source( &self, _fact: InferenceFact ) -> Box<dyn InferenceOp + 'static, Global>

source§

fn wire_node( &mut self, name: impl Into<String>, op: impl Into<Box<dyn InferenceOp + 'static, Global>>, inputs: &[OutletId] ) -> Result<SmallVec<[OutletId; 4]>, Error>

source§

impl<'a> TryFrom<&'a InferenceFact> for TypedFact

§

type Error = Error

The type returned in the event of a conversion error.
source§

fn try_from(fact: &InferenceFact) -> Result<TypedFact, Error>

Performs the conversion.
source§

impl Eq for InferenceFact

source§

impl StructuralEq for InferenceFact

source§

impl StructuralPartialEq for InferenceFact

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> CallHasher for Twhere T: Hash + ?Sized,

§

default fn get_hash<H, B>(value: &H, build_hasher: &B) -> u64where H: Hash + ?Sized, B: BuildHasher,

§

impl<T> Downcast for Twhere T: Any,

§

fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> DowncastSync for Twhere T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync + 'static>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
source§

impl<T> DynClone for Twhere T: Clone,

source§

fn __clone_box(&self, _: Private) -> *mut ()

source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere 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> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.