From b20d11d36c3baa2e7c9b49d423a39c1e5cc0ceac Mon Sep 17 00:00:00 2001 From: Alexandre Passos Date: Thu, 16 Nov 2017 10:34:42 -0800 Subject: [PATCH] Ops with no outputs in eager should return None instead of [] PiperOrigin-RevId: 175983704 --- tensorflow/python/eager/ops_test.py | 4 ++++ tensorflow/python/eager/python_eager_op_gen.cc | 2 ++ 2 files changed, 6 insertions(+) diff --git a/tensorflow/python/eager/ops_test.py b/tensorflow/python/eager/ops_test.py index 51550c9f514..70e23b93117 100644 --- a/tensorflow/python/eager/ops_test.py +++ b/tensorflow/python/eager/ops_test.py @@ -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() diff --git a/tensorflow/python/eager/python_eager_op_gen.cc b/tensorflow/python/eager/python_eager_op_gen.cc index 374894733af..956fbdac50d 100644 --- a/tensorflow/python/eager/python_eager_op_gen.cc +++ b/tensorflow/python/eager/python_eager_op_gen.cc @@ -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_;