Export utility inside_function to the public API.

PiperOrigin-RevId: 323943686
Change-Id: Ie50ea6880731feb99b0d4d243aab8e468bb7b86b
This commit is contained in:
Francois Chollet 2020-07-29 23:05:16 -07:00 committed by TensorFlower Gardener
parent 2c1b1b87f0
commit 1d19b8f060
2 changed files with 21 additions and 0 deletions
tensorflow
python/framework
tools/api/golden/v2

View File

@ -5820,7 +5820,24 @@ def executing_eagerly_outside_functions():
return context.executing_eagerly()
@tf_export("inside_function", v1=[])
def inside_function():
"""Indicates whether the caller code is executing inside a `tf.function`.
Returns:
Boolean, True if the caller code is executing inside a `tf.function`
rather than eagerly.
Example:
>>> tf.inside_function()
False
>>> @tf.function
... def f():
... print(tf.inside_function())
>>> f()
True
"""
return get_default_graph().building_function

View File

@ -744,6 +744,10 @@ tf_module {
name: "init_scope"
argspec: "args=[], varargs=None, keywords=None, defaults=None"
}
member_method {
name: "inside_function"
argspec: "args=[], varargs=None, keywords=None, defaults=None"
}
member_method {
name: "is_tensor"
argspec: "args=[\'x\'], varargs=None, keywords=None, defaults=None"