pub struct Profiler { /* private fields */ }Expand description
Collects per-op timing events during TFLite inference.
Created via Profiler::new, attached to an interpreter via
InterpreterBuilder::profiler,
then events are read after
Interpreter::invoke.
The Profiler must outlive the Interpreter it
is attached to. This is guaranteed when the Profiler is declared
before the Interpreter in the same scope, or when it is stored in a
longer-lived struct.
§Example
use edgefirst_tflite::{Library, Model, Interpreter, Profiler};
let lib = Library::new()?;
let model = Model::from_file(&lib, "model.tflite")?;
let profiler = Profiler::new();
let mut interp = Interpreter::builder(&lib)?
.profiler(&profiler)?
.build(&model)?;
interp.invoke()?;
for event in profiler.events() {
println!("{}: {}us", event.op_name, event.duration_us);
}Implementations§
Source§impl Profiler
impl Profiler
Sourcepub fn events(&self) -> Vec<OpEvent>
pub fn events(&self) -> Vec<OpEvent>
Get a snapshot of all collected events since the last drain or clear.
Sourcepub fn drain_events(&self) -> Vec<OpEvent>
pub fn drain_events(&self) -> Vec<OpEvent>
Drain and return all collected events, leaving the internal list empty.
Sourcepub fn event_count(&self) -> usize
pub fn event_count(&self) -> usize
Returns the number of completed events collected so far.
Trait Implementations§
impl Send for Profiler
impl Sync for Profiler
Auto Trait Implementations§
impl Freeze for Profiler
impl RefUnwindSafe for Profiler
impl Unpin for Profiler
impl UnsafeUnpin for Profiler
impl UnwindSafe for Profiler
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