Fork and update the API compatibility test for OSS keras.

Borrow the main body of the tf api compat test for diffing and api generation. The py_object_to_proto lib need a slight update to config the root path since we will make tensorflow.keras as the root when visiting all the keras related API.

PiperOrigin-RevId: 360954528
Change-Id: I1c0d6e3310479cc7cf66ffd1f8b1a060f7f5029b
This commit is contained in:
Scott Zhu 2021-03-04 10:52:18 -08:00 committed by TensorFlower Gardener
parent e2390bc48c
commit 94941b0f9a
3 changed files with 11 additions and 4 deletions

View File

@ -6,7 +6,10 @@ load(
)
package(
default_visibility = ["//tensorflow/tools/api:__subpackages__"],
default_visibility = [
"//tensorflow/tools/api:__subpackages__",
"//third_party/py/keras/api:__subpackages__",
],
licenses = ["notice"], # Apache 2.0
)

View File

@ -201,10 +201,11 @@ def _IsProtoClass(obj):
class PythonObjectToProtoVisitor(object):
"""A visitor that summarizes given python objects as protobufs."""
def __init__(self):
def __init__(self, default_path='tensorflow'):
# A dict to store all protocol buffers.
# Keyed by "path" to the object.
self._protos = {}
self._default_path = default_path
def GetProtos(self):
"""Return the list of protos stored."""
@ -212,7 +213,7 @@ class PythonObjectToProtoVisitor(object):
def __call__(self, path, parent, children):
# The path to the object.
lib_path = 'tensorflow.%s' % path if path else 'tensorflow'
lib_path = self._default_path + '.' + path if path else self._default_path
_, parent = tf_decorator.unwrap(parent)
# A small helper method to construct members(children) protos.

View File

@ -4,7 +4,10 @@
load("//tensorflow:tensorflow.bzl", "py_test")
package(
default_visibility = ["//tensorflow:__subpackages__"],
default_visibility = [
"//tensorflow:__subpackages__",
"//third_party/py/keras/api:__subpackages__",
],
licenses = ["notice"], # Apache 2.0
)