tff.framework.FederatingExecutor

An executor for handling federated types and intrinsics.

Inherits From: Executor

At a high-level, this executor is responsible for handling federated types and federated intrinsics and delegating work to an underlying collection of target executors associated with individual placements.

The responsibility for handling federated types and federated intrinsics is delegated to a FederatingStrategy, specifically:

  • which federated intrinsics are implemented
  • how federated types and federated intrinsics are implemented
  • how federated values are represented in the execution stack
  • how work is delegated to the target executors
  • which placements are implemented

The reponsibility for handling unplaced types, computations, and processing is delegated to an unplaced_executor.

Expressed in a different way, this executor integrates a FederatedStrategy with an execution stack, providing a way to inject the logic for handling federated types and intrinsics into the execution stack.

strategy_factory A function that accepts an instance of a FederatingExecutor and returns a newly constructed FederatingStrategy to use to handle federated types and intrinsics.
unplaced_executor An executor_base.Executor to use to handle unplaced types, computations, and processing.

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 an embedded call for the given comp and optional arg.

The kinds of supported comps are:

  • An instance of pb.Computation if of one of the following kinds: tensorflow.
  • An instance of intrinsic_defs.IntrinsicDef.

Args
comp An embedded computation with a functional type signature representing the function of the call.
arg An optional embedded argument of the call, or None if no argument is supplied.

Returns
An instance of executor_value_base.ExecutorValue representing the embedded call.

Raises
TypeError If comp or arg are not embedded in the executor; if the type_signature of comp is not tff.FunctionType; or if the type_signatures of comp and arg are not compatible.
ValueError If comp is not a kind supported by the FederatingExecutor.

create_selection

View source

Creates an embedded selection from the given source.

The kinds of supported sources are:

Args
source An embedded computation with a tuple type signature representing the source from which to make a selection.
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 executor_value_base.ExecutorValue representing the embedded selection.

Raises
TypeError If source is not embedded in the executor or if the type_signature of source is not a tff.StructType.
ValueError If both index and name are None or if source is not a kind supported by the FederatingExecutor.

create_struct

View source

Creates an embedded tuple of the given elements.

Args
elements A collection of embedded values.

Returns
An instance of executor_value_base.ExecutorValue representing the embedded tuple.

Raises
TypeError If the elements are not embedded in the executor.

create_value

View source

Creates an embedded value from the given value and type_spec.

The kinds of supported values are:

  • An instance of intrinsic_defs.IntrinsicDef.

  • An instance of placement_literals.PlacementLiteral.

  • An instance of pb.Computation if of one of the following kinds: intrinsic, lambda, and tensorflow.

  • A Python list if type_spec is a federated type.

  • A Python value if type_spec is a non-functional, non-federated type.

Args
value An object to embed in the executor, one of the supported types defined by above.
type_spec An optional type convertible to instance of tff.Type via tff.to_type, the type of value.

Returns
An instance of executor_value_base.ExecutorValue representing a value embedded in the FederatingExecutor using a particular FederatingStrategy.

Raises
TypeError If the value and type_spec do not match.
ValueError If value is not a kind supported by the FederatingExecutor.