aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/python/client
diff options
context:
space:
mode:
authorGravatar A. Unique TensorFlower <gardener@tensorflow.org>2018-09-19 01:30:07 -0700
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2018-09-19 01:33:53 -0700
commit6967287715a097c8b009b52010c53247ab658232 (patch)
tree69f3670067e91b70bf7c174e83a6397e073235bd /tensorflow/python/client
parent50125bf0d8ee9f47b868211f62cb545c5701a032 (diff)
Modify Timeline Analysis to consider allocations in order.
PiperOrigin-RevId: 213589710
Diffstat (limited to 'tensorflow/python/client')
-rw-r--r--tensorflow/python/client/timeline.py3
-rw-r--r--tensorflow/python/client/timeline_test.py4
2 files changed, 3 insertions, 4 deletions
diff --git a/tensorflow/python/client/timeline.py b/tensorflow/python/client/timeline.py
index 1e96ac5ed4..c3f38294b5 100644
--- a/tensorflow/python/client/timeline.py
+++ b/tensorflow/python/client/timeline.py
@@ -588,7 +588,8 @@ class Timeline(object):
alloc_tensor_set = set()
alloc_maxes[allocator] = AllocationMaximum(
timestamp=0, num_bytes=0, tensors=set())
- for time, num_bytes, name in alloc_list:
+ for time, num_bytes, name in sorted(
+ alloc_list, key=lambda allocation: allocation[0]):
total_bytes += num_bytes
if num_bytes < 0:
alloc_tensor_set.discard(name)
diff --git a/tensorflow/python/client/timeline_test.py b/tensorflow/python/client/timeline_test.py
index 281d7f2e2b..032bbf7c4e 100644
--- a/tensorflow/python/client/timeline_test.py
+++ b/tensorflow/python/client/timeline_test.py
@@ -134,7 +134,7 @@ class TimelineTest(test.TestCase):
ctf = tl.generate_chrome_trace_format()
self._validateTrace(ctf)
- def disabled_testAnalysisAndAllocations(self):
+ def testAnalysisAndAllocations(self):
run_options = config_pb2.RunOptions(
trace_level=config_pb2.RunOptions.FULL_TRACE)
run_metadata = config_pb2.RunMetadata()
@@ -163,8 +163,6 @@ class TimelineTest(test.TestCase):
# At least num1 + num2, both float32s (4 bytes each)
self.assertGreaterEqual(cpu_max.num_bytes, 8)
self.assertGreater(cpu_max.timestamp, 0)
- self.assertTrue('num1' in cpu_max.tensors or 'num1/read' in cpu_max.tensors)
- self.assertTrue('num2' in cpu_max.tensors or 'num2/read' in cpu_max.tensors)
def testManyCPUs(self):
run_options = config_pb2.RunOptions(