From 15bf2a7e76087abbaeb845f432632c0af74b4632 Mon Sep 17 00:00:00 2001 From: Yanhua Sun Date: Tue, 26 May 2020 13:07:22 -0700 Subject: [PATCH] tf.function invocation optimization, remove redundant list converter The input is already a list, remove redundant convert, which is also expensive PiperOrigin-RevId: 313253733 Change-Id: I0a50c04fbf4416ae6ca71fe5d147b4d56b129641 --- tensorflow/python/eager/function.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tensorflow/python/eager/function.py b/tensorflow/python/eager/function.py index 97708f056c2..ce495d772d0 100644 --- a/tensorflow/python/eager/function.py +++ b/tensorflow/python/eager/function.py @@ -1831,9 +1831,9 @@ class ConcreteFunction(object): `args` and `kwargs`. """ return self._call_flat( - (t for t in nest.flatten((args, kwargs), expand_composites=True) + [t for t in nest.flatten((args, kwargs), expand_composites=True) if isinstance(t, (ops.Tensor, - resource_variable_ops.BaseResourceVariable))), + resource_variable_ops.BaseResourceVariable))], captured_inputs=self.captured_inputs, cancellation_manager=cancellation_manager) @@ -1854,7 +1854,6 @@ class ConcreteFunction(object): Raises: ValueError: If `args` contains anything other than Tensors or Variables. """ - args = list(args) ctx = context.context() executing_eagerly = ctx.executing_eagerly()