Struct wasi_nn_safe::GraphBuilder
source · pub struct GraphBuilder { /* private fields */ }
Expand description
Graph factory, which can be used in order to configure the properties of a new graph. Methods can be chained on it in order to configure it.
- Default Graph Encoding:
Openvino
. - Default Execution Target:
CPU
.
Examples
build a graph with default config ( CPU
+ Openvino
)
use wasi_nn_safe::GraphBuilder;
let xml = "./mobilenet.xml";
let weight = "./mobilenet.bin";
let graph = GraphBuilder::default().build_from_files([xml, weight])?;
build a graph with onnx backend and gpu device target
use wasi_nn_safe::{GraphBuilder, GraphEncoding, ExecutionTarget};
let model_file = "./test.onnx";
let graph = GraphBuilder::new(GraphEncoding::Onnx, ExecutionTarget::GPU).build_from_files([model_file])?;
Implementations§
source§impl GraphBuilder
impl GraphBuilder
sourcepub fn new(encoding: GraphEncoding, target: ExecutionTarget) -> Self
pub fn new(encoding: GraphEncoding, target: ExecutionTarget) -> Self
Create a new GraphBuilder
.
sourcepub fn encoding(self, encoding: GraphEncoding) -> Self
pub fn encoding(self, encoding: GraphEncoding) -> Self
Set graph encoding.
sourcepub fn execution_target(self, execution_target: ExecutionTarget) -> Self
pub fn execution_target(self, execution_target: ExecutionTarget) -> Self
Set graph execution target.
pub fn build_from_bytes<B>( self, bytes_array: impl AsRef<[B]> ) -> Result<Graph, Error>where B: AsRef<[u8]>,
pub fn build_from_files<P>(self, files: impl AsRef<[P]>) -> Result<Graph, Error>where P: AsRef<Path>,
Trait Implementations§
source§impl Clone for GraphBuilder
impl Clone for GraphBuilder
source§fn clone(&self) -> GraphBuilder
fn clone(&self) -> GraphBuilder
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for GraphBuilder
impl Debug for GraphBuilder
Auto Trait Implementations§
impl RefUnwindSafe for GraphBuilder
impl Send for GraphBuilder
impl Sync for GraphBuilder
impl Unpin for GraphBuilder
impl UnwindSafe for GraphBuilder
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