![]() |
An executor for handling federated types and intrinsics.
Inherits From: Executor
tff.framework.FederatingExecutor(
strategy_factory: Callable[['FederatingExecutor'], FederatingStrategy],
unplaced_executor: tff.framework.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.
Methods
close
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
create_call(
comp, arg=None
)
Creates an embedded call for the given comp
and optional arg
.
The kinds of supported comp
s are:
- An instance of
pb.Computation
if of one of the following kinds: tensorflow, xla. - 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_signature s of comp and arg are not compatible.
|
ValueError
|
If comp is not a kind supported by the FederatingExecutor .
|
create_selection
create_selection(
source, index
)
Creates an embedded selection from the given source
.
The kinds of supported source
s are:
- An embedded value.
- An instance of
structure.Struct
.
Args | |
---|---|
source
|
An embedded computation with a tuple type signature representing the source from which to make a selection. |
index
|
An integer index. |
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
create_struct(
elements
)
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
create_value(
value, type_spec=None
)
Creates an embedded value from the given value
and type_spec
.
The kinds of supported value
s are:
An instance of
intrinsic_defs.IntrinsicDef
.An instance of
placements.PlacementLiteral
.An instance of
pb.Computation
if of one of the following kinds: intrinsic, lambda, tensorflow, xla, or data.A Python
list
iftype_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 .
|