From feb3489722728944d99bef4845b1b90c3b0817ad Mon Sep 17 00:00:00 2001 From: Yuxin Wu Date: Wed, 24 Apr 2019 20:57:32 -0700 Subject: [PATCH] Check empty_fetches without using nest.flatten --- tensorflow/python/debug/wrappers/framework.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/tensorflow/python/debug/wrappers/framework.py b/tensorflow/python/debug/wrappers/framework.py index 6cc9c67f2f0dd7..b16871fc3a2038 100644 --- a/tensorflow/python/debug/wrappers/framework.py +++ b/tensorflow/python/debug/wrappers/framework.py @@ -111,6 +111,8 @@ from __future__ import division from __future__ import print_function +import collections + import abc import re import threading @@ -460,7 +462,19 @@ def run(self, "but are used simultaneously.") self.increment_run_call_count() - empty_fetches = not nest.flatten(fetches) + + def is_empty(x): + """Check whether a possibly nested structure is empty.""" + if not nest.is_nested(x): + return False + if isinstance(x, collections.Mapping): + return is_empty(list(x.values())) + for item in x: + if not is_empty(item): + return False + return True + + empty_fetches = is_empty(fetches) if empty_fetches: tf_logging.info( "Due to empty fetches, tfdbg Session wrapper is letting a "