Unverified Commit 5dfcc6be authored by guoshzhao's avatar guoshzhao Committed by GitHub
Browse files

Benchmarks: Add Feature - Add benchmark finish check according to...


Benchmarks: Add Feature - Add benchmark finish check according to num_warmup/num_steps and duration in ModelBenchmark class. (#25)

* add is_finished function

* reuse current time.
Co-authored-by: default avatarGuoshuai Zhao <guzhao@microsoft.com>
parent 3be4d8ee
......@@ -4,6 +4,7 @@
"""Module of the model-benchmark base class."""
import math
import time
from abc import abstractmethod
from superbench.common.utils import logger
......@@ -324,6 +325,7 @@ def _benchmark(self):
for precision in precision_need_to_run:
for model_action in self._args.model_action:
self._sub_benchmark_start_time = time.time()
if model_action == ModelAction.TRAIN:
if not self.__train(precision):
self._result.set_return_code(ReturnCode.MODEL_TRAIN_FAILURE)
......@@ -341,6 +343,17 @@ def _benchmark(self):
return True
def _is_finished(self, curr_step, curr_time):
total_steps = self._args.num_warmup + self._args.num_steps
if (
(self._args.duration > 0 and (curr_time - self._sub_benchmark_start_time) >= self._args.duration)
or (total_steps > 0 and curr_step >= total_steps)
):
return True
return False
def __process_model_result(self, model_action, precision, step_times):
"""Function to process raw results and save the summarized results.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment