![]() |
ExecutorFactory exposing hook to construct executors on environment change.
Inherits From: ExecutorFactory
tff.framework.ReconstructOnChangeExecutorFactory(
underlying_stack: tff.framework.ExecutorFactory
,
ensure_closed: Optional[Sequence[executor_base.Executor]] = None,
change_query: Callable[[executor_factory.CardinalitiesType], bool] = (lambda _: True)
)
When the initialization parameter change_query
returns True
,
ReconstructOnChangeExecutorFactory` constructs a new executor, bypassing
any previously constructed executors.
Methods
clean_up_executors
clean_up_executors()
Releases any resources held by the factory.
Note that calling this method may invalidate the state of any executors
which have previously been returned by the factory; create_executor
should be called again if a new executor which is safe to use is desired.
create_executor
create_executor(
cardinalities: executor_factory.CardinalitiesType
) -> tff.framework.Executor
Returns a new or existing executor, depending on change_query
.
create_executor
constructs a new executor whenever change_query
returns
True
when called with argument cardinalities
. If change_query
returns
False
, create_executor
is free to inspect its internal executor cache
and return a previously constructed executor if one is available.
Args | |
---|---|
cardinalities
|
A mapping from placement literals to ints. |
Returns | |
---|---|
An executor_base.Executor obeying the semantics above.
|