Skip to content
This repository was archived by the owner on Jul 10, 2025. It is now read-only.

Commit abac309

Browse files
author
ematejska
authored
Merge pull request #278 from qlzh727/tf-internal-api
RFC: tf.__internal__ API namespace.
2 parents af5d62f + a2f84c3 commit abac309

File tree

1 file changed

+114
-0
lines changed

1 file changed

+114
-0
lines changed

rfcs/20200810-tf-internal-api.md

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
# tf._internal API namespace
2+
3+
| Status | Accepted |
4+
:-------------- |:---------------------------------------------------- |
5+
| **RFC #** | [278](https://github.com/tensorflow/community/pull/278)|
6+
| **Author(s)** | Qianli Zhu ([email protected]) |
7+
| **Sponsor** | Martin Wicke ([email protected]), Alex Passos ([email protected])|
8+
| **Updated** | 2020-08-10 |
9+
| **Intended audience**| tf-api-owners, keras-team|
10+
11+
## Objective
12+
13+
Adding a new "_internal" API namespace in TF to host APIs for framework building
14+
/testing, etc. The API namespace will serve as a whitelist for client libraries
15+
to gradually migrate off the usage tf private API symbol.
16+
17+
18+
## Motivation
19+
20+
TensorFlow has a strong contract to ensure the stability of its API. The core
21+
API, once added, can't be updated with backward incompatible change or removed.
22+
TF API owners will pay extra attention to any new API proposal due to this
23+
restriction, based on the cost we have to bear to maintain the API
24+
compatibility. See more details about API review
25+
[here](https://github.com/tensorflow/community/blob/master/governance/api-reviews.md).
26+
27+
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).
28+
One of the key actions before the repository split is that Keras code has to
29+
rely on the public TF API only, to avoid any future breakages due to private
30+
method/class change.
31+
32+
Historically, Keras was an internal component of TF, and relies heavily on a lot
33+
of private TF utilities and functionalities that are not part of the public
34+
API. Exposing those functions into public APIs will be very confusing to the
35+
end user who uses tf to build/train models, since those functions are useful to
36+
framework-builders, but not typical TensorFlow users.
37+
38+
39+
## Design Proposal
40+
41+
Add a new namespace "tensorflow._internal" to host the framework building/
42+
testing related APIs that are currently used by other high level API in TF
43+
(Keras, and estimator, etc.). This name space will be treated as a protected
44+
API, which shouldn't be used by the end users. It will have no API contract
45+
compared to core TF API. TF side must be aware of the usage from client lib,
46+
so that it can properly test the change to any of those internal API before TF
47+
side making any backward incompatible change.
48+
49+
### Backward compatibility
50+
There is no API contract for all the functions under this namespace. TF side
51+
can make any backward incompatible change at any time. To prevent any breakage
52+
caused on the client side, TF must be aware who is using this API, so that any
53+
changes to those API will be verified against the client code.
54+
55+
### Acceptance Criteria
56+
The candidate of the "_internal" API should:
57+
58+
1. Does NOT fit for core TF API, otherwise it should be exposed as core TF API.
59+
1. Are currently used by other high level API to build/test/deploy a framework
60+
or library on top of TensorFlow, or to integrate such a framework into
61+
TensorFlow's API.
62+
1. Non-trivial, otherwise the function should be copied to the client side.
63+
1. Widely used in the implementation of TF public APIs or test TF related
64+
features. (i.e. new functionality isn’t immediately added to the tf._internal
65+
namespace)
66+
67+
TF API owners will review the new API proposal, and follow the existing review
68+
process for core TF API.
69+
70+
71+
### Lifespan of the internal API
72+
The internal API should serve as a temporary solution for the client side, and
73+
they should gradually migrate to alternative public TF core API, or other
74+
approaches. Once all the usage for a certain internal API has been removed, it
75+
will be deleted from the internal API namespace.
76+
77+
78+
### Documentation and Docstring
79+
The "internal" API should have the same style and standard as the core
80+
TensorFlow API, which is documented [here](https://github.com/tensorflow/community/blob/master/governance/api-reviews.md#docstrings).
81+
We will hide this from the documentation site, since the end users are the
82+
target audience for this API.
83+
84+
### Naming and sub namespace
85+
Similar "internal" APIs should be grouped together as sub namespaces, e.g., test
86+
related APIs should live under "tf.internal.test". This is aligned with the
87+
existing TF naming conversion.
88+
89+
90+
### Current candidate
91+
The following list is created from the private TF method usage within Keras,
92+
when we were trying to convert Keras to use the public TF API only. This is by
93+
no means the full list, but will serve as the first wave of review requests we
94+
send to the API owner for review. We don't expect all of them to be approved,
95+
and will discuss with the API owner on a case to case basis.
96+
97+
|Symbol location |API Name |
98+
:-------------- |:---------------------------------------------------- |
99+
|python.framework.func_graph.FuncGraph |tf.internal.FuncGraph |
100+
|python.framework.combinations.*| tf.internal.test.combinations.* |
101+
|python.distribute.strategy_combinations.* |tf.internal.test.combinations.* |
102+
|python.util.object_identity.*|tf.internal.object_identity.* |
103+
|python.util.tf_decorator.TFDecorator|tf.internal.decorator.TFDecorator |
104+
|python.util.tf_decorator.unwrap|tf.internal.inspect.unwrap |
105+
106+
### Alternative Names
107+
1. <b>"tf.internal"</b>: It gives the user the impression that this is not a
108+
standard user facing API (good), and contains some private/implementation
109+
details that are internal to TF.
110+
1. <b>"tf.infra"</b>: infrastructure is aligned with "building blocks" and low
111+
level functionalities, like file system/network etc. So far, the APIs we want
112+
to add are still high level APIs and utility functions.
113+
1. By Martin <b>"tf.\_internal"</b>: the extra "_" emphasis in the pythonic way
114+
that this is for private usage.

0 commit comments

Comments
 (0)