Skip to main content

GraphExecutor

Struct GraphExecutor 

Source
pub struct GraphExecutor { /* private fields */ }
Expand description

Batched Metal dispatch — encodes multiple ops into a single CommandEncoder.

Create one per model (or per forward-pass loop). Call begin at the start of each forward pass to get a GraphSession that holds the shared encoder.

Implementations§

Source§

impl GraphExecutor

Source

pub fn new(device: MlxDevice) -> Self

Create a new graph executor backed by the given device.

Source

pub fn begin(&self) -> Result<GraphSession<'_>>

Begin a new forward pass (direct-dispatch mode).

Returns a GraphSession that holds a fresh CommandEncoder. All ops encoded through the session share this single encoder. Call GraphSession::finish to commit and wait.

Source

pub fn begin_recorded(&self) -> Result<GraphSession<'_>>

Begin a new forward pass in capture (record) mode.

All op calls are recorded into a ComputeGraph instead of being dispatched to Metal. When GraphSession::finish is called, the recorded graph is replayed into a fresh encoder via ComputeGraph::encode_sequential().

The API is identical to begin() — callers do not need to change any op call code. The only behavioral difference: GPU work happens at finish() time rather than at each op call.

Source

pub fn device(&self) -> &MlxDevice

Borrow the underlying device.

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.