Fix wrap_function on empty arguments
Caused by an implicit boolean check which should have been an explicit None check PiperOrigin-RevId: 225096833
This commit is contained in:
parent
45a6696c0a
commit
db340f9efc
@ -340,7 +340,7 @@ class Function(object):
|
||||
TypeError: For invalid positional/keyword argument combinations.
|
||||
"""
|
||||
if self._arg_keywords is None or self._num_positional_args is None:
|
||||
if self._signature:
|
||||
if self._signature is not None:
|
||||
if kwargs:
|
||||
raise NotImplementedError(
|
||||
"Keyword arguments not supported when calling a "
|
||||
|
@ -19,6 +19,7 @@ from __future__ import print_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 ops
|
||||
from tensorflow.python.framework import tensor_spec
|
||||
@ -70,6 +71,14 @@ class WrapFunctionTest(test.TestCase):
|
||||
f_pruned = f_wrapped.prune(x_in[0], [x_out[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__':
|
||||
ops.enable_eager_execution()
|
||||
|
Loading…
Reference in New Issue
Block a user