|View source on GitHub|
Represents the interface to the context that the API executes against.
The interfaces in Core API may be used in a variety of contexts, such as at a compile time or at runtime, during unit tests, nested inside a body of an outer computation being defined or at the top level (not nested), and in the former case potentially nested more than one level deep, either in a general orchestration scope or in a section of TensorFlow code, as well as potentially in an undecorated regular Python function or a tfe.defun. The context of usage potentially affects some of the API, determines which subset of the API is available, and it can influence the manner in which the API calls behave. This interface abstracts out interactions between the API and the underlying context for mechanisms that are context-dependent. The API only interacts with a given current context (instance). Manipulating a context stack is the responsibility of the implementation.
ingest( val, type_spec )
Ingests value 'val' given the expected type
This function is invoked on Python call arguments and/or their constituents
to translate them into a form that can be used in the given context. This
is performed in the process of handling a computation's
bundling arguments together, and prior to calling
val: An object that represents the value to ingest in the given context.
tff.Typeof the value represented by this object.
The result of ingestion, which is context-dependent.
invoke( comp, arg )
comp with argument
Prior to calling
invoke, the argument
arg or its constituents must have
been ingested by the context by calling
comp: The computation being invoked. The Python type of
compexpected here (e.g.,
ComputationImpl, or other) may depend on the context. It is the responsibility of the concrete implementation of this interface to verify that the type of
compmatches what the context is expecting.
arg: The optional argument of the call (possibly an argument tuple with a nested structure), or
Noneif no argument was supplied. Computations accept arguments in a variety of forms, but those are first ingested by calling
ingest()above, then bundled together into a single object before calling
invoke()in the given context.
The result of invocation, which is context-dependent.