Merge pull request #23006 from girving:compatibility

PiperOrigin-RevId: 219199109
This commit is contained in:
TensorFlower Gardener 2018-10-29 15:24:26 -07:00
commit 7470219a53
62 changed files with 186 additions and 155 deletions

View File

@ -1,6 +1,6 @@
path: "tensorflow.data.Dataset.__metaclass__"
tf_class {
is_instance: "<class \'abc.ABCMeta\'>"
is_instance: "<type \'type\'>"
member_method {
name: "__init__"
}

View File

@ -1,6 +1,6 @@
path: "tensorflow.data.FixedLengthRecordDataset.__metaclass__"
tf_class {
is_instance: "<class \'abc.ABCMeta\'>"
is_instance: "<type \'type\'>"
member_method {
name: "__init__"
}

View File

@ -1,6 +1,6 @@
path: "tensorflow.data.TFRecordDataset.__metaclass__"
tf_class {
is_instance: "<class \'abc.ABCMeta\'>"
is_instance: "<type \'type\'>"
member_method {
name: "__init__"
}

View File

@ -1,6 +1,6 @@
path: "tensorflow.data.TextLineDataset.__metaclass__"
tf_class {
is_instance: "<class \'abc.ABCMeta\'>"
is_instance: "<type \'type\'>"
member_method {
name: "__init__"
}

View File

@ -1,6 +1,6 @@
path: "tensorflow.data.experimental.CsvDataset.__metaclass__"
tf_class {
is_instance: "<class \'abc.ABCMeta\'>"
is_instance: "<type \'type\'>"
member_method {
name: "__init__"
}

View File

@ -1,6 +1,6 @@
path: "tensorflow.data.experimental.RandomDataset.__metaclass__"
tf_class {
is_instance: "<class \'abc.ABCMeta\'>"
is_instance: "<type \'type\'>"
member_method {
name: "__init__"
}

View File

@ -1,6 +1,6 @@
path: "tensorflow.data.experimental.SqlDataset.__metaclass__"
tf_class {
is_instance: "<class \'abc.ABCMeta\'>"
is_instance: "<type \'type\'>"
member_method {
name: "__init__"
}

View File

@ -10,7 +10,7 @@ tf_module {
}
member {
name: "CsvDataset"
mtype: "<class \'abc.ABCMeta\'>"
mtype: "<type \'type\'>"
}
member {
name: "Optional"
@ -18,7 +18,7 @@ tf_module {
}
member {
name: "RandomDataset"
mtype: "<class \'abc.ABCMeta\'>"
mtype: "<type \'type\'>"
}
member {
name: "Reducer"
@ -26,7 +26,7 @@ tf_module {
}
member {
name: "SqlDataset"
mtype: "<class \'abc.ABCMeta\'>"
mtype: "<type \'type\'>"
}
member {
name: "StatsAggregator"

View File

@ -2,11 +2,11 @@ path: "tensorflow.data"
tf_module {
member {
name: "Dataset"
mtype: "<class \'abc.ABCMeta\'>"
mtype: "<type \'type\'>"
}
member {
name: "FixedLengthRecordDataset"
mtype: "<class \'abc.ABCMeta\'>"
mtype: "<type \'type\'>"
}
member {
name: "Iterator"
@ -18,11 +18,11 @@ tf_module {
}
member {
name: "TFRecordDataset"
mtype: "<class \'abc.ABCMeta\'>"
mtype: "<type \'type\'>"
}
member {
name: "TextLineDataset"
mtype: "<class \'abc.ABCMeta\'>"
mtype: "<type \'type\'>"
}
member {
name: "experimental"

View File

@ -1,6 +1,6 @@
path: "tensorflow.estimator.export.ClassificationOutput.__metaclass__"
tf_class {
is_instance: "<class \'abc.ABCMeta\'>"
is_instance: "<type \'type\'>"
member_method {
name: "__init__"
}

View File

@ -1,6 +1,6 @@
path: "tensorflow.estimator.export.ExportOutput.__metaclass__"
tf_class {
is_instance: "<class \'abc.ABCMeta\'>"
is_instance: "<type \'type\'>"
member_method {
name: "__init__"
}

View File

@ -1,6 +1,6 @@
path: "tensorflow.estimator.export.PredictOutput.__metaclass__"
tf_class {
is_instance: "<class \'abc.ABCMeta\'>"
is_instance: "<type \'type\'>"
member_method {
name: "__init__"
}

View File

@ -1,6 +1,6 @@
path: "tensorflow.estimator.export.RegressionOutput.__metaclass__"
tf_class {
is_instance: "<class \'abc.ABCMeta\'>"
is_instance: "<type \'type\'>"
member_method {
name: "__init__"
}

View File

@ -2,19 +2,19 @@ path: "tensorflow.estimator.export"
tf_module {
member {
name: "ClassificationOutput"
mtype: "<class \'abc.ABCMeta\'>"
mtype: "<type \'type\'>"
}
member {
name: "ExportOutput"
mtype: "<class \'abc.ABCMeta\'>"
mtype: "<type \'type\'>"
}
member {
name: "PredictOutput"
mtype: "<class \'abc.ABCMeta\'>"
mtype: "<type \'type\'>"
}
member {
name: "RegressionOutput"
mtype: "<class \'abc.ABCMeta\'>"
mtype: "<type \'type\'>"
}
member {
name: "ServingInputReceiver"

View File

@ -1,6 +1,6 @@
path: "tensorflow.linalg.LinearOperatorBlockDiag.__metaclass__"
tf_class {
is_instance: "<class \'abc.ABCMeta\'>"
is_instance: "<type \'type\'>"
member_method {
name: "__init__"
}

View File

@ -1,6 +1,6 @@
path: "tensorflow.linalg.LinearOperatorCirculant.__metaclass__"
tf_class {
is_instance: "<class \'abc.ABCMeta\'>"
is_instance: "<type \'type\'>"
member_method {
name: "__init__"
}

View File

@ -1,6 +1,6 @@
path: "tensorflow.linalg.LinearOperatorCirculant2D.__metaclass__"
tf_class {
is_instance: "<class \'abc.ABCMeta\'>"
is_instance: "<type \'type\'>"
member_method {
name: "__init__"
}

View File

@ -1,6 +1,6 @@
path: "tensorflow.linalg.LinearOperatorCirculant3D.__metaclass__"
tf_class {
is_instance: "<class \'abc.ABCMeta\'>"
is_instance: "<type \'type\'>"
member_method {
name: "__init__"
}

View File

@ -1,6 +1,6 @@
path: "tensorflow.linalg.LinearOperatorComposition.__metaclass__"
tf_class {
is_instance: "<class \'abc.ABCMeta\'>"
is_instance: "<type \'type\'>"
member_method {
name: "__init__"
}

View File

@ -1,6 +1,6 @@
path: "tensorflow.linalg.LinearOperatorDiag.__metaclass__"
tf_class {
is_instance: "<class \'abc.ABCMeta\'>"
is_instance: "<type \'type\'>"
member_method {
name: "__init__"
}

View File

@ -1,6 +1,6 @@
path: "tensorflow.linalg.LinearOperatorFullMatrix.__metaclass__"
tf_class {
is_instance: "<class \'abc.ABCMeta\'>"
is_instance: "<type \'type\'>"
member_method {
name: "__init__"
}

View File

@ -1,6 +1,6 @@
path: "tensorflow.linalg.LinearOperatorIdentity.__metaclass__"
tf_class {
is_instance: "<class \'abc.ABCMeta\'>"
is_instance: "<type \'type\'>"
member_method {
name: "__init__"
}

View File

@ -1,6 +1,6 @@
path: "tensorflow.linalg.LinearOperatorKronecker.__metaclass__"
tf_class {
is_instance: "<class \'abc.ABCMeta\'>"
is_instance: "<type \'type\'>"
member_method {
name: "__init__"
}

View File

@ -1,6 +1,6 @@
path: "tensorflow.linalg.LinearOperatorLowRankUpdate.__metaclass__"
tf_class {
is_instance: "<class \'abc.ABCMeta\'>"
is_instance: "<type \'type\'>"
member_method {
name: "__init__"
}

View File

@ -1,6 +1,6 @@
path: "tensorflow.linalg.LinearOperatorLowerTriangular.__metaclass__"
tf_class {
is_instance: "<class \'abc.ABCMeta\'>"
is_instance: "<type \'type\'>"
member_method {
name: "__init__"
}

View File

@ -1,6 +1,6 @@
path: "tensorflow.linalg.LinearOperatorScaledIdentity.__metaclass__"
tf_class {
is_instance: "<class \'abc.ABCMeta\'>"
is_instance: "<type \'type\'>"
member_method {
name: "__init__"
}

View File

@ -1,6 +1,6 @@
path: "tensorflow.linalg.LinearOperatorZeros.__metaclass__"
tf_class {
is_instance: "<class \'abc.ABCMeta\'>"
is_instance: "<type \'type\'>"
member_method {
name: "__init__"
}

View File

@ -1,6 +1,6 @@
path: "tensorflow.linalg.LinearOperator.__metaclass__"
tf_class {
is_instance: "<class \'abc.ABCMeta\'>"
is_instance: "<type \'type\'>"
member_method {
name: "__init__"
}

View File

@ -2,59 +2,59 @@ path: "tensorflow.linalg"
tf_module {
member {
name: "LinearOperator"
mtype: "<class \'abc.ABCMeta\'>"
mtype: "<type \'type\'>"
}
member {
name: "LinearOperatorBlockDiag"
mtype: "<class \'abc.ABCMeta\'>"
mtype: "<type \'type\'>"
}
member {
name: "LinearOperatorCirculant"
mtype: "<class \'abc.ABCMeta\'>"
mtype: "<type \'type\'>"
}
member {
name: "LinearOperatorCirculant2D"
mtype: "<class \'abc.ABCMeta\'>"
mtype: "<type \'type\'>"
}
member {
name: "LinearOperatorCirculant3D"
mtype: "<class \'abc.ABCMeta\'>"
mtype: "<type \'type\'>"
}
member {
name: "LinearOperatorComposition"
mtype: "<class \'abc.ABCMeta\'>"
mtype: "<type \'type\'>"
}
member {
name: "LinearOperatorDiag"
mtype: "<class \'abc.ABCMeta\'>"
mtype: "<type \'type\'>"
}
member {
name: "LinearOperatorFullMatrix"
mtype: "<class \'abc.ABCMeta\'>"
mtype: "<type \'type\'>"
}
member {
name: "LinearOperatorIdentity"
mtype: "<class \'abc.ABCMeta\'>"
mtype: "<type \'type\'>"
}
member {
name: "LinearOperatorKronecker"
mtype: "<class \'abc.ABCMeta\'>"
mtype: "<type \'type\'>"
}
member {
name: "LinearOperatorLowRankUpdate"
mtype: "<class \'abc.ABCMeta\'>"
mtype: "<type \'type\'>"
}
member {
name: "LinearOperatorLowerTriangular"
mtype: "<class \'abc.ABCMeta\'>"
mtype: "<type \'type\'>"
}
member {
name: "LinearOperatorScaledIdentity"
mtype: "<class \'abc.ABCMeta\'>"
mtype: "<type \'type\'>"
}
member {
name: "LinearOperatorZeros"
mtype: "<class \'abc.ABCMeta\'>"
mtype: "<type \'type\'>"
}
member_method {
name: "adjoint"

View File

@ -6,10 +6,6 @@ tf_class {
name: "args"
mtype: "<type \'getset_descriptor\'>"
}
member {
name: "message"
mtype: "<type \'getset_descriptor\'>"
}
member_method {
name: "__init__"
}

View File

@ -1,6 +1,6 @@
path: "tensorflow.data.Dataset.__metaclass__"
tf_class {
is_instance: "<class \'abc.ABCMeta\'>"
is_instance: "<type \'type\'>"
member_method {
name: "__init__"
}

View File

@ -1,6 +1,6 @@
path: "tensorflow.data.FixedLengthRecordDataset.__metaclass__"
tf_class {
is_instance: "<class \'abc.ABCMeta\'>"
is_instance: "<type \'type\'>"
member_method {
name: "__init__"
}

View File

@ -1,6 +1,6 @@
path: "tensorflow.data.TFRecordDataset.__metaclass__"
tf_class {
is_instance: "<class \'abc.ABCMeta\'>"
is_instance: "<type \'type\'>"
member_method {
name: "__init__"
}

View File

@ -1,6 +1,6 @@
path: "tensorflow.data.TextLineDataset.__metaclass__"
tf_class {
is_instance: "<class \'abc.ABCMeta\'>"
is_instance: "<type \'type\'>"
member_method {
name: "__init__"
}

View File

@ -1,6 +1,6 @@
path: "tensorflow.data.experimental.CsvDataset.__metaclass__"
tf_class {
is_instance: "<class \'abc.ABCMeta\'>"
is_instance: "<type \'type\'>"
member_method {
name: "__init__"
}

View File

@ -1,6 +1,6 @@
path: "tensorflow.data.experimental.RandomDataset.__metaclass__"
tf_class {
is_instance: "<class \'abc.ABCMeta\'>"
is_instance: "<type \'type\'>"
member_method {
name: "__init__"
}

View File

@ -1,6 +1,6 @@
path: "tensorflow.data.experimental.SqlDataset.__metaclass__"
tf_class {
is_instance: "<class \'abc.ABCMeta\'>"
is_instance: "<type \'type\'>"
member_method {
name: "__init__"
}

View File

@ -10,7 +10,7 @@ tf_module {
}
member {
name: "CsvDataset"
mtype: "<class \'abc.ABCMeta\'>"
mtype: "<type \'type\'>"
}
member {
name: "Optional"
@ -18,7 +18,7 @@ tf_module {
}
member {
name: "RandomDataset"
mtype: "<class \'abc.ABCMeta\'>"
mtype: "<type \'type\'>"
}
member {
name: "Reducer"
@ -26,7 +26,7 @@ tf_module {
}
member {
name: "SqlDataset"
mtype: "<class \'abc.ABCMeta\'>"
mtype: "<type \'type\'>"
}
member {
name: "StatsAggregator"

View File

@ -2,11 +2,11 @@ path: "tensorflow.data"
tf_module {
member {
name: "Dataset"
mtype: "<class \'abc.ABCMeta\'>"
mtype: "<type \'type\'>"
}
member {
name: "FixedLengthRecordDataset"
mtype: "<class \'abc.ABCMeta\'>"
mtype: "<type \'type\'>"
}
member {
name: "Iterator"
@ -18,11 +18,11 @@ tf_module {
}
member {
name: "TFRecordDataset"
mtype: "<class \'abc.ABCMeta\'>"
mtype: "<type \'type\'>"
}
member {
name: "TextLineDataset"
mtype: "<class \'abc.ABCMeta\'>"
mtype: "<type \'type\'>"
}
member {
name: "experimental"

View File

@ -1,6 +1,6 @@
path: "tensorflow.estimator.export.ClassificationOutput.__metaclass__"
tf_class {
is_instance: "<class \'abc.ABCMeta\'>"
is_instance: "<type \'type\'>"
member_method {
name: "__init__"
}

View File

@ -1,6 +1,6 @@
path: "tensorflow.estimator.export.ExportOutput.__metaclass__"
tf_class {
is_instance: "<class \'abc.ABCMeta\'>"
is_instance: "<type \'type\'>"
member_method {
name: "__init__"
}

View File

@ -1,6 +1,6 @@
path: "tensorflow.estimator.export.PredictOutput.__metaclass__"
tf_class {
is_instance: "<class \'abc.ABCMeta\'>"
is_instance: "<type \'type\'>"
member_method {
name: "__init__"
}

View File

@ -1,6 +1,6 @@
path: "tensorflow.estimator.export.RegressionOutput.__metaclass__"
tf_class {
is_instance: "<class \'abc.ABCMeta\'>"
is_instance: "<type \'type\'>"
member_method {
name: "__init__"
}

View File

@ -2,19 +2,19 @@ path: "tensorflow.estimator.export"
tf_module {
member {
name: "ClassificationOutput"
mtype: "<class \'abc.ABCMeta\'>"
mtype: "<type \'type\'>"
}
member {
name: "ExportOutput"
mtype: "<class \'abc.ABCMeta\'>"
mtype: "<type \'type\'>"
}
member {
name: "PredictOutput"
mtype: "<class \'abc.ABCMeta\'>"
mtype: "<type \'type\'>"
}
member {
name: "RegressionOutput"
mtype: "<class \'abc.ABCMeta\'>"
mtype: "<type \'type\'>"
}
member {
name: "ServingInputReceiver"

View File

@ -1,6 +1,6 @@
path: "tensorflow.linalg.LinearOperatorBlockDiag.__metaclass__"
tf_class {
is_instance: "<class \'abc.ABCMeta\'>"
is_instance: "<type \'type\'>"
member_method {
name: "__init__"
}

View File

@ -1,6 +1,6 @@
path: "tensorflow.linalg.LinearOperatorCirculant.__metaclass__"
tf_class {
is_instance: "<class \'abc.ABCMeta\'>"
is_instance: "<type \'type\'>"
member_method {
name: "__init__"
}

View File

@ -1,6 +1,6 @@
path: "tensorflow.linalg.LinearOperatorCirculant2D.__metaclass__"
tf_class {
is_instance: "<class \'abc.ABCMeta\'>"
is_instance: "<type \'type\'>"
member_method {
name: "__init__"
}

View File

@ -1,6 +1,6 @@
path: "tensorflow.linalg.LinearOperatorCirculant3D.__metaclass__"
tf_class {
is_instance: "<class \'abc.ABCMeta\'>"
is_instance: "<type \'type\'>"
member_method {
name: "__init__"
}

View File

@ -1,6 +1,6 @@
path: "tensorflow.linalg.LinearOperatorComposition.__metaclass__"
tf_class {
is_instance: "<class \'abc.ABCMeta\'>"
is_instance: "<type \'type\'>"
member_method {
name: "__init__"
}

View File

@ -1,6 +1,6 @@
path: "tensorflow.linalg.LinearOperatorDiag.__metaclass__"
tf_class {
is_instance: "<class \'abc.ABCMeta\'>"
is_instance: "<type \'type\'>"
member_method {
name: "__init__"
}

View File

@ -1,6 +1,6 @@
path: "tensorflow.linalg.LinearOperatorFullMatrix.__metaclass__"
tf_class {
is_instance: "<class \'abc.ABCMeta\'>"
is_instance: "<type \'type\'>"
member_method {
name: "__init__"
}

View File

@ -1,6 +1,6 @@
path: "tensorflow.linalg.LinearOperatorIdentity.__metaclass__"
tf_class {
is_instance: "<class \'abc.ABCMeta\'>"
is_instance: "<type \'type\'>"
member_method {
name: "__init__"
}

View File

@ -1,6 +1,6 @@
path: "tensorflow.linalg.LinearOperatorKronecker.__metaclass__"
tf_class {
is_instance: "<class \'abc.ABCMeta\'>"
is_instance: "<type \'type\'>"
member_method {
name: "__init__"
}

View File

@ -1,6 +1,6 @@
path: "tensorflow.linalg.LinearOperatorLowRankUpdate.__metaclass__"
tf_class {
is_instance: "<class \'abc.ABCMeta\'>"
is_instance: "<type \'type\'>"
member_method {
name: "__init__"
}

View File

@ -1,6 +1,6 @@
path: "tensorflow.linalg.LinearOperatorLowerTriangular.__metaclass__"
tf_class {
is_instance: "<class \'abc.ABCMeta\'>"
is_instance: "<type \'type\'>"
member_method {
name: "__init__"
}

View File

@ -1,6 +1,6 @@
path: "tensorflow.linalg.LinearOperatorScaledIdentity.__metaclass__"
tf_class {
is_instance: "<class \'abc.ABCMeta\'>"
is_instance: "<type \'type\'>"
member_method {
name: "__init__"
}

View File

@ -1,6 +1,6 @@
path: "tensorflow.linalg.LinearOperatorZeros.__metaclass__"
tf_class {
is_instance: "<class \'abc.ABCMeta\'>"
is_instance: "<type \'type\'>"
member_method {
name: "__init__"
}

View File

@ -1,6 +1,6 @@
path: "tensorflow.linalg.LinearOperator.__metaclass__"
tf_class {
is_instance: "<class \'abc.ABCMeta\'>"
is_instance: "<type \'type\'>"
member_method {
name: "__init__"
}

View File

@ -2,59 +2,59 @@ path: "tensorflow.linalg"
tf_module {
member {
name: "LinearOperator"
mtype: "<class \'abc.ABCMeta\'>"
mtype: "<type \'type\'>"
}
member {
name: "LinearOperatorBlockDiag"
mtype: "<class \'abc.ABCMeta\'>"
mtype: "<type \'type\'>"
}
member {
name: "LinearOperatorCirculant"
mtype: "<class \'abc.ABCMeta\'>"
mtype: "<type \'type\'>"
}
member {
name: "LinearOperatorCirculant2D"
mtype: "<class \'abc.ABCMeta\'>"
mtype: "<type \'type\'>"
}
member {
name: "LinearOperatorCirculant3D"
mtype: "<class \'abc.ABCMeta\'>"
mtype: "<type \'type\'>"
}
member {
name: "LinearOperatorComposition"
mtype: "<class \'abc.ABCMeta\'>"
mtype: "<type \'type\'>"
}
member {
name: "LinearOperatorDiag"
mtype: "<class \'abc.ABCMeta\'>"
mtype: "<type \'type\'>"
}
member {
name: "LinearOperatorFullMatrix"
mtype: "<class \'abc.ABCMeta\'>"
mtype: "<type \'type\'>"
}
member {
name: "LinearOperatorIdentity"
mtype: "<class \'abc.ABCMeta\'>"
mtype: "<type \'type\'>"
}
member {
name: "LinearOperatorKronecker"
mtype: "<class \'abc.ABCMeta\'>"
mtype: "<type \'type\'>"
}
member {
name: "LinearOperatorLowRankUpdate"
mtype: "<class \'abc.ABCMeta\'>"
mtype: "<type \'type\'>"
}
member {
name: "LinearOperatorLowerTriangular"
mtype: "<class \'abc.ABCMeta\'>"
mtype: "<type \'type\'>"
}
member {
name: "LinearOperatorScaledIdentity"
mtype: "<class \'abc.ABCMeta\'>"
mtype: "<type \'type\'>"
}
member {
name: "LinearOperatorZeros"
mtype: "<class \'abc.ABCMeta\'>"
mtype: "<type \'type\'>"
}
member_method {
name: "adjoint"

View File

@ -6,10 +6,6 @@ tf_class {
name: "args"
mtype: "<type \'getset_descriptor\'>"
}
member {
name: "message"
mtype: "<type \'getset_descriptor\'>"
}
member_method {
name: "__init__"
}

View File

@ -19,6 +19,8 @@ from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import sys
import enum
from google.protobuf import message
from tensorflow.python.platform import tf_logging as logging
from tensorflow.python.util import tf_decorator
@ -27,11 +29,55 @@ from tensorflow.tools.api.lib import api_objects_pb2
# Following object need to be handled individually.
_CORNER_CASES = {
'': {'tools': {}},
'': {
'tools': {}
},
'test.TestCase': {},
'test.TestCase.failureException': {},
'train.NanLossDuringTrainingError': {
'message': {}
},
}
# Python 2 vs. 3 differences
if sys.version_info.major == 3:
_NORMALIZE_TYPE = {}
for t in ('property', 'object', 'getset_descriptor', 'int', 'str', 'type',
'tuple', 'module', 'collections.defaultdict', 'set', 'dict',
'NoneType', 'frozenset'):
_NORMALIZE_TYPE["<class '%s'>" % t] = "<type '%s'>" % t
for e in 'Exception', 'RuntimeError':
_NORMALIZE_TYPE["<class '%s'>" % e] = "<type 'exceptions.%s'>" % e
_NORMALIZE_TYPE["<class 'abc.ABCMeta'>"] = "<type 'type'>"
_NORMALIZE_ISINSTANCE = {
"<class "
"'tensorflow.python.training.monitored_session._MonitoredSession.StepContext'>": # pylint: disable=line-too-long
"<class "
"'tensorflow.python.training.monitored_session.StepContext'>",
"<class "
"'tensorflow.python.ops.variables.Variable.SaveSliceInfo'>":
"<class "
"'tensorflow.python.ops.variables.SaveSliceInfo'>"
}
def _SkipMember(cls, member):
return (member == 'with_traceback' or member in ('name', 'value') and
isinstance(cls, type) and issubclass(cls, enum.Enum))
else:
_NORMALIZE_TYPE = {"<class 'abc.ABCMeta'>": "<type 'type'>"}
_NORMALIZE_ISINSTANCE = {}
def _SkipMember(cls, member): # pylint: disable=unused-argument
return False
def _NormalizeType(ty):
return _NORMALIZE_TYPE.get(ty, ty)
def _NormalizeIsInstance(ty):
return _NORMALIZE_ISINSTANCE.get(ty, ty)
def _SanitizedArgSpec(obj):
"""Get an ArgSpec string that is free of addresses.
@ -91,7 +137,7 @@ def _SanitizedMRO(obj):
if cls.__name__ == '_NewClass':
# Ignore class created by @deprecated_alias decorator.
continue
str_repr = str(cls)
str_repr = _NormalizeType(str(cls))
return_list.append(str_repr)
if 'tensorflow' not in str_repr:
break
@ -130,6 +176,8 @@ class PythonObjectToProtoVisitor(object):
def _AddMember(member_name, member_obj, proto):
"""Add the child object to the object being constructed."""
_, member_obj = tf_decorator.unwrap(member_obj)
if _SkipMember(parent, member_name):
return
if member_name == '__init__' or not member_name.startswith('_'):
if tf_inspect.isroutine(member_obj):
new_method = proto.member_method.add()
@ -137,12 +185,12 @@ class PythonObjectToProtoVisitor(object):
# If member_obj is a python builtin, there is no way to get its
# argspec, because it is implemented on the C side. It also has no
# func_code.
if getattr(member_obj, 'func_code', None):
if hasattr(member_obj, '__code__'):
new_method.argspec = _SanitizedArgSpec(member_obj)
else:
new_member = proto.member.add()
new_member.name = member_name
new_member.mtype = str(type(member_obj))
new_member.mtype = _NormalizeType(str(type(member_obj)))
parent_corner_cases = _CORNER_CASES.get(path, {})
@ -172,7 +220,8 @@ class PythonObjectToProtoVisitor(object):
elif tf_inspect.isclass(parent):
# Construct a class.
class_obj = api_objects_pb2.TFAPIClass()
class_obj.is_instance.extend(_SanitizedMRO(parent))
class_obj.is_instance.extend(
_NormalizeIsInstance(i) for i in _SanitizedMRO(parent))
for name, child in children:
if name in parent_corner_cases:
# If we have an empty entry, skip this object.

View File

@ -31,7 +31,6 @@ import argparse
import os
import re
import sys
import unittest
import tensorflow as tf
from tensorflow._api import v2 as tf_v2
@ -83,6 +82,7 @@ def _KeyToFilePath(key, api_version):
Filepath will be inside golden folder for api_version.
"""
def _ReplaceCapsWithDash(matchobj):
match = matchobj.group(0)
return '-%s' % (match.lower())
@ -95,22 +95,22 @@ def _KeyToFilePath(key, api_version):
def _FileNameToKey(filename):
"""From a given filename, construct a key we use for api objects."""
def _ReplaceDashWithCaps(matchobj):
match = matchobj.group(0)
return match[1].upper()
base_filename = os.path.basename(filename)
base_filename_without_ext = os.path.splitext(base_filename)[0]
api_object_key = re.sub(
'((-[a-z]){1})', _ReplaceDashWithCaps, base_filename_without_ext)
api_object_key = re.sub('((-[a-z]){1})', _ReplaceDashWithCaps,
base_filename_without_ext)
return api_object_key
def _VerifyNoSubclassOfMessageVisitor(path, parent, unused_children):
"""A Visitor that crashes on subclasses of generated proto classes."""
# If the traversed object is a proto Message class
if not (isinstance(parent, type) and
issubclass(parent, message.Message)):
if not (isinstance(parent, type) and issubclass(parent, message.Message)):
return
if parent is message.Message:
return
@ -124,11 +124,11 @@ def _VerifyNoSubclassOfMessageVisitor(path, parent, unused_children):
def _FilterNonCoreGoldenFiles(golden_file_list):
"""Filter out non-core API pbtxt files."""
filtered_file_list = []
filtered_package_prefixes = [
'tensorflow.%s.' % p for p in _NON_CORE_PACKAGES]
filtered_package_prefixes = ['tensorflow.%s.' % p for p in _NON_CORE_PACKAGES]
for f in golden_file_list:
if any([f.rsplit('/')[-1].startswith(pre)
for pre in filtered_package_prefixes]):
if any([
f.rsplit('/')[-1].startswith(pre) for pre in filtered_package_prefixes
]):
continue
filtered_file_list.append(f)
return filtered_file_list
@ -140,14 +140,12 @@ class ApiCompatibilityTest(test.TestCase):
super(ApiCompatibilityTest, self).__init__(*args, **kwargs)
golden_update_warning_filename = os.path.join(
resource_loader.get_root_dir_with_all_resources(),
_UPDATE_WARNING_FILE)
resource_loader.get_root_dir_with_all_resources(), _UPDATE_WARNING_FILE)
self._update_golden_warning = file_io.read_file_to_string(
golden_update_warning_filename)
test_readme_filename = os.path.join(
resource_loader.get_root_dir_with_all_resources(),
_TEST_README_FILE)
resource_loader.get_root_dir_with_all_resources(), _TEST_README_FILE)
self._test_readme_message = file_io.read_file_to_string(
test_readme_filename)
@ -161,15 +159,14 @@ class ApiCompatibilityTest(test.TestCase):
"""Diff given dicts of protobufs and report differences a readable way.
Args:
expected_dict: a dict of TFAPIObject protos constructed from golden
files.
expected_dict: a dict of TFAPIObject protos constructed from golden files.
actual_dict: a ict of TFAPIObject protos constructed by reading from the
TF package linked to the test.
TF package linked to the test.
verbose: Whether to log the full diffs, or simply report which files were
different.
different.
update_goldens: Whether to update goldens when there are diffs found.
additional_missing_object_message: Message to print when a symbol is
missing.
missing.
api_version: TensorFlow API version to test.
"""
diffs = []
@ -257,8 +254,7 @@ class ApiCompatibilityTest(test.TestCase):
visitor = public_api.PublicAPIVisitor(_VerifyNoSubclassOfMessageVisitor)
visitor.do_not_descend_map['tf'].append('contrib')
if FLAGS.only_test_core_api:
visitor.do_not_descend_map['tf'].extend(
_NON_CORE_PACKAGES)
visitor.do_not_descend_map['tf'].extend(_NON_CORE_PACKAGES)
traverse.traverse(tf_v2.compat.v1, visitor)
def testNoSubclassOfMessageV2(self):
@ -267,23 +263,22 @@ class ApiCompatibilityTest(test.TestCase):
visitor = public_api.PublicAPIVisitor(_VerifyNoSubclassOfMessageVisitor)
visitor.do_not_descend_map['tf'].append('contrib')
if FLAGS.only_test_core_api:
visitor.do_not_descend_map['tf'].extend(
_NON_CORE_PACKAGES)
visitor.do_not_descend_map['tf'].extend(_NON_CORE_PACKAGES)
traverse.traverse(tf_v2, visitor)
def _checkBackwardsCompatibility(
self, root, golden_file_pattern, api_version,
additional_private_map=None):
def _checkBackwardsCompatibility(self,
root,
golden_file_pattern,
api_version,
additional_private_map=None):
# Extract all API stuff.
visitor = python_object_to_proto_visitor.PythonObjectToProtoVisitor()
public_api_visitor = public_api.PublicAPIVisitor(visitor)
public_api_visitor.private_map['tf'] = ['contrib']
public_api_visitor.do_not_descend_map['tf.GPUOptions'] = [
'Experimental']
public_api_visitor.do_not_descend_map['tf.GPUOptions'] = ['Experimental']
if FLAGS.only_test_core_api:
public_api_visitor.do_not_descend_map['tf'].extend(
_NON_CORE_PACKAGES)
public_api_visitor.do_not_descend_map['tf'].extend(_NON_CORE_PACKAGES)
if additional_private_map:
public_api_visitor.private_map.update(additional_private_map)
@ -315,9 +310,6 @@ class ApiCompatibilityTest(test.TestCase):
update_goldens=FLAGS.update_goldens,
api_version=api_version)
@unittest.skipUnless(
sys.version_info.major == 2,
'API compabitility test goldens are generated using python2.')
def testAPIBackwardsCompatibility(self):
api_version = 1
golden_file_pattern = os.path.join(
@ -336,27 +328,23 @@ class ApiCompatibilityTest(test.TestCase):
'tensorflow.python.util.lazy_loader.LazyLoader'
in str(type(tf.contrib)))
@unittest.skipUnless(
sys.version_info.major == 2,
'API compabitility test goldens are generated using python2.')
def testAPIBackwardsCompatibilityV1(self):
api_version = 1
golden_file_pattern = os.path.join(
resource_loader.get_root_dir_with_all_resources(),
_KeyToFilePath('*', api_version))
self._checkBackwardsCompatibility(
tf_v2.compat.v1, golden_file_pattern, api_version)
self._checkBackwardsCompatibility(tf_v2.compat.v1, golden_file_pattern,
api_version)
@unittest.skipUnless(
sys.version_info.major == 2,
'API compabitility test goldens are generated using python2.')
def testAPIBackwardsCompatibilityV2(self):
api_version = 2
golden_file_pattern = os.path.join(
resource_loader.get_root_dir_with_all_resources(),
_KeyToFilePath('*', api_version))
self._checkBackwardsCompatibility(
tf_v2, golden_file_pattern, api_version,
tf_v2,
golden_file_pattern,
api_version,
additional_private_map={'tf.compat': ['v1']})
@ -367,7 +355,9 @@ if __name__ == '__main__':
# TODO(mikecase): Create Estimator's own API compatibility test or
# a more general API compatibility test for use for TF components.
parser.add_argument(
'--only_test_core_api', type=bool, default=False,
'--only_test_core_api',
type=bool,
default=False,
help=_ONLY_TEST_CORE_API_HELP)
parser.add_argument(
'--verbose_diffs', type=bool, default=True, help=_VERBOSE_DIFFS_HELP)