Trait tract_libcli::model::Model
source · pub trait Model: Downcast + Debug + DynClone + Send + Sync {
Show 26 methods
// Required methods
fn node_id_by_name(&self, name: &str) -> TractResult<usize>;
fn node_name(&self, id: usize) -> &str;
fn node_op(&self, id: usize) -> &dyn Op;
fn node_const(&self, id: usize) -> bool;
fn node_op_name(&self, id: usize) -> Cow<'_, str>;
fn node_inputs(&self, id: usize) -> &[OutletId];
fn node_output_count(&self, id: usize) -> usize;
fn nodes_len(&self) -> usize;
fn node_display(&self, id: usize) -> String;
fn node_debug(&self, id: usize) -> String;
fn eval_order(&self) -> TractResult<Vec<usize>>;
fn eval_order_for_io(
&self,
inputs: &[usize],
outputs: &[usize]
) -> TractResult<Vec<usize>>;
fn input_outlets(&self) -> &[OutletId];
fn set_input_names(&mut self, names: &[&str]) -> TractResult<()>;
fn set_output_names(&mut self, names: &[&str]) -> TractResult<()>;
fn output_outlets(&self) -> &[OutletId];
fn outlet_typedfact(&self, outlet: OutletId) -> TractResult<TypedFact>;
fn outlet_fact_format(&self, outlet: OutletId) -> String;
fn outlet_label(&self, id: OutletId) -> Option<&str>;
fn outlet_successors(&self, outlet: OutletId) -> &[InletId];
fn auto_outputs(&mut self) -> TractResult<()>;
fn properties(&self) -> &HashMap<String, Arc<Tensor>>;
fn get_or_intern_symbol(&self, name: &str) -> Symbol;
fn rename_node(&mut self, id: usize, name: &str) -> TractResult<()>;
// Provided methods
fn nested_models(&self, id: usize) -> Vec<(String, &dyn Model)> { ... }
fn nested_models_iters(
&self,
id: usize,
input: &[&TypedFact]
) -> Option<TDim> { ... }
}Expand description
Common methods for all variants of model.
Required Methods§
sourcefn node_id_by_name(&self, name: &str) -> TractResult<usize>
fn node_id_by_name(&self, name: &str) -> TractResult<usize>
Lookup node id by name
sourcefn node_const(&self, id: usize) -> bool
fn node_const(&self, id: usize) -> bool
Node is const
sourcefn node_op_name(&self, id: usize) -> Cow<'_, str>
fn node_op_name(&self, id: usize) -> Cow<'_, str>
Node op by id
sourcefn node_inputs(&self, id: usize) -> &[OutletId]
fn node_inputs(&self, id: usize) -> &[OutletId]
Node inputs by id
sourcefn node_output_count(&self, id: usize) -> usize
fn node_output_count(&self, id: usize) -> usize
Number of outputs for a node, by id.
sourcefn node_display(&self, id: usize) -> String
fn node_display(&self, id: usize) -> String
Formatted node label
sourcefn node_debug(&self, id: usize) -> String
fn node_debug(&self, id: usize) -> String
Formatted node label
sourcefn eval_order(&self) -> TractResult<Vec<usize>>
fn eval_order(&self) -> TractResult<Vec<usize>>
Eval order for the model
sourcefn eval_order_for_io(
&self,
inputs: &[usize],
outputs: &[usize]
) -> TractResult<Vec<usize>>
fn eval_order_for_io( &self, inputs: &[usize], outputs: &[usize] ) -> TractResult<Vec<usize>>
Eval order for the model overriding input and outputs node
sourcefn input_outlets(&self) -> &[OutletId]
fn input_outlets(&self) -> &[OutletId]
Inputs of the model
fn set_input_names(&mut self, names: &[&str]) -> TractResult<()>
fn set_output_names(&mut self, names: &[&str]) -> TractResult<()>
sourcefn output_outlets(&self) -> &[OutletId]
fn output_outlets(&self) -> &[OutletId]
Outputs of the model
sourcefn outlet_typedfact(&self, outlet: OutletId) -> TractResult<TypedFact>
fn outlet_typedfact(&self, outlet: OutletId) -> TractResult<TypedFact>
Tensorfact for an outlet
sourcefn outlet_fact_format(&self, outlet: OutletId) -> String
fn outlet_fact_format(&self, outlet: OutletId) -> String
Short outlet formatter (id plus fact)
sourcefn outlet_label(&self, id: OutletId) -> Option<&str>
fn outlet_label(&self, id: OutletId) -> Option<&str>
Labels for an outlet
sourcefn outlet_successors(&self, outlet: OutletId) -> &[InletId]
fn outlet_successors(&self, outlet: OutletId) -> &[InletId]
List consumers of an outlet
fn auto_outputs(&mut self) -> TractResult<()>
fn properties(&self) -> &HashMap<String, Arc<Tensor>>
fn get_or_intern_symbol(&self, name: &str) -> Symbol
fn rename_node(&mut self, id: usize, name: &str) -> TractResult<()>
Provided Methods§
sourcefn nested_models_iters(&self, id: usize, input: &[&TypedFact]) -> Option<TDim>
fn nested_models_iters(&self, id: usize, input: &[&TypedFact]) -> Option<TDim>
Subnets of a node
Implementations§
source§impl dyn Model
impl dyn Model
sourcepub fn is<__T: Model>(&self) -> bool
pub fn is<__T: Model>(&self) -> bool
Returns true if the trait object wraps an object of type __T.
sourcepub fn downcast<__T: Model>(self: Box<Self>) -> Result<Box<__T>, Box<Self>>
pub fn downcast<__T: Model>(self: Box<Self>) -> Result<Box<__T>, Box<Self>>
Returns a boxed object from a boxed trait object if the underlying object is of type
__T. Returns the original boxed trait if it isn’t.
sourcepub fn downcast_rc<__T: Model>(self: Rc<Self>) -> Result<Rc<__T>, Rc<Self>>
pub fn downcast_rc<__T: Model>(self: Rc<Self>) -> Result<Rc<__T>, Rc<Self>>
Returns an Rc-ed object from an Rc-ed trait object if the underlying object is of
type __T. Returns the original Rc-ed trait if it isn’t.
sourcepub fn downcast_ref<__T: Model>(&self) -> Option<&__T>
pub fn downcast_ref<__T: Model>(&self) -> Option<&__T>
Returns a reference to the object within the trait object if it is of type __T, or
None if it isn’t.
sourcepub fn downcast_mut<__T: Model>(&mut self) -> Option<&mut __T>
pub fn downcast_mut<__T: Model>(&mut self) -> Option<&mut __T>
Returns a mutable reference to the object within the trait object if it is of type
__T, or None if it isn’t.