Missed TensorFlow Dev Summit? Check out the video playlist. Watch recordings

tff.framework.TransformingExecutor

View source on GitHub

This executor transforms computations prior to executing them.

Inherits From: Executor

tff.framework.TransformingExecutor(
    transformation_fn, target_executor
)

This executor only performs transformations. All other aspects of execution are delegated to the underlying target executor.

Args:

  • transformation_fn: A callable that accepts as single parameter that is an instance of tff.framework.ComputationBuildingBlock, and returns a result of the same type. This callable is used to transform any kind of computations before they are relayed to the target executor.
  • target_executor: The target executor to delegate all the execution to.

Methods

close

View source

close()

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

create_call(
    comp, arg=None
)

A coroutine that creates a call to comp with optional argument arg.

Args:

  • comp: The computation to invoke. It must have been first embedded in the executor by calling create_value() on it first.
  • arg: An optional argument of the call, or None if no argument was supplied. If it is present, it must have been embedded in the executor by calling create_value() on it first.

Returns:

An instance of ExecutorValue that represents the constructed vall.

create_selection

View source

create_selection(
    source, index=None, name=None
)

A coroutine that creates a selection from source.

Args:

  • source: The source to select from. The source must have been embedded in this executor by invoking create_value() on it first.
  • index: An optional integer index. Either this, or name must be present.
  • name: An optional string name. Either this, or index must be present.

Returns:

An instance of ExecutorValue that represents the constructed selection.

create_tuple

View source

create_tuple(
    elements
)

A coroutine that creates a tuple of elements.

Args:

  • elements: A collection of ExecutorValues to create a tuple from. The collection may be of any kind accepted by anonymous_tuple.from_container, including dictionaries and lists. The ExecutorValues in the container must have been created by calling create_value on this executor.

Returns:

An instance of ExecutorValue that represents the constructed tuple.

create_value

View source

create_value(
    value, type_spec=None
)

A coroutine that creates embedded value from value of type type_spec.

This function is used to embed a value within the executor. The argument can be one of the plain Python types, a nested structure, a representation of a TFF computation, etc. Once embedded, the value can be further passed around within the executor. For functional values, embedding them prior to invocation potentially allows the executor to amortize overhead across multiple calls.

Args:

  • value: An object that represents the value to embed within the executor.
  • type_spec: An optional tff.Type of the value represented by this object, or something convertible to it. The type can only be omitted if the value is a instance of tff.TypedObject.

Returns:

An instance of ExecutorValue that represents the embedded value.