|
| 1 | +# `tf.backend` |
| 2 | + |
| 3 | +| Status | Proposed | |
| 4 | +| :------------ | :------------------------------------------------------ | |
| 5 | +| **Author ** | [email protected] | |
| 6 | +| **Sponsor ** | [email protected] | |
| 7 | +| **Updated** | 2018-12-25 | |
| 8 | + |
| 9 | +## Objective |
| 10 | + |
| 11 | +Expose a `tf.backend` namespace containing all raw operations in TensorFlow. |
| 12 | + |
| 13 | +## Motivation |
| 14 | + |
| 15 | +Some parts of the TensorFlow Python API, such as variables, optimizers, and |
| 16 | +control flow, are currently not implementable by third parties. Moreover, with |
| 17 | +the tf.contrib deprecation, there is now no valid Python endpoint from which to |
| 18 | +use many TF operations. |
| 19 | + |
| 20 | +## Design Proposal |
| 21 | + |
| 22 | +We'll add a `tf.backend` namespace to TensorFlow with Python bindings to all |
| 23 | +non-deprecated TensorFlow ops which is usable in a backwards-compatible |
| 24 | +way. This is designed to be consumed by downstream library writers and not end |
| 25 | +users (in this way it's similar to `tf.keras.backend`, from which it gets its |
| 26 | +name). |
| 27 | + |
| 28 | +## Detailed Design |
| 29 | + |
| 30 | +The namespace will be automatically populated with generated bindings for every |
| 31 | +operation in TensorFlow. These generated bindings will be similar to the ones |
| 32 | +currently used for the python API, with the following differences: |
| 33 | + |
| 34 | +* All arguments are keyword arguments. |
| 35 | + - This allows us to add new attributes to existing ops without breaking users |
| 36 | + who call by positional arguments (given that there is an always-last `name` |
| 37 | + argument added by the tf op binding generator). |
| 38 | + - This also prevents users from assuming that calling conventions from the |
| 39 | + existing python bindings apply to the backend versions (we often do argument |
| 40 | + reordering in our python bindings, for example). |
| 41 | +* Any op marked as deprecated will be in the namespace but will raise an |
| 42 | + exception when used. |
| 43 | + - This includes ops which take or produce ref tensors. |
| 44 | + - This allows us to deprecate ops eventually and to be less strict with the API |
| 45 | + here than with the main API. |
| 46 | + - This is mostly OK since only library writers are supposed to use these |
| 47 | + symbols, and the deprecation messages should include upgrading instructions. |
| 48 | + |
| 49 | + |
| 50 | +## Questions and Discussion Topics |
| 51 | + |
| 52 | +* Naming: is tf.backend the best name we can have for this? |
| 53 | +* Backward compatibility policy: is it acceptable to have a subnamespace with a |
| 54 | +different compatibility guarantee? |
| 55 | +* Flat namespace vs nested? Currently the TF ops are loosely grouped in |
| 56 | + `gen_*_ops.py` files; is it worth to preserve this grouping here? |
0 commit comments