From 037cc9e406425d7ad893b2b772248551e6dce516 Mon Sep 17 00:00:00 2001 From: Yifan Zhao <yifanz16@illinois.edu> Date: Wed, 17 Mar 2021 19:19:58 -0500 Subject: [PATCH] Use time() instead of time_ns() for older python versions --- predtuner/pipedbin.py | 6 +++--- predtuner/torchapp.py | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/predtuner/pipedbin.py b/predtuner/pipedbin.py index b5d525d..8882370 100644 --- a/predtuner/pipedbin.py +++ b/predtuner/pipedbin.py @@ -92,11 +92,11 @@ class PipedBinaryApp(ModeledApp): def empirical_measure_qos_cost( self, with_approxes: KnobsT, is_test: bool ) -> Tuple[float, float]: - from time import time_ns + from time import time - time_begin = time_ns() / (10 ** 9) + time_begin = time() _, qos = self._run_on_knobs(with_approxes, is_test) - time_end = time_ns() / (10 ** 9) + time_end = time() return qos, time_end - time_begin def get_models(self) -> List[Union["IPerfModel", "IQoSModel"]]: diff --git a/predtuner/torchapp.py b/predtuner/torchapp.py index 33ceaad..92ca90c 100644 --- a/predtuner/torchapp.py +++ b/predtuner/torchapp.py @@ -172,7 +172,7 @@ class TorchApp(ModeledApp, abc.ABC): """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 time import time from tqdm import tqdm dataloader = self.test_loader if is_test else self.tune_loader @@ -181,13 +181,13 @@ class TorchApp(ModeledApp, abc.ABC): approxed = self._apply_knobs(with_approxes) qoses = [] - time_begin = time_ns() / (10 ** 9) + time_begin = time() for inputs, targets in dataloader: inputs = move_to_device_recursively(inputs, self.device) targets = move_to_device_recursively(targets, self.device) outputs = approxed(inputs) qoses.append(self.tensor_to_qos(outputs, targets)) - time_end = time_ns() / (10 ** 9) + time_end = time() qos = float(self.combine_qos(np.array(qoses))) return qos, time_end - time_begin -- GitLab