Path: blob/master/site/en-snapshot/federated/design/life_of_a_computation.md
25118 views
Life of a Computation
[TOC]
Executing a Python function in TFF
This example is meant to highlight how a Python function becomes a TFF computation and how the computation is evaluated by TFF.
From a users perspective:
Write a Python function.
Decorate the Python function with
@tff.tf_computation
.Note: For now, it is only important that the Python function is decorated not the specifics of the decorator itself; this is explained in more detail below.
Set a TFF context.
Invoke the Python function.
From a TFF perspective:
When the Python is parsed, the @tff.tf_computation
decorator will trace the Python function and construct a TFF computation.
When the decorated Python function is invoked, it is the TFF computation which is invoked and TFF will compile and execute the computation in the context that was set.
TF vs TFF vs Python
TODO: b/153500547 - Describe TF vs TFF vs Python example.