tff.framework.ContextStack

An interface to a context stack for the API to run against.

current Returns the current context (one at the top of the context stack).

Methods

install

View source

A context manager that temporarily installs a new context on the stack.

The installed context is placed at the top on the stack while in the context manager's scope, and remove from the stack upon exiting the scope. This method should only be used by the implementation code, and by the unit tests for dependency injection.

Args
ctx The context to temporarily install at the top of the context stack, an instance of Context defined in context_base.py.

Yields
The installed context.

Raises
TypeError If ctx is not a valid instance of tff.framework.AsyncContext or tff.framework.SyncContext.