pub struct Graph { /* private fields */ }
Expand description
An execution graph for performing inference (i.e., a model), which can create instances of
GraphExecutionContext
.
Example
// Create a graph using `GraphBuilder`.
let model_file = "./test.tflite";
let graph = GraphBuilder::new(GraphEncoding::TensorflowLite, ExecutionTarget::CPU)
.build_from_files([model_file])
.unwrap();
// Create an execution context using this graph.
let mut graph_exec_ctx = graph.init_execution_context().unwrap();
// Set input tensors.
// ...
// Compute the inference on the given inputs.
graph_exec_ctx.compute().unwrap();
// Get output tensors and do post-processing.
// ...
Implementations§
source§impl Graph
impl Graph
sourcepub fn encoding(&self) -> GraphEncoding
pub fn encoding(&self) -> GraphEncoding
Get the graph encoding.
sourcepub fn execution_target(&self) -> ExecutionTarget
pub fn execution_target(&self) -> ExecutionTarget
Get the graph execution target.
sourcepub fn init_execution_context(&self) -> Result<GraphExecutionContext<'_>, Error>
pub fn init_execution_context(&self) -> Result<GraphExecutionContext<'_>, Error>
Use this graph to create a new instances of GraphExecutionContext
.
Trait Implementations§
Auto Trait Implementations§
impl RefUnwindSafe for Graph
impl Send for Graph
impl Sync for Graph
impl Unpin for Graph
impl UnwindSafe for Graph
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
Mutably borrows from an owned value. Read more