Skip to content

Commit bc58a40

Browse files
A. Unique TensorFlowerkeveman
authored andcommitted
Allow PyFunc to accept inputs of length zero. This is useful if a python
function is producing data for the rest of the Tensorflow graph. Change: 113597306
1 parent 0db132c commit bc58a40

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

‎tensorflow/core/ops/script_ops.cc‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ REGISTER_OP("PyFunc")
2121
.Input("input: Tin")
2222
.Output("output: Tout")
2323
.Attr("token: string")
24-
.Attr("Tin: list(type)")
24+
.Attr("Tin: list(type) >= 0")
2525
.Attr("Tout: list(type)")
2626
.Doc(R"doc(
2727
Invokes a python function to compute func(input)->output.

‎tensorflow/python/kernel_tests/py_func_test.py‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,11 @@ def testLarge(self):
8080
for _ in xrange(100):
8181
sess.run([y[0].op, z[0].op])
8282

83+
def testNoInput(self):
84+
with self.test_session():
85+
x, = tf.py_func(lambda: 42.0, [], [tf.float64])
86+
self.assertAllClose(x.eval(), 42.0)
87+
8388
def testCleanup(self):
8489
for _ in range(1000):
8590
g = tf.Graph()

0 commit comments

Comments
 (0)