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
impl InferenceFact
Sourcepub fn new() -> InferenceFact
pub fn new() -> InferenceFact
Constructs the most general tensor fact possible.
pub fn any() -> InferenceFact
pub fn dt(dt: DatumType) -> InferenceFact
pub fn dt_shape<S>(dt: DatumType, shape: S) -> InferenceFactwhere
S: Into<ShapeFactoid>,
pub fn shape<S>(shape: S) -> InferenceFactwhere
S: Into<ShapeFactoid>,
pub fn with_datum_type(self, dt: DatumType) -> InferenceFact
pub fn without_datum_type(self) -> InferenceFact
pub fn with_shape<S>(self, shape: S) -> InferenceFactwhere
S: Into<ShapeFactoid>,
pub fn format_dt_shape(&self) -> String
pub fn dt_shape_from_tensor(t: &Tensor) -> InferenceFact
pub fn without_value(self) -> InferenceFact
Trait Implementations§
Source§impl Clone for InferenceFact
impl Clone for InferenceFact
Source§fn clone(&self) -> InferenceFact
fn clone(&self) -> InferenceFact
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for InferenceFact
impl Debug for InferenceFact
Source§impl Default for InferenceFact
impl Default for InferenceFact
Source§fn default() -> InferenceFact
fn default() -> InferenceFact
Source§impl Fact for InferenceFact
impl Fact for InferenceFact
fn to_typed_fact(&self) -> Result<Cow<'_, TypedFact>, Error>
fn matches( &self, t: &Tensor, _symbols: Option<&SymbolValues>, ) -> Result<bool, Error>
fn same_as(&self, other: &(dyn Fact + 'static)) -> bool
Source§fn compatible_with(&self, other: &(dyn Fact + 'static)) -> bool
fn compatible_with(&self, other: &(dyn Fact + 'static)) -> bool
fn datum_type(&self) -> Option<DatumType>
Source§impl Factoid for InferenceFact
impl Factoid for InferenceFact
Source§fn concretize(&self) -> Option<<InferenceFact as Factoid>::Concrete>
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>
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
fn is_concrete(&self) -> bool
Source§fn unify_with(&mut self, other: &Self) -> Result<bool, Error>
fn unify_with(&mut self, other: &Self) -> Result<bool, Error>
Source§impl<'a> From<&'a InferenceFact> for InferenceFact
impl<'a> From<&'a InferenceFact> for InferenceFact
Source§fn from(t: &'a InferenceFact) -> InferenceFact
fn from(t: &'a InferenceFact) -> InferenceFact
Source§impl<'a> From<&'a TypedFact> for InferenceFact
impl<'a> From<&'a TypedFact> for InferenceFact
Source§fn from(t: &'a TypedFact) -> InferenceFact
fn from(t: &'a TypedFact) -> InferenceFact
Source§impl From<Tensor> for InferenceFact
impl From<Tensor> for InferenceFact
Source§fn from(t: Tensor) -> InferenceFact
fn from(t: Tensor) -> InferenceFact
Source§impl From<TypedFact> for InferenceFact
impl From<TypedFact> for InferenceFact
Source§fn from(t: TypedFact) -> InferenceFact
fn from(t: TypedFact) -> InferenceFact
Source§impl Hash for InferenceFact
impl Hash for InferenceFact
Source§impl PartialEq for InferenceFact
impl PartialEq for InferenceFact
Source§impl SpecialOps<InferenceFact, Box<dyn InferenceOp>> for Graph<InferenceFact, Box<dyn InferenceOp>>
impl SpecialOps<InferenceFact, Box<dyn InferenceOp>> for Graph<InferenceFact, Box<dyn InferenceOp>>
fn is_source(op: &Box<dyn InferenceOp>) -> bool
fn create_dummy(&self) -> Box<dyn InferenceOp>
fn create_source(&self, _fact: InferenceFact) -> Box<dyn InferenceOp>
fn wire_node( &mut self, name: impl Into<String>, op: impl Into<Box<dyn InferenceOp>>, inputs: &[OutletId], ) -> Result<SmallVec<[OutletId; 4]>, Error>
fn add_const( &mut self, name: impl Into<String>, v: impl IntoArcTensor, ) -> Result<OutletId, Error>
Source§impl TryFrom<&InferenceFact> for TypedFact
impl TryFrom<&InferenceFact> for TypedFact
impl Eq for InferenceFact
impl StructuralPartialEq for InferenceFact
Auto Trait Implementations§
impl Freeze for InferenceFact
impl !RefUnwindSafe for InferenceFact
impl Send for InferenceFact
impl Sync for InferenceFact
impl Unpin for InferenceFact
impl !UnwindSafe for InferenceFact
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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
.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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