pub struct SessionRunArgs<'l> { /* private fields */ }
Expand description

Manages the inputs and outputs for a single execution of a graph.

Typical usage involves creating an instance of this struct, adding some inputs to it, requesting some outputs, passing it to Session::run and then taking the outputs out of it.

Example:

let mut args = SessionRunArgs::new();
args.add_feed(&op1, 0, &tensor1);
args.add_feed(&op2, 0, &tensor2);
let result_token = args.request_fetch(&op3, 0);
session.run(&mut args)?;
let result_tensor = args.fetch(result_token)?;

See examples/addition.rs for a more concrete example.

Implementations§

source§

impl<'l> SessionRunArgs<'l>

source

pub fn new() -> Self

Creates a SessionRunArgs.

source

pub fn add_feed<T: TensorType>( &mut self, operation: &Operation, index: c_int, tensor: &'l Tensor<T> )

Adds an input to be fed to the graph. The index selects which output of the operation to feed. For most operations, there is only one output, so the index should be 0.

source

pub fn add_input<T: TensorType>( &mut self, operation: &Operation, index: c_int, tensor: &'l Tensor<T> )

👎Deprecated since 0.10.0: Use add_feed instead.

Deprecated alias for add_feed.

source

pub fn request_fetch( &mut self, operation: &Operation, index: c_int ) -> FetchToken

Requests that an output is fetched from the graph after running this step. The index selects which output of the operation to return. For most operations, there is only one output, so the index should be 0. Returns a token that you can then use to fetch this output from the args after running it.

source

pub fn request_output( &mut self, operation: &Operation, index: c_int ) -> OutputToken

👎Deprecated since 0.10.0: Use request_fetch instead.

Deprecated alias for request_fetch.

source

pub fn fetch<T: TensorType>(&mut self, token: FetchToken) -> Result<Tensor<T>>

Extracts a tensor output given a token. A given token can only be extracted once per Session::run. Returns an error if the token is invalid, output is unavailable or the requested type does not match the type of the actual tensor.

source

pub fn take_output<T: TensorType>( &mut self, token: OutputToken ) -> Result<Tensor<T>>

👎Deprecated since 0.10.0: Use fetch instead.

Deprecated alias for fetch.

source

pub fn add_target(&mut self, operation: &Operation)

Adds a target operation to be executed when running the graph.

source

pub fn output_data_type(&self, output_idx: usize) -> Option<DataType>

Retuns the type of the tensor given an index. Returns None if the index is out of range or the output is not yet available.

source

pub fn set_run_options(&mut self, run_options: &[u8])

Sets the RunOptions. run_options is a serialized RunOptions proto.

source

pub fn get_run_options(&self) -> Option<&[u8]>

Returns the serialized RunOptions proto Returns none if RunOption are not set.

source

pub fn get_metadata(&mut self) -> Option<&[u8]>

Returns the serialized RunMetadata proto Returns none if self::set_request_metadata is not set to true.

source

pub fn set_request_metadata(&mut self, request: bool)

Requests run_metadata. The serialized RunMetadata proto can be retrieved via self::get_metadata after calling Session::run.

source

pub fn is_request_metadata(&self) -> bool

Returns whether RunMetadata should be stored.

Trait Implementations§

source§

impl<'l> Debug for SessionRunArgs<'l>

source§

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

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

impl<'l> Default for SessionRunArgs<'l>

source§

fn default() -> Self

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

impl<'l> Drop for SessionRunArgs<'l>

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl<'l> Send for SessionRunArgs<'l>

source§

impl<'l> Sync for SessionRunArgs<'l>

Auto Trait Implementations§

§

impl<'l> !RefUnwindSafe for SessionRunArgs<'l>

§

impl<'l> Unpin for SessionRunArgs<'l>

§

impl<'l> !UnwindSafe for SessionRunArgs<'l>

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.