Export utility inside_function
to the public API.
PiperOrigin-RevId: 323943686 Change-Id: Ie50ea6880731feb99b0d4d243aab8e468bb7b86b
This commit is contained in:
parent
2c1b1b87f0
commit
1d19b8f060
tensorflow
@ -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
|
||||
|
||||
|
||||
|
@ -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"
|
||||
|
Loading…
Reference in New Issue
Block a user