pub struct Executor<B: Backend> { /* private fields */ }Expand description
Executes IrProgram graphs on the Shrew tensor runtime.
Implementations§
Source§impl<B: Backend> Executor<B>
impl<B: Backend> Executor<B>
Sourcepub fn new(
program: IrProgram,
device: B::Device,
config: RuntimeConfig,
) -> Result<Self>
pub fn new( program: IrProgram, device: B::Device, config: RuntimeConfig, ) -> Result<Self>
Create a new executor. Initializes all parameters.
Sourcepub fn config(&self) -> &RuntimeConfig
pub fn config(&self) -> &RuntimeConfig
Get a reference to the runtime config.
Sourcepub fn config_mut(&mut self) -> &mut RuntimeConfig
pub fn config_mut(&mut self) -> &mut RuntimeConfig
Get a mutable reference to the runtime config.
Sourcepub fn all_params(&self) -> Vec<Tensor<B>>
pub fn all_params(&self) -> Vec<Tensor<B>>
Get flattened parameter list (all graphs).
Sourcepub fn named_params(&self) -> Vec<(String, Tensor<B>)>
pub fn named_params(&self) -> Vec<(String, Tensor<B>)>
Get all parameters as (key, tensor) pairs, where key = "graph/param".
Sourcepub fn set_param_by_key(&mut self, key: &str, tensor: Tensor<B>) -> bool
pub fn set_param_by_key(&mut self, key: &str, tensor: Tensor<B>) -> bool
Set a parameter by its "graph/param" key. Returns true if found.
Sourcepub fn run(
&self,
graph_name: &str,
inputs: &HashMap<String, Tensor<B>>,
) -> Result<ExecResult<B>>
pub fn run( &self, graph_name: &str, inputs: &HashMap<String, Tensor<B>>, ) -> Result<ExecResult<B>>
Execute a named graph with given inputs.
Sourcepub fn update_params(&mut self, graph_name: &str, new_params: &[Tensor<B>])
pub fn update_params(&mut self, graph_name: &str, new_params: &[Tensor<B>])
Update parameters after an optimizer step.
Sourcepub fn graph_params(&self, graph_name: &str) -> Vec<Tensor<B>>
pub fn graph_params(&self, graph_name: &str) -> Vec<Tensor<B>>
Collect parameters for a specific graph (for optimizer).
Auto Trait Implementations§
impl<B> Freeze for Executor<B>
impl<B> RefUnwindSafe for Executor<B>
impl<B> Send for Executor<B>
impl<B> Sync for Executor<B>
impl<B> Unpin for Executor<B>
impl<B> UnwindSafe for Executor<B>
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more