![]() |
Implementation of executor factory holding an executor per cardinality.
Inherits From: ExecutorFactory
tff.framework.ResourceManagingExecutorFactory(
executor_stack_fn: Callable[[tff.framework.CardinalitiesType
], tff.framework.Executor
],
ensure_closed: Optional[Sequence[executor_base.Executor]] = None
)
Args | |
---|---|
executor_stack_fn
|
Callable taking a mapping from
placements.PlacementLiteral to integers, and returning an
executor_base.Executor . The returned executor will be configured to
handle these cardinalities.
|
ensure_closed
|
Optional sequence of executor_base.Excutors which should
always be closed on a clean_up_executors call. Defaults to empty.
|
Methods
clean_up_executors
clean_up_executors()
Calls close
on all constructed executors, resetting internal cache.
If a caller holds a name bound to any of the executors returned from
create_executor
, this executor should be assumed to be in an invalid
state, and should not be used after this method is called. Instead, callers
should again invoke create_executor
.
create_executor
create_executor(
cardinalities: tff.framework.CardinalitiesType
) -> tff.framework.Executor
Constructs or gets existing executor.
Returns a previously-constructed executor if this method has already been
invoked with cardinalities
. If not, invokes self._executor_stack_fn
with cardinalities
and returns the result.
Args | |
---|---|
cardinalities
|
dict with placements.PlacementLiteral keys and integer
values, specifying the population size at each placement. The executor
stacks returned from this method are not themselves polymorphic; a
concrete stack must have fixed sizes at each placement.
|
Returns | |
---|---|
Instance of executor_base.Executor as described above.
|