Ops with no outputs in eager should return None instead of []

PiperOrigin-RevId: 175983704
This commit is contained in:
Alexandre Passos 2017-11-16 10:34:42 -08:00 committed by TensorFlower Gardener
parent de8453ff5d
commit b20d11d36c
2 changed files with 6 additions and 0 deletions

View File

@ -30,6 +30,7 @@ from tensorflow.python.framework import tensor_shape
from tensorflow.python.framework import test_util
from tensorflow.python.layers import core
from tensorflow.python.ops import array_ops
from tensorflow.python.ops import control_flow_ops
from tensorflow.python.ops import math_ops
from tensorflow.python.ops import random_ops
from tensorflow.python.ops import sparse_ops
@ -349,6 +350,9 @@ class OpsTest(test_util.TensorFlowTestCase):
x = constant_op.constant(3.1415)
self.assertEqual('3.14', '{:.2f}'.format(x))
def testNoOpIsNone(self):
self.assertTrue(control_flow_ops.no_op() is None)
if __name__ == '__main__':
test.main()

View File

@ -531,6 +531,8 @@ string GenEagerPythonOp::Code() {
strings::StrAppend(&result_, " _result = _", op_def_.name(),
"Output._make(_result)\n");
}
} else {
strings::StrAppend(&result_, " _result = None\n");
}
strings::StrAppend(&result_, " return _result\n\n");
return prelude_ + result_;