Skip to content
Snippets Groups Projects
Commit 16397c55 authored by Yifan Zhao's avatar Yifan Zhao
Browse files

Use time() instead of time_ns() for older python versions

parent 0763a9d7
No related branches found
No related tags found
No related merge requests found
...@@ -173,7 +173,7 @@ class TorchApp(ModeledApp, abc.ABC): ...@@ -173,7 +173,7 @@ class TorchApp(ModeledApp, abc.ABC):
"""Measure the QoS and performance of Module with given approximation """Measure the QoS and performance of Module with given approximation
empirically (i.e., by running the Module on the dataset).""" empirically (i.e., by running the Module on the dataset)."""
from time import time_ns from time import time
from tqdm import tqdm from tqdm import tqdm
dataloader = self.test_loader if is_test else self.tune_loader dataloader = self.test_loader if is_test else self.tune_loader
...@@ -182,13 +182,13 @@ class TorchApp(ModeledApp, abc.ABC): ...@@ -182,13 +182,13 @@ class TorchApp(ModeledApp, abc.ABC):
approxed = self._apply_knobs(with_approxes) approxed = self._apply_knobs(with_approxes)
qoses = [] qoses = []
time_begin = time_ns() / (10 ** 9) time_begin = time()
for inputs, targets in dataloader: for inputs, targets in dataloader:
inputs = move_to_device_recursively(inputs, self.device) inputs = move_to_device_recursively(inputs, self.device)
targets = move_to_device_recursively(targets, self.device) targets = move_to_device_recursively(targets, self.device)
outputs = approxed(inputs) outputs = approxed(inputs)
qoses.append(self.tensor_to_qos(outputs, targets)) 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))) qos = float(self.combine_qos(np.array(qoses)))
return qos, time_end - time_begin return qos, time_end - time_begin
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment