diff --git a/mmengine/runner/log_processor.py b/mmengine/runner/log_processor.py index b278cf06fd..34d59fd0a5 100644 --- a/mmengine/runner/log_processor.py +++ b/mmengine/runner/log_processor.py @@ -307,7 +307,8 @@ def get_log_after_epoch(self, tag[key] = value # Log other messages. log_items = [] - for name, val in chain(tag.items(), non_scalar_tag.items()): + for name, val in chain(tag.items(), non_scalar_tag.items(), + time_tag.items()): if isinstance(val, float): val = f'{val:.{self.num_digits}f}' if isinstance(val, (torch.Tensor, np.ndarray)): @@ -316,9 +317,6 @@ def get_log_after_epoch(self, log_items.append(f'{name}: {val}') log_str += ' '.join(log_items) - for name, val in time_tag.items(): - log_str += f'{name}: {val:.{self.num_digits}f} ' - if with_non_scalar: tag.update(non_scalar_tag) tag.update(time_tag) diff --git a/tests/test_runner/test_log_processor.py b/tests/test_runner/test_log_processor.py index 2009db708b..c1fc833eea 100644 --- a/tests/test_runner/test_log_processor.py +++ b/tests/test_runner/test_log_processor.py @@ -161,7 +161,7 @@ def test_log_val(self, by_epoch, mode, log_with_hierarchy): return_value=non_scalar_logs) _, out = log_processor.get_log_after_epoch(self.runner, 2, mode) expect_metric_str = ("accuracy: 0.9000 recall: {'cat': 1, 'dog': 0} " - 'cm: \ntensor([1, 2, 3])\ndata_time: 1.0000 ') + 'cm: \ntensor([1, 2, 3])\n data_time: 1.0000') if by_epoch: if mode == 'test': assert out == 'Epoch(test) [5/5] ' + expect_metric_str