Skip to content

Commit c0a2a3b

Browse files
Add a new method SummaryWriter.flush() (#20607)
Summary: Pull Request resolved: #20607 Add a new method SummaryWriter.flush() that iterates through all of the FileWriters and flushes them Reviewed By: orionr Differential Revision: D15380124 fbshipit-source-id: 1975f3f61c5ae3754552bfdb23f2cd78f687d19f
1 parent f215db9 commit c0a2a3b

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

torch/utils/tensorboard/writer.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -837,6 +837,16 @@ def add_custom_scalars(self, layout):
837837
"""
838838
self._get_file_writer().add_summary(custom_scalars(layout))
839839

840+
def flush(self):
841+
"""Flushes the event file to disk.
842+
Call this method to make sure that all pending events have been written to
843+
disk.
844+
"""
845+
if self.all_writers is None:
846+
return
847+
for writer in self.all_writers.values():
848+
writer.flush()
849+
840850
def close(self):
841851
if self.all_writers is None:
842852
return # ignore double close

0 commit comments

Comments
 (0)