pub struct Interpreter<'lib> { /* private fields */ }Expand description
TFLite inference engine.
Owns its delegates and provides access to input/output tensors.
Created via Interpreter::builder.
Implementations§
Source§impl<'lib> Interpreter<'lib>
impl<'lib> Interpreter<'lib>
Sourcepub fn builder(lib: &'lib Library) -> Result<InterpreterBuilder<'lib>>
pub fn builder(lib: &'lib Library) -> Result<InterpreterBuilder<'lib>>
Create a new InterpreterBuilder for configuring an interpreter.
§Errors
Returns an error if TfLiteInterpreterOptionsCreate returns null.
Sourcepub fn allocate_tensors(&mut self) -> Result<()>
pub fn allocate_tensors(&mut self) -> Result<()>
Re-allocate tensors after an input resize.
This must be called after Interpreter::resize_input and before
Interpreter::invoke. Any previously obtained tensor slices or
pointers are invalidated.
§Errors
Returns an error if the C API returns a non-OK status.
Sourcepub fn resize_input(&mut self, input_index: usize, shape: &[i32]) -> Result<()>
pub fn resize_input(&mut self, input_index: usize, shape: &[i32]) -> Result<()>
Resize an input tensor’s dimensions.
After resizing, Interpreter::allocate_tensors must be called
before inference can proceed.
§Errors
Returns an error if the C API returns a non-OK status (e.g., the input index is out of range).
Sourcepub fn inputs(&self) -> Result<Vec<Tensor<'_>>>
pub fn inputs(&self) -> Result<Vec<Tensor<'_>>>
Get immutable views of all input tensors.
§Errors
Returns an error if any input tensor pointer is null.
Sourcepub fn inputs_mut(&mut self) -> Result<Vec<TensorMut<'_>>>
pub fn inputs_mut(&mut self) -> Result<Vec<TensorMut<'_>>>
Get mutable views of all input tensors.
§Errors
Returns an error if any input tensor pointer is null.
Sourcepub fn outputs(&self) -> Result<Vec<Tensor<'_>>>
pub fn outputs(&self) -> Result<Vec<Tensor<'_>>>
Get immutable views of all output tensors.
§Errors
Returns an error if any output tensor pointer is null.
Sourcepub fn input_count(&self) -> usize
pub fn input_count(&self) -> usize
Returns the number of input tensors.
Sourcepub fn output_count(&self) -> usize
pub fn output_count(&self) -> usize
Returns the number of output tensors.