Skip to main content

Profiler

Struct Profiler 

Source
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

Source

pub fn new() -> Self

Create a new profiler ready to be attached to an interpreter.

Source

pub fn events(&self) -> Vec<OpEvent>

Get a snapshot of all collected events since the last drain or clear.

Source

pub fn drain_events(&self) -> Vec<OpEvent>

Drain and return all collected events, leaving the internal list empty.

Source

pub fn clear(&self)

Clear all collected events without returning them.

Source

pub fn event_count(&self) -> usize

Returns the number of completed events collected so far.

Trait Implementations§

Source§

impl Debug for Profiler

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Profiler

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Drop for Profiler

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl Send for Profiler

Source§

impl Sync for Profiler

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.