From: A. Unique TensorFlower Date: Tue, 27 Mar 2018 02:46:51 +0000 (-0700) Subject: Include additional cases for evaluating the fqn annotation. X-Git-Tag: tflite-v0.1.7~93^2~1^2~15 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=591b6a7709fa05d490b0c718253492dfad35557f;p=platform%2Fupstream%2Ftensorflow.git Include additional cases for evaluating the fqn annotation. PiperOrigin-RevId: 190564036 --- diff --git a/tensorflow/contrib/autograph/pyct/static_analysis/live_values.py b/tensorflow/contrib/autograph/pyct/static_analysis/live_values.py index 5f81335..53ae154 100644 --- a/tensorflow/contrib/autograph/pyct/static_analysis/live_values.py +++ b/tensorflow/contrib/autograph/pyct/static_analysis/live_values.py @@ -59,9 +59,15 @@ class LiveValueResolver(transformer.Base): obj = self.context.namespace[node.id] anno.setanno(node, 'live_val', obj) if hasattr(obj, '__name__'): + anno.setanno(node, 'fqn', (obj.__name__,)) + elif hasattr(obj, '__class__'): + obj_class = obj.__class__ + anno.setanno(node, 'fqn', + (obj_class.__module__, obj_class.__name__)) + else: # If the symbol value is for example a primitive, then it will not # have a name. - anno.setanno(node, 'fqn', (obj.__name__,)) + pass else: pass # TODO(mdan): Should we raise an error here? diff --git a/tensorflow/contrib/autograph/pyct/static_analysis/live_values_test.py b/tensorflow/contrib/autograph/pyct/static_analysis/live_values_test.py index b664396..69e428b 100644 --- a/tensorflow/contrib/autograph/pyct/static_analysis/live_values_test.py +++ b/tensorflow/contrib/autograph/pyct/static_analysis/live_values_test.py @@ -18,6 +18,8 @@ from __future__ import absolute_import from __future__ import division from __future__ import print_function +import six + from tensorflow.contrib.autograph.pyct import anno from tensorflow.contrib.autograph.pyct import context from tensorflow.contrib.autograph.pyct import parser @@ -75,7 +77,11 @@ class LiveValuesResolverTest(test.TestCase): node = self._parse_and_analyze(test_fn, {'a': True}) retval_node = node.body[0].body[0].value - self.assertFalse(anno.hasanno(retval_node, 'fqn')) + if six.PY2: + self.assertEqual( + anno.getanno(retval_node, 'fqn'), ('__builtin__', 'bool')) + else: + self.assertEqual(anno.getanno(retval_node, 'fqn'), ('builtins', 'bool')) def test_namespace(self):