提交 db340f9e 编写于 作者: A Allen Lavoie 提交者: TensorFlower Gardener

Fix wrap_function on empty arguments

Caused by an implicit boolean check which should have been an explicit None check

PiperOrigin-RevId: 225096833
上级 45a6696c
...@@ -340,7 +340,7 @@ class Function(object): ...@@ -340,7 +340,7 @@ class Function(object):
TypeError: For invalid positional/keyword argument combinations. TypeError: For invalid positional/keyword argument combinations.
""" """
if self._arg_keywords is None or self._num_positional_args is None: if self._arg_keywords is None or self._num_positional_args is None:
if self._signature: if self._signature is not None:
if kwargs: if kwargs:
raise NotImplementedError( raise NotImplementedError(
"Keyword arguments not supported when calling a " "Keyword arguments not supported when calling a "
......
...@@ -19,6 +19,7 @@ from __future__ import print_function ...@@ -19,6 +19,7 @@ from __future__ import print_function
from tensorflow.python.eager import wrap_function from tensorflow.python.eager import wrap_function
from tensorflow.python.framework import constant_op
from tensorflow.python.framework import dtypes from tensorflow.python.framework import dtypes
from tensorflow.python.framework import ops from tensorflow.python.framework import ops
from tensorflow.python.framework import tensor_spec from tensorflow.python.framework import tensor_spec
...@@ -70,6 +71,14 @@ class WrapFunctionTest(test.TestCase): ...@@ -70,6 +71,14 @@ class WrapFunctionTest(test.TestCase):
f_pruned = f_wrapped.prune(x_in[0], [x_out[0]]) f_pruned = f_wrapped.prune(x_in[0], [x_out[0]])
self.assertAllEqual(f_pruned(ops.convert_to_tensor(2.0)), [4.0]) self.assertAllEqual(f_pruned(ops.convert_to_tensor(2.0)), [4.0])
def testNoArguments(self):
def f():
return constant_op.constant(1.)
f_wrapped = wrap_function.wrap_function(f, [])
self.assertAllEqual(1.0, f_wrapped())
if __name__ == '__main__': if __name__ == '__main__':
ops.enable_eager_execution() ops.enable_eager_execution()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册