|
| 1 | +# tf.internal API namespace |
| 2 | + |
| 3 | +| Status | Proposed | |
| 4 | +:-------------- |:---------------------------------------------------- | |
| 5 | +| **RFC #** | [NNN](https://github.com/tensorflow/community/pull/NNN) (update when you have community PR #)| |
| 6 | +| **Author(s) ** | Qianli Zhu ( [email protected]) | |
| 7 | +| **Sponsor ** | Martin Wicke ( [email protected]), Alex Apassos ( [email protected]) | |
| 8 | +| **Updated** | 2020-08-10 | |
| 9 | +| **Intended audience**| tf-api-owners, tf-addons, keras-team, deepmind/sonnet| |
| 10 | + |
| 11 | +## Objective |
| 12 | + |
| 13 | +Adding a new "internal" API namespace in TF to host APIs for framework building/testing, etc. The API will have looser contracts compared to core TF API. |
| 14 | + |
| 15 | +## Motivation |
| 16 | + |
| 17 | +TensorFlow has a strong contract to ensure the stability of its API. The core |
| 18 | +API, once added, can't be updated with backward incompatible change or removed. |
| 19 | +TF API owners will pay extra attention to any new API proposal due to this |
| 20 | +restriction, based on the cost we have to bear to maintain the API |
| 21 | +compatibility. See more details about API review |
| 22 | +[here](https://github.com/tensorflow/community/blob/master/governance/api-reviews.md). |
| 23 | + |
| 24 | +Keras team is trying to split its code into a [standalone Github repository](https://github.com/tensorflow/community/blob/master/rfcs/20200205-standalone-keras-repository.md). |
| 25 | +One of the key actions before the repository split is that Keras code has to |
| 26 | +rely on the public TF API only, to avoid any future breakages due to private |
| 27 | +method/class change. |
| 28 | + |
| 29 | +Historically, Keras was an internal component of TF, and relies heavily on a lot |
| 30 | +of private TF utilities and functionalities that are not part of the public API. |
| 31 | +Exposing those functions into public APIs will be very confusing to the end |
| 32 | +user, since those functions are useful to framework-builders, but not typical |
| 33 | +TensorFlow users. In addition, these utilities would be overly restricted by the |
| 34 | +standard TensorFlow API contract, as we would like to change/remove them more |
| 35 | +often than the existing core API. |
| 36 | + |
| 37 | + |
| 38 | +## Design Proposal |
| 39 | + |
| 40 | +Add a new namespace "tensorflow.internal" to host the framework building/testing |
| 41 | +related APIs. <b>(See alternative naming in the sections below, the naming of |
| 42 | +the namespace will be discussed in the design meeting.)</b> |
| 43 | + |
| 44 | +### Backward compatibility |
| 45 | +The contract for all the APIs under this namespace is looser compared to core TF |
| 46 | +API. It will remain backward compatible for at least 1 minor TF release. |
| 47 | + |
| 48 | +This means for any API that is added in 2.x release, it will remain the same in |
| 49 | +2.x+1. If we choose to remove the same API, we will mark it as deprecated in |
| 50 | +2.x+1, and delete it at 2.x+2 release. TensorFlow is released every 3 months, |
| 51 | +and this will give enough time for all the clients to change to the new |
| 52 | +API/alternative. |
| 53 | + |
| 54 | +Any deprecation and backward incompatible API change will be explicitly called |
| 55 | +out in TF release notes. This applies to both core API and "internal" API. |
| 56 | + |
| 57 | +### Acceptance Criteria |
| 58 | +The candidate of the "internal" API should: |
| 59 | + |
| 60 | +1. Does NOT fit for core TF API, otherwise it should be exposed as core TF API. |
| 61 | +1. Are effectively required to build/test/deploy a framework or library on top |
| 62 | + of TensorFlow, or to integrate such a framework into TensorFlow's API. |
| 63 | +1. Mature enough and won't change behavior/interface for every release. |
| 64 | +1. Non-trivial, otherwise the function should be copied to the client side. |
| 65 | +1. Widely used in the implementation of TF public APIs (i.e. new functionality |
| 66 | + isn’t immediately added to the tf.internal namespace) |
| 67 | +1. Has at least two downstream libraries which are known to need it. |
| 68 | + |
| 69 | +TF API owners will review the new API proposal, and follow the existing review |
| 70 | +process for core TF API. |
| 71 | + |
| 72 | + |
| 73 | +### Documentation and Docstring |
| 74 | +The "internal" API should have the same style and standard as the core |
| 75 | +TensorFlow API, which is documented [here](https://github.com/tensorflow/community/blob/master/governance/api-reviews.md#docstrings). |
| 76 | +We should explicitly list out the difference between "internal" API and core |
| 77 | +API, and also choose a different place on tensorflow.org so that existing user |
| 78 | +are not confused. |
| 79 | + |
| 80 | +### Naming and sub namespace |
| 81 | +Similar "internal" APIs should be grouped together as sub namespaces, e.g., test |
| 82 | +related APIs should live under "tf.internal.test". This is aligned with the |
| 83 | +existing TF naming conversion. |
| 84 | + |
| 85 | +Try not to export experimental APIs since the "internal" API should be mature |
| 86 | +enough. |
| 87 | + |
| 88 | +### Current candidate |
| 89 | +The following list is created from the private TF method usage within Keras, |
| 90 | +when we were trying to convert Keras to use the public TF API only. This is by |
| 91 | +no means the full list, but will serve as the first wave of review requests we |
| 92 | +send to the API owner for review. We don't expect all of them to be approved, |
| 93 | +and will discuss with the API owner on a case to case basis. |
| 94 | + |
| 95 | +|Symbol location |API Name | |
| 96 | +:-------------- |:---------------------------------------------------- | |
| 97 | +|python.framework.func_graph.FuncGraph |tf.internal.FuncGraph | |
| 98 | +|python.framework.combinations.*| tf.internal.test.combinations.* | |
| 99 | +|python.distribute.strategy_combinations.* |tf.internal.test.combinations.* | |
| 100 | +|python.training.tracking.base.no_automatic_dependency_tracking|tf.internal.tracking.no_automatic_dependency_tracking | |
| 101 | +|python.util.object_identity.*|tf.internal.object_identity.* | |
| 102 | +|python.util.tf_decorator.*|tf.internal.decorator.* | |
| 103 | +|python.util.tf_inspect.*|tf.internal.inspect.* | |
| 104 | + |
| 105 | +### Alternative Names |
| 106 | +1. <b>"tf.internal"</b>: It gives the user the impression that this is not a |
| 107 | + standard user facing API (good), and contains some private/implementation |
| 108 | + details that are internal to TF. |
| 109 | +1. <b>"tf.infra"</b>: infrastructure is aligned with "building blocks" and low |
| 110 | + level functionalities, like file system/network etc. So far, the APIs we want |
| 111 | + to add are still high level APIs and utility functions. |
| 112 | +1. By Martin <b>"tf._internal"</b>: the extra "_" emphasis in the pythonic way |
| 113 | + that this is for private usage. |
| 114 | + |
| 115 | + |
| 116 | +## Questions and Discussion Topics |
| 117 | + |
| 118 | +1. Naming of the API namespace. |
| 119 | + |
0 commit comments