Don't use the heavyweight tf_stack in tf_decorator, which only needs the name of the parent frame. Remove package dependency.

PiperOrigin-RevId: 342089411
Change-Id: Id0aeb501f799cb829bca59fd3345e844e44a395a
This commit is contained in:
Dan Moldovan 2020-11-12 11:18:11 -08:00 committed by TensorFlower Gardener
parent 1028958173
commit 9aec83d8e6
2 changed files with 4 additions and 7 deletions

View File

@ -5688,7 +5688,7 @@ py_strict_library(
"util/tf_inspect.py",
],
compatible_with = get_compatible_with_portable(),
srcs_version = "PY2AND3",
srcs_version = "PY3",
visibility = [
"//tensorflow:__subpackages__",
# TODO(mdan): Remove these dependencies.
@ -5696,12 +5696,12 @@ py_strict_library(
"//learning/deepmind/research/language/translation/lm:__subpackages__",
],
deps = [
":tf_stack",
"@six_archive//:six",
],
)
# Leaf library: may not depend on anything else inside TensorFlow.
# Note: this is a heavyweight library specialized for TensorFlow graphs. Do not use for
# other purposes.
py_strict_library(
name = "tf_stack",
srcs = ["util/tf_stack.py"],

View File

@ -61,8 +61,6 @@ from __future__ import print_function
import inspect
from tensorflow.python.util import tf_stack
def make_decorator(target,
decorator_func,
@ -84,8 +82,7 @@ def make_decorator(target,
The `decorator_func` argument with new metadata attached.
"""
if decorator_name is None:
frame = tf_stack.extract_stack(limit=2)[0]
decorator_name = frame.name
decorator_name = inspect.currentframe().f_back.f_code.co_name
decorator = TFDecorator(decorator_name, target, decorator_doc,
decorator_argspec)
setattr(decorator_func, '_tf_decorator', decorator)