Path: blob/master/site/en-snapshot/federated/design/backend.md
25118 views
Backend
[TOC]
A backend is the composition of a compiler and a runtime in a Context used to construct, compile, and execute an AST, meaning a backend constructs environments that evaluate an AST.
The backends package contains backends which may extend the TFF compiler and/or the TFF runtime; these extensions can be found in the corresponding backend.
If the runtime of a backend is implemented as an execution stack, then the backend can construct an ExecutionContext to provide TFF with an environemnt in which to evaluate an AST. In this case, the backend is integrating with TFF using the high-level abstraction. However, if the runtime is not implemented as an execution stack, then the backend will need to construct a Context and is integrating with TFF using the low-level abstraction.
The blue nodes are provided by TFF core.
The green, red, yellow, and purple nodes are provided by the native, mapreduce, and reference backends respectively.
The dashed nodes are provided by an external system.
The solid arrows indicate relationship and the dashed arrows indicate inheritance.
Native
The native backend composes of the TFF compiler and TFF runtime in order to compile and execute an AST in a way that is reasonably efficiant and debuggable.
Native Form
A native form is an AST that is topologically sorted into a directed acyclic graph (DAG) of TFF intrinsics with some optimizations to the dependency of those intrinsics.
Compiler
The compiler.transform_to_native_form function compiles an AST into a native form.
Runtime
The native backend does not contain backend specific extentions to the TFF runtime, instead an execution stack can be used directly.
Context
A native context is an ExecutionContext constructed with a native compiler (or no compiler) and a TFF runtime, for example:
However, there are some common configurations:
The execution_context.set_sync_local_cpp_execution_context function constructs an ExecutionContext
with a native compiler and a local execution stack.
MapReduce
The mapreduce backend contains the data structures and compiler required to construct a form that can be executed on MapReduce-like runtimes.
MapReduceForm
A forms.MapReduceForm is a data structure defining the representation of logic that can be executed on MapReduce-like runtimes. This logic is organized as a collection of TensorFlow functions, see the forms module for more information about the nature of these functions.
Compiler
The compiler module contains Building Block and TensorFlow Computation transformations required to compile an AST to a MapReduceForm.
The form_utils module contains the compiler for the MapReduce backend and constructs a MapReduceForm.
Runtime
A MapReduce runtime is not provided by TFF, instead this should be provided by an external MapReduce-like system.
Context
A MapReduce context is not provided by TFF.