From 16397c55c4e05c53c13f0979571177ecde045649 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/torchapp.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/predtuner/torchapp.py b/predtuner/torchapp.py
index dac293f..f2bc4ee 100644
--- a/predtuner/torchapp.py
+++ b/predtuner/torchapp.py
@@ -173,7 +173,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
@@ -182,13 +182,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