tff.framework.ResourceManagingExecutorFactory

Implementation of executor factory holding an executor per cardinality.

Inherits From: ExecutorFactory

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.

Methods

clean_up_executor

View source

Calls close on constructed executors, resetting internal cache.

If a caller holds a name bound to any of the executors returned from create_executor with the specified cardinalities, 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.

Args
cardinalities The cardinalities of the executor to be cleaned up.

create_executor

View source

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.