Removing experimental from run_functions_eagerly. Also removed all references for the experimental one from documentation.

PiperOrigin-RevId: 309036487
Change-Id: I91ab0f8857387c337f329c13e78ffba312ae362c
This commit is contained in:
Rohan Jain 2020-04-29 09:21:51 -07:00 committed by TensorFlower Gardener
parent 967b778276
commit 1e1e08e367
7 changed files with 96 additions and 13 deletions

View File

@ -62,7 +62,7 @@ Adding a call to `tf.config.experimental_execute_functions_eagerly` before
executing the function will land the debugger in the original code instead:
```
tf.config.experimental_run_functions_eagerly(True)
tf.config.run_functions_eagerly(True)
f(1)
```

View File

@ -1793,7 +1793,7 @@ def executing_eagerly():
cases.
* Executing inside `tf.function`, unless under `tf.init_scope` or
`tf.config.experimental_run_functions_eagerly(True)` is previously called.
`tf.config.run_functions_eagerly(True)` is previously called.
* Executing inside a transformation function for `tf.dataset`.
* `tf.compat.v1.disable_eager_execution()` is called.
@ -1815,8 +1815,8 @@ def executing_eagerly():
Inside `tf.function` after
`tf.config.experimental_run_functions_eagerly(True)` is called:
>>> tf.config.experimental_run_functions_eagerly(True)
`tf.config.run_functions_eagerly(True)` is called:
>>> tf.config.run_functions_eagerly(True)
>>> @tf.function
... def fn():
... with tf.init_scope():
@ -1825,7 +1825,7 @@ def executing_eagerly():
>>> fn()
True
True
>>> tf.config.experimental_run_functions_eagerly(False)
>>> tf.config.run_functions_eagerly(False)
Inside a transformation function for `tf.dataset`:
@ -1858,7 +1858,7 @@ def executing_eagerly_v1():
this API might return `False` in the following use cases.
* Executing inside `tf.function`, unless under `tf.init_scope` or
`tf.config.experimental_run_functions_eagerly(True)` is previously called.
`tf.config.run_functions_eagerly(True)` is previously called.
* Executing inside a transformation function for `tf.dataset`.
* `tf.compat.v1.disable_eager_execution()` is called.
@ -1881,9 +1881,9 @@ def executing_eagerly_v1():
False
Inside `tf.function`
after `tf.config.experimental_run_functions_eagerly(True)` is called:
after `tf.config.run_functions_eagerly(True)` is called:
>>> tf.config.experimental_run_functions_eagerly(True)
>>> tf.config.run_functions_eagerly(True)
>>> @tf.function
... def fn():
... with tf.init_scope():
@ -1892,7 +1892,7 @@ def executing_eagerly_v1():
>>> fn()
True
True
>>> tf.config.experimental_run_functions_eagerly(False)
>>> tf.config.run_functions_eagerly(False)
Inside a transformation function for `tf.dataset`:

View File

@ -41,6 +41,7 @@ from tensorflow.python.ops import resource_variable_ops
from tensorflow.python.platform import tf_logging as logging
from tensorflow.python.profiler import traceme
from tensorflow.python.training.tracking import base as trackable
from tensorflow.python.util import deprecation
from tensorflow.python.util import nest
from tensorflow.python.util import object_identity
from tensorflow.python.util import tf_decorator
@ -305,8 +306,11 @@ class UnliftedInitializerVariable(resource_variable_ops.UninitializedVariable):
RUN_FUNCTIONS_EAGERLY = False
@deprecation.deprecated(
None,
"Use tf.config.run_functions_eagerly instead of the experimental version.")
@tf_export("config.experimental_run_functions_eagerly")
def run_functions_eagerly(run_eagerly):
def experimental_run_functions_eagerly(run_eagerly):
"""Enables / disables eager execution of `tf.function`s.
Calling `tf.config.experimental_run_functions_eagerly(True)` will make all
@ -345,6 +349,60 @@ def run_functions_eagerly(run_eagerly):
Calling `tf.config.experimental_run_functions_eagerly(False)` will undo this
behavior.
Note: This flag has no effect on functions passed into tf.data transformations
as arguments. tf.data functions are never executed eagerly and are always
executed as a compiled Tensorflow Graph.
Args:
run_eagerly: Boolean. Whether to run functions eagerly.
"""
return run_functions_eagerly(run_eagerly)
@tf_export("config.run_functions_eagerly")
def run_functions_eagerly(run_eagerly):
"""Enables / disables eager execution of `tf.function`s.
Calling `tf.config.run_functions_eagerly(True)` will make all
invocations of `tf.function` run eagerly instead of running as a traced graph
function.
This can be useful for debugging or profiling. For example, let's say you
implemented a simple iterative sqrt function, and you want to collect the
intermediate values and plot the convergence. Appending the values to a list
in `@tf.function` normally wouldn't work since it will just record the Tensors
being traced, not the values. Instead, you can do the following.
>>> ys = []
>>>
>>> @tf.function
... def sqrt(x):
... y = x / 2
... d = y
... for _ in range(10):
... d /= 2
... if y * y < x:
... y += d
... else:
... y -= d
... ys.append(y.numpy())
... return y
>>>
>>> tf.config.run_functions_eagerly(True)
>>> sqrt(tf.constant(2.))
<tf.Tensor: shape=(), dtype=float32, numpy=1.4150391>
>>> ys
[1.5, 1.25, 1.375, 1.4375, 1.40625, 1.421875, 1.4140625, 1.4179688, 1.4160156,
1.4150391]
>>> tf.config.run_functions_eagerly(False)
Calling `tf.config.run_functions_eagerly(False)` will undo this
behavior.
Note: This flag has no effect on functions passed into tf.data transformations
as arguments. tf.data functions are never executed eagerly and are always
executed as a compiled Tensorflow Graph.
Args:
run_eagerly: Boolean. Whether to run functions eagerly.
"""
@ -352,9 +410,18 @@ def run_functions_eagerly(run_eagerly):
RUN_FUNCTIONS_EAGERLY = bool(run_eagerly)
@deprecation.deprecated(
None,
"Use tf.config.functions_run_eagerly instead of the experimental version.")
@tf_export("config.experimental_functions_run_eagerly")
def functions_run_eagerly():
def experimental_functions_run_eagerly():
"""Returns the value of the `experimental_run_functions_eagerly` setting."""
return functions_run_eagerly()
@tf_export("config.functions_run_eagerly")
def functions_run_eagerly():
"""Returns the value of the `run_functions_eagerly` setting."""
return RUN_FUNCTIONS_EAGERLY

View File

@ -534,7 +534,7 @@ class Model(training_lib.Model):
'is enabled.')
if not self.dynamic:
if self._run_eagerly is None:
# Respect `tf.config.experimental_run_functions_eagerly` unless
# Respect `tf.config.run_functions_eagerly` unless
# `run_eagerly` was explicitly passed to `compile`.
return def_function.RUN_FUNCTIONS_EAGERLY
else:

View File

@ -195,7 +195,7 @@ def pfor(loop_fn, iters, fallback_to_while_loop=True, parallel_iterations=None):
if functions_run_eagerly:
logging.warning(
"It looks like tf.function behavior was disabled, perhaps using "
"tf.config.experimental_run_functions_eagerly. Vectorization "
"tf.config.run_functions_eagerly. Vectorization "
"primitives (e.g. tf.vectorized_map) require tf.function to work. "
"These primitives will override the disable.")
def_function.run_functions_eagerly(False)

View File

@ -40,6 +40,10 @@ tf_module {
name: "experimental_run_functions_eagerly"
argspec: "args=[\'run_eagerly\'], varargs=None, keywords=None, defaults=None"
}
member_method {
name: "functions_run_eagerly"
argspec: "args=[], varargs=None, keywords=None, defaults=None"
}
member_method {
name: "get_logical_device_configuration"
argspec: "args=[\'device\'], varargs=None, keywords=None, defaults=None"
@ -60,6 +64,10 @@ tf_module {
name: "list_physical_devices"
argspec: "args=[\'device_type\'], varargs=None, keywords=None, defaults=[\'None\'], "
}
member_method {
name: "run_functions_eagerly"
argspec: "args=[\'run_eagerly\'], varargs=None, keywords=None, defaults=None"
}
member_method {
name: "set_logical_device_configuration"
argspec: "args=[\'device\', \'logical_devices\'], varargs=None, keywords=None, defaults=None"

View File

@ -40,6 +40,10 @@ tf_module {
name: "experimental_run_functions_eagerly"
argspec: "args=[\'run_eagerly\'], varargs=None, keywords=None, defaults=None"
}
member_method {
name: "functions_run_eagerly"
argspec: "args=[], varargs=None, keywords=None, defaults=None"
}
member_method {
name: "get_logical_device_configuration"
argspec: "args=[\'device\'], varargs=None, keywords=None, defaults=None"
@ -60,6 +64,10 @@ tf_module {
name: "list_physical_devices"
argspec: "args=[\'device_type\'], varargs=None, keywords=None, defaults=[\'None\'], "
}
member_method {
name: "run_functions_eagerly"
argspec: "args=[\'run_eagerly\'], varargs=None, keywords=None, defaults=None"
}
member_method {
name: "set_logical_device_configuration"
argspec: "args=[\'device\', \'logical_devices\'], varargs=None, keywords=None, defaults=None"