tff.framework.EagerTFExecutor

The eager executor only runs TensorFlow, synchronously, in eager mode.

This executor understands the following TFF types: tensors, sequences, named tuples, and functions. It does not understand placements, federated, or abstract types.

This executor understands the following kinds of TFF computation building blocks: tensorflow computations, and external data. It does not understand lambda calculus or any compositional constructs. Tuples and selections can only be created using create_struct() and create_selection() in the API.

The arguments to be ingested can be Python constants of simple types, nested structures of those, as well as eager tensors and eager datasets.

The external data references must identify files available in the executor's filesystem. The exact format is yet to be documented.

The executor will be able to place work on specific devices (e.g., on GPUs). In contrast to the reference executor, it handles data sets in a pipelined fashion, and does not place limits on the data set sizes. It also avoids marshaling TensorFlow values in and out between calls.

It does not deal with multithreading, checkpointing, federated computations, and other concerns to be covered by separate executor components. It runs the operations it supports in a synchronous fashion. Asynchrony and other aspects not supported here should be handled by composing this executor with other executors into a complex executor stack, rather than mixing in all the logic.

One further implementation detail is worth noting. Like all executors, this executor embeds incoming data as an instance of an executor-specific class, here the EagerValue. All EagerValues are assumed in this implmentation to have an reference which is a fixed point under the action of to_representation_for_type with type the type_signature attribute of the EagerValue. This invariant is introduced by normalization in create_value, and is respected by the form of returned EagerValues in all other methods this executor exposes.

device An optional tf.config.LogicalDevice that this executor will schedule all of its operations to run on. For example, the list of logical devices can be obtained using tf.config.list_logical_devices().

RuntimeError If not executing eagerly.
TypeError If the device is not a tf.config.LogicalDevice.
ValueError If there is no device device.

Methods

close

View source

Release resources associated with this Executor, if any.

If the executor has one or more target Executors, implementation of this method must close them.

create_call

View source

Creates a call to comp with optional arg.

Args
comp As documented in executor_base.Executor.
arg As documented in executor_base.Executor.

Returns
An instance of EagerValue representing the result of the call.

Raises
RuntimeError If not executing eagerly.
TypeError If the arguments are of the wrong types.

create_selection

View source

Creates a selection from source.

Args
source As documented in executor_base.Executor.
index As documented in executor_base.Executor.

Returns
An instance of EagerValue that represents the constructed selection.

Raises
TypeError If arguments are of the wrong types.
ValueError If either both, or neither of name and index are present.

create_struct

View source

Creates a tuple of elements.

Args
elements As documented in executor_base.Executor.

Returns
An instance of EagerValue that represents the constructed tuple.

create_value

View source

Embeds value of type type_spec within this executor.

create_value first normalizes its incoming value arguments via to_representation_for_type, establishing the invariant that every value embedded in this executor would no-op under the action of to_representation_for_type. This invariant is then preserved and assumed by the remainder of the methods exposed by the executor.

Args
value An object that represents the value to embed within the executor.
type_spec The tff.Type of the value represented by this object, or something convertible to it. Can optionally be None if value is an instance of typed_object.TypedObject.

Returns
An instance of EagerValue.

Raises
RuntimeError If not executing eagerly.
TypeError If the arguments are of the wrong types.
ValueError If the type was not specified and cannot be determined from the value.