Add user_ops.my_fact to the new TensorFlow API.
authorAnna R <annarev@google.com>
Sat, 17 Mar 2018 00:05:51 +0000 (17:05 -0700)
committerTensorFlower Gardener <gardener@tensorflow.org>
Sat, 17 Mar 2018 00:10:37 +0000 (17:10 -0700)
PiperOrigin-RevId: 189415577

tensorflow/python/BUILD
tensorflow/python/user_ops/user_ops.py
tensorflow/tools/api/generator/BUILD
tensorflow/tools/api/tests/api_compatibility_test.py

index a206685..9a29986 100644 (file)
@@ -2585,6 +2585,7 @@ py_library(
     srcs_version = "PY2AND3",
     deps = [
         ":user_ops_gen",
+        ":util",
         "@six_archive//:six",
     ],
 )
index 6f9b5d9..20ea3b0 100644 (file)
@@ -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()
index 14ce8db..d9b0260 100644 (file)
@@ -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"],
index 5268bba..99c47fd 100644 (file)
@@ -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(