Struct CallableOptions

Source
pub struct CallableOptions {
    pub feed: Vec<String>,
    pub fetch: Vec<String>,
    pub target: Vec<String>,
    pub run_options: Option<RunOptions>,
    pub tensor_connection: Vec<TensorConnection>,
    pub feed_devices: HashMap<String, String>,
    pub fetch_devices: HashMap<String, String>,
    pub fetch_skip_sync: bool,
}
Expand description

Defines a subgraph in another GraphDef as a set of feed points and nodes to be fetched or executed.

Compare with the arguments to Session::Run().

Fields§

§feed: Vec<String>

Tensors to be fed in the callable. Each feed is the name of a tensor.

§fetch: Vec<String>

Fetches. A list of tensor names. The caller of the callable expects a tensor to be returned for each fetch[i] (see RunStepResponse.tensor). The order of specified fetches does not change the execution order.

§target: Vec<String>

Target Nodes. A list of node names. The named nodes will be run by the callable but their outputs will not be returned.

§run_options: Option<RunOptions>

Options that will be applied to each run.

§tensor_connection: Vec<TensorConnection>

Tensors to be connected in the callable. Each TensorConnection denotes a pair of tensors in the graph, between which an edge will be created in the callable.

§feed_devices: HashMap<String, String>

The Tensor objects fed in the callable and fetched from the callable are expected to be backed by host (CPU) memory by default.

The options below allow changing that - feeding tensors backed by device memory, or returning tensors that are backed by device memory.

The maps below map the name of a feed/fetch tensor (which appears in ‘feed’ or ‘fetch’ fields above), to the fully qualified name of the device owning the memory backing the contents of the tensor.

For example, creating a callable with the following options:

CallableOptions { feed: “a:0” feed: “b:0”

fetch: “x:0” fetch: “y:0”

feed_devices: { “a:0”: “/job:localhost/replica:0/task:0/device:GPU:0” }

fetch_devices: { “y:0”: “/job:localhost/replica:0/task:0/device:GPU:0” } }

means that the Callable expects:

  • The first argument (“a:0”) is a Tensor backed by GPU memory.
  • The second argument (“b:0”) is a Tensor backed by host memory. and of its return values:
  • The first output (“x:0”) will be backed by host memory.
  • The second output (“y:0”) will be backed by GPU memory.

FEEDS: It is the responsibility of the caller to ensure that the memory of the fed tensors will be correctly initialized and synchronized before it is accessed by operations executed during the call to Session::RunCallable().

This is typically ensured by using the TensorFlow memory allocators (Device::GetAllocator()) to create the Tensor to be fed.

Alternatively, for CUDA-enabled GPU devices, this typically means that the operation that produced the contents of the tensor has completed, i.e., the CUDA stream has been synchronized (e.g., via cuCtxSynchronize() or cuStreamSynchronize()).

§fetch_devices: HashMap<String, String>§fetch_skip_sync: bool

By default, RunCallable() will synchronize the GPU stream before returning fetched tensors on a GPU device, to ensure that the values in those tensors have been produced. This simplifies interacting with the tensors, but potentially incurs a performance hit.

If this options is set to true, the caller is responsible for ensuring that the values in the fetched tensors have been produced before they are used. The caller can do this by invoking Device::Sync() on the underlying device(s), or by feeding the tensors back to the same Session using feed_devices with the same corresponding device name.

Trait Implementations§

Source§

impl Clone for CallableOptions

Source§

fn clone(&self) -> CallableOptions

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for CallableOptions

Source§

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

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

impl Default for CallableOptions

Source§

fn default() -> Self

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

impl Message for CallableOptions

Source§

fn encoded_len(&self) -> usize

Returns the encoded length of the message without a length delimiter.
Source§

fn clear(&mut self)

Clears the message, resetting all fields to their default.
Source§

fn encode<B>(&self, buf: &mut B) -> Result<(), EncodeError>
where B: BufMut, Self: Sized,

Encodes the message to a buffer. Read more
Source§

fn encode_length_delimited<B>(&self, buf: &mut B) -> Result<(), EncodeError>
where B: BufMut, Self: Sized,

Encodes the message with a length-delimiter to a buffer. Read more
Source§

fn decode<B>(buf: B) -> Result<Self, DecodeError>
where B: Buf, Self: Default,

Decodes an instance of the message from a buffer. Read more
Source§

fn decode_length_delimited<B>(buf: B) -> Result<Self, DecodeError>
where B: Buf, Self: Default,

Decodes a length-delimited instance of the message from the buffer.
Source§

fn merge<B>(&mut self, buf: B) -> Result<(), DecodeError>
where B: Buf, Self: Sized,

Decodes an instance of the message from a buffer, and merges it into self. Read more
Source§

fn merge_length_delimited<B>(&mut self, buf: B) -> Result<(), DecodeError>
where B: Buf, Self: Sized,

Decodes a length-delimited instance of the message from buffer, and merges it into self.
Source§

impl PartialEq for CallableOptions

Source§

fn eq(&self, other: &CallableOptions) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for CallableOptions

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.