From 2477abd6e0fc8338c4fe1af0227d9d0ff9dffc0f Mon Sep 17 00:00:00 2001
From: Yifan Zhao <yifanz16@illinois.edu>
Date: Mon, 15 Mar 2021 15:57:33 -0500
Subject: [PATCH] Fixed a bug in qos computation with model p1

---
 examples/tune_vgg16_cifar10.py | 1 +
 predtuner/torchapp.py          | 1 +
 2 files changed, 2 insertions(+)

diff --git a/examples/tune_vgg16_cifar10.py b/examples/tune_vgg16_cifar10.py
index 9530bc0..1e6caa6 100644
--- a/examples/tune_vgg16_cifar10.py
+++ b/examples/tune_vgg16_cifar10.py
@@ -47,6 +47,7 @@ tuner.tune(
     qos_keep_threshold=3.0,  # QoS threshold for which we actually keep the thresholds
     is_threshold_relative=True,  # Thresholds are relative to baseline -- baseline_acc - 2.1
     cost_model="cost_linear",  # Use linear performance predictor
+    qos_model="qos_p1",  # Use P1 QoS predictor
 )
 # Save configs here when you're done
 tuner.dump_configs("tuner_results/vgg16_cifar10_configs.json")
diff --git a/predtuner/torchapp.py b/predtuner/torchapp.py
index 33ceaad..dac293f 100644
--- a/predtuner/torchapp.py
+++ b/predtuner/torchapp.py
@@ -153,6 +153,7 @@ class TorchApp(ModeledApp, abc.ABC):
                 target = move_to_device_recursively(target, self.device)
                 qos = self.tensor_to_qos(tensor_output[begin:end], target)
                 qoses.append(qos)
+                begin = end
             return self.combine_qos(np.array(qoses))
 
         p1_storage = self.model_storage / "p1.pkl" if self.model_storage else None
-- 
GitLab