pub trait Model:
Downcast
+ Debug
+ DynClone
+ Send
+ Sync {
Show 27 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) -> StaticName;
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_opt_ram(&self) -> 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 symbols(&self) -> &SymbolScope;
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) -> StaticName
fn node_op_name(&self, id: usize) -> StaticName
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_opt_ram(&self) -> TractResult<Vec<usize>>
fn eval_order_opt_ram(&self) -> TractResult<Vec<usize>>
Eval order for the model
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 symbols(&self) -> &SymbolScope
fn get_or_intern_symbol(&self, name: &str) -> Symbol
fn rename_node(&mut self, id: usize, name: &str) -> TractResult<()>
Provided Methods§
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.