From e3930fc11f042416a34ed5526bc506e1e0e32660 Mon Sep 17 00:00:00 2001 From: Anna R Date: Fri, 16 Mar 2018 17:05:51 -0700 Subject: [PATCH] Add user_ops.my_fact to the new TensorFlow API. PiperOrigin-RevId: 189415577 --- tensorflow/python/BUILD | 1 + tensorflow/python/user_ops/user_ops.py | 2 ++ tensorflow/tools/api/generator/BUILD | 1 + tensorflow/tools/api/tests/api_compatibility_test.py | 11 ----------- 4 files changed, 4 insertions(+), 11 deletions(-) diff --git a/tensorflow/python/BUILD b/tensorflow/python/BUILD index a206685..9a29986 100644 --- a/tensorflow/python/BUILD +++ b/tensorflow/python/BUILD @@ -2585,6 +2585,7 @@ py_library( srcs_version = "PY2AND3", deps = [ ":user_ops_gen", + ":util", "@six_archive//:six", ], ) diff --git a/tensorflow/python/user_ops/user_ops.py b/tensorflow/python/user_ops/user_ops.py index 6f9b5d9..20ea3b0 100644 --- a/tensorflow/python/user_ops/user_ops.py +++ b/tensorflow/python/user_ops/user_ops.py @@ -23,8 +23,10 @@ from tensorflow.python.ops import gen_user_ops as _gen_user_ops # go/tf-wildcard-import from tensorflow.python.ops.gen_user_ops import * # pylint: disable=wildcard-import +from tensorflow.python.util.tf_export import tf_export +@tf_export('user_ops.my_fact') def my_fact(): """Example of overriding the generated code for an Op.""" return _gen_user_ops.fact() diff --git a/tensorflow/tools/api/generator/BUILD b/tensorflow/tools/api/generator/BUILD index 14ce8db..d9b0260 100644 --- a/tensorflow/tools/api/generator/BUILD +++ b/tensorflow/tools/api/generator/BUILD @@ -127,6 +127,7 @@ genrule( "api/test/__init__.py", "api/train/__init__.py", "api/train/queue_runner/__init__.py", + "api/user_ops/__init__.py", ], cmd = "$(location create_python_api) $(OUTS)", tools = ["create_python_api"], diff --git a/tensorflow/tools/api/tests/api_compatibility_test.py b/tensorflow/tools/api/tests/api_compatibility_test.py index 5268bba..99c47fd 100644 --- a/tensorflow/tools/api/tests/api_compatibility_test.py +++ b/tensorflow/tools/api/tests/api_compatibility_test.py @@ -268,17 +268,6 @@ class ApiCompatibilityTest(test.TestCase): for filename in golden_file_list } - # user_ops is an empty module. It is currently available in TensorFlow API - # but we don't keep empty modules in the new API. - # We delete user_ops from golden_proto_dict to make sure assert passes - # when diffing new API against goldens. - # TODO(annarev): remove user_ops from goldens once we switch to new API. - tf_module = golden_proto_dict['tensorflow'].tf_module - for i in range(len(tf_module.member)): - if tf_module.member[i].name == 'user_ops': - del tf_module.member[i] - break - # Diff them. Do not fail if called with update. # If the test is run to update goldens, only report diffs but do not fail. self._AssertProtoDictEquals( -- 2.7.4