diff --git a/predtuner/torchapp.py b/predtuner/torchapp.py index 0e6fc287be85cc0b73766ce91c1034a6e07186d1..4c9618a96739c612a088d275f594e258a8ff223d 100644 --- a/predtuner/torchapp.py +++ b/predtuner/torchapp.py @@ -9,8 +9,14 @@ from torch.utils.data.dataloader import DataLoader from ._logging import PathLike from .approxapp import ApproxKnob, BaselineKnob, KnobsT -from .modeledapp import (IPerfModel, IQoSModel, LinearPerfModel, ModeledApp, - QoSModelP1, QoSModelP2) +from .modeledapp import ( + IPerfModel, + IQoSModel, + LinearPerfModel, + ModeledApp, + QoSModelP1, + QoSModelP2, +) from .torchutil import ModuleIndexer, get_summary, move_to_device_recursively @@ -161,14 +167,17 @@ class TorchApp(ModeledApp, abc.ABC): @torch.no_grad() def empirical_measure_qos_perf( - self, with_approxes: KnobsT, is_test: bool + self, with_approxes: KnobsT, is_test: bool, progress: bool = False ) -> Tuple[float, float]: """Measure the QoS and performance of Module with given approximation empirically (i.e., by running the Module on the dataset).""" from time import time_ns + from tqdm import tqdm dataloader = self.test_loader if is_test else self.tune_loader + if progress: + dataloader = tqdm(dataloader) approxed = self._apply_knobs(with_approxes) qoses = [] diff --git a/test/test_model_zoo_acc.py b/test/test_model_zoo_acc.py index 55f770df42fe44bc0ffcd1b49f43a19b6d73c006..e4028814ae2b0c510073af01626fd87a19f36d22 100644 --- a/test/test_model_zoo_acc.py +++ b/test/test_model_zoo_acc.py @@ -34,5 +34,5 @@ class TestModelZooAcc(unittest.TestCase): ) tune = DataLoader(dataset, batchsize) app = TorchApp("", network, tune, tune, get_knobs_from_file(), accuracy) - qos, _ = app.measure_qos_perf({}, False) + qos, _ = app.empirical_measure_qos_perf({}, False, True) self.assertAlmostEqual(qos, target_acc)