Removed accept_symbolic_tensors from internal_convert_to_tensor

It was only used from one (of the two) branches in args_to_matching_eager.

PiperOrigin-RevId: 255572203
This commit is contained in:
Sergei Lebedev 2019-06-28 03:12:23 -07:00 committed by TensorFlower Gardener
parent 86eedcea09
commit 2fd2eff6cb
2 changed files with 9 additions and 18 deletions

View File

@ -192,16 +192,20 @@ def args_to_matching_eager(l, ctx, default_dtype=None):
# remaining values.
ret = []
for t in l:
ret.append(internal_convert_to_tensor(
t, dtype,
preferred_dtype=default_dtype,
ctx=ctx,
accept_symbolic_tensors=False))
ret.append(
internal_convert_to_tensor(
t, dtype, preferred_dtype=default_dtype, ctx=ctx))
if dtype is None:
dtype = ret[-1].dtype
else:
ret = [internal_convert_to_tensor(t, dtype, ctx=ctx) for t in l]
# TODO(slebedev): consider removing this as it leaks a Keras concept.
# pylint: disable=protected-access
if any(ops._is_keras_symbolic_tensor(x) for x in ret):
raise core._SymbolicException(
"Using the symbolic output of a Keras layer during eager execution.")
# pylint: enable=protected-access
return dtype.as_datatype_enum, ret

View File

@ -1170,7 +1170,6 @@ def internal_convert_to_tensor(value,
as_ref=False,
preferred_dtype=None,
ctx=None,
accept_symbolic_tensors=True,
accept_composite_tensors=False):
"""Implementation of the public convert_to_tensor."""
if ctx is None:
@ -1187,18 +1186,6 @@ def internal_convert_to_tensor(value,
raise RuntimeError("Attempting to capture an EagerTensor without "
"building a function.")
return graph.capture(value, name=name)
elif ((not accept_symbolic_tensors) and isinstance(value, Tensor) and
ctx.executing_eagerly()):
# Found a symbolic tensor in an eager context.
# This happens when we use the Keras functional API (i.e. calling layers
# on the output of `keras.Input()`, which is symbolic) while eager
# execution is enabled.
if _is_keras_symbolic_tensor(value):
# If the graph of the tensor isn't the Keras graph, we should still
# fail, for the time being. TODO(fchollet): consider allowing
# all symbolic tensors to raise this exception in this case.
raise core._SymbolicException( # pylint: disable=protected-access
"Using the symbolic output of a Keras layer during eager execution.")
if dtype is not None:
dtype = dtypes.as_dtype(dtype)