View source on GitHub |
An asynchronous execution context backed by an executor_base.Executor
.
Inherits From: AsyncContext
tff.framework.AsyncExecutionContext(
executor_fn: tff.framework.ExecutorFactory
,
compiler_fn: Optional[Callable[[_Computation], object]] = None,
*,
transform_args: Optional[Callable[[object], object]] = None,
transform_result: Optional[Callable[[object], object]] = None,
cardinality_inference_fn: cardinalities_utils.CardinalityInferenceFnType = cardinalities_utils.infer_cardinalities
)
This context's ingest
and invoke
methods return Python coroutine objects
which represent the actual work of ingestion and invocation in the backing
executor.
This context will support concurrent invocation of multiple computations if their arguments have the same cardinalities.
Attributes | |
---|---|
executor_factory
|
Methods
invoke
invoke(
comp, arg
)
Invokes computation comp
with argument arg
.
Args | |
---|---|
comp
|
The computation being invoked. The Python type of comp expected
here (e.g., pb.Computation . tff.framework.ConcreteComputation , or
other) may depend on the context. It is the responsibility of the
concrete implementation of this interface to verify that the type of
comp matches what the context is expecting.
|
arg
|
The argument passed to the computation. If no argument is passed,
this will be None . Structural argument types will be normalized into
tff.structure.Struct s.
|
Returns | |
---|---|
The result of invocation, which is context-dependent. |