From 77de7e215b75a7af94de7460dd48833fb5a25efe Mon Sep 17 00:00:00 2001
From: Yifan Zhao <yifanz16@illinois.edu>
Date: Fri, 29 Jan 2021 16:11:54 -0600
Subject: [PATCH] Changed add_baseline_to_knobs to add knobs in order

---
 predtuner/approxapp.py | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/predtuner/approxapp.py b/predtuner/approxapp.py
index f82544e..7564bb8 100644
--- a/predtuner/approxapp.py
+++ b/predtuner/approxapp.py
@@ -93,11 +93,10 @@ class ApproxApp(abc.ABC):
         return baseline_knob
 
     def add_baseline_to_knobs(self, approxes: KnobsT):
-        approxes = approxes.copy()
-        for op_name in self.ops:
-            if op_name not in approxes:
-                approxes[op_name] = self.baseline_knob.name
-        return approxes
+        return {
+            op_name: approxes.get(op_name, self.baseline_knob.name)
+            for op_name in self.ops
+        }
 
 
 class BaselineKnob(ApproxKnob):
@@ -230,7 +229,7 @@ class ApproxTuner(Generic[T]):
         filepath = Path(filepath)
         os.makedirs(filepath.parent, exist_ok=True)
         with filepath.open("w") as f:
-            f.write(encode(self.kept_configs, indent=2))
+            f.write(encode(self.best_configs, indent=2))
 
     def plot_configs(self) -> plt.Figure:
         if not self.tuned:
-- 
GitLab