Struct tract_hir::infer::rules::Solver[][src]

pub struct Solver<'rules> {
    pub rules: Vec<Box<dyn Rule<'rules> + 'rules>>,
}
Expand description

A declarative constraint solver for tensors.

Fields

rules: Vec<Box<dyn Rule<'rules> + 'rules>>

Implementations

Consumes the solver and returns the rules that it uses.

Runs the solver on a set of InferenceFacts.

This method returns:

  • Err(_) if a constraint couldn’t be satisfied.
  • Ok(None) if no more information about tensors could be deduced.
  • Ok(Some(facts)) otherwise, with facts the new InferenceFacts.

Ensures that two expressions are equal.

For instance, one could write:

solver.equals(outputs[0].rank, inputs[1].shape[0]);
solver.equals(outputs[1].rank, 3);

Ensures that several expressions are equal.

For instance, one could write:

solver.equals_all(vec![
    outputs[0].rank.into(),
    inputs[1].shape[0].into(),
    3.into(),
]);

Ensures that the sum of several expressions equals zero.

For instance, one could write:

solver.equals_zero(vec![
    outputs[0].rank.into(),
    outputs[1].rank.into(),
    (-1, inputs[1].shape[0]).into(),
]);

Adds rules to the solver with a partial value.

For instance, one could write:

solver.given(input.rank, |solver, ir|
    (0..ir).map(|i| solver.equals(input.shape[ir], 0))
);

Adds rules to the solver once the value of an expression is known.

For instance, one could write:

solver.given(input.rank, |solver, ir|
    (0..ir).map(|i| solver.equals(input.shape[ir], 0))
);

Adds rules to the solver once the value of all expressions are known.

For instance, one could write:

solver.given(input.rank, |solver, ir|
    (0..ir).map(|i| solver.equals(input.shape[ir], 0))
);

Trait Implementations

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

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

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. Read more

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

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

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

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.