Skip to content

Commit

Permalink
Remove automatic control dep wrapping from layers in v2.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 316638920
Change-Id: Iad14b1a4b0b14052f34784401b375a14b49a7641
  • Loading branch information
pavithrasv authored and tensorflower-gardener committed Jun 16, 2020
1 parent aa99cf2 commit 8950c47
Showing 1 changed file with 1 addition and 12 deletions.
13 changes: 1 addition & 12 deletions tensorflow/python/keras/engine/base_layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
from tensorflow.python.eager import execute
from tensorflow.python.eager import function
from tensorflow.python.eager import monitoring
from tensorflow.python.framework import auto_control_deps
from tensorflow.python.framework import constant_op
from tensorflow.python.framework import dtypes
from tensorflow.python.framework import errors
Expand Down Expand Up @@ -1105,17 +1104,7 @@ def _convert_non_tensor(x):

try:
with ops.enable_auto_cast_variables(self._compute_dtype_object):
# Add auto_control_deps in V2 when they are not already added by
# a `tf.function`.
if (ops.executing_eagerly_outside_functions() and
not base_layer_utils.is_in_eager_or_tf_function()):
with auto_control_deps.AutomaticControlDependencies() as acd:
outputs = call_fn(cast_inputs, *args, **kwargs)
# Wrap Tensors in `outputs` in `tf.identity` to avoid
# circular dependencies.
outputs = base_layer_utils.mark_as_return(outputs, acd)
else:
outputs = call_fn(cast_inputs, *args, **kwargs)
outputs = call_fn(cast_inputs, *args, **kwargs)

except errors.OperatorNotAllowedInGraphError as e:
raise TypeError('You are attempting to use Python control '
Expand Down

0 comments on commit 8950c47

Please sign in to comment.