diff --git a/hpvm/projects/keras/frontend/approxhpvm_translator.py b/hpvm/projects/keras/frontend/approxhpvm_translator.py
index 7515bf67da0d4cc604bfcd92450fe78579fc56ac..32a4839ee6625a3d0c1c6e1f8284c8c92f512c09 100644
--- a/hpvm/projects/keras/frontend/approxhpvm_translator.py
+++ b/hpvm/projects/keras/frontend/approxhpvm_translator.py
@@ -211,7 +211,7 @@ class TensorRtTranslator:
     self.knobs_str = ""
     self.cur_height = 32    
     self.cur_width = 32     
-    self.op_count = 1       
+    self.op_count = 0       
     
     
 
diff --git a/hpvm/projects/keras/frontend/hpvm_dfg_translator.py b/hpvm/projects/keras/frontend/hpvm_dfg_translator.py
index c631b605cb1bb01862ef6c493676ee299de6beb4..d14c64bbf406e991b0b623fa3b56f938153e7fe8 100644
--- a/hpvm/projects/keras/frontend/hpvm_dfg_translator.py
+++ b/hpvm/projects/keras/frontend/hpvm_dfg_translator.py
@@ -751,7 +751,8 @@ class HPVMTranslator:
 
      abs_src_path = str(os.getcwd()) + "/" + src_dir 
      tuner_main_func_str += "auto* fp = open_fifo(\"" + abs_src_path + "/hpvm_fifo_w\", \"wb\"); \n\n"
-
+     tuner_main_func_str += "float total_accuracy = 0; \n"
+     
      tuner_main_func_str += self.genBatchLoop(test_data.shape, batch_size)
      tuner_main_func_str += self.genBatchInput(test_data.shape, "input_pth")
 
@@ -765,12 +766,14 @@ class HPVMTranslator:
     
      tuner_main_func_str += "hpvm_request_tensor(result, 0); \n\n"
      tuner_main_func_str += "uint32_t* labels = readLabelsBatch3(labels_pth.c_str(), start, end); \n"
-     tuner_main_func_str += "computeAccuracy3(labels, result); \n"
+     tuner_main_func_str += "total_accuracy += computeAccuracy3(labels, result) * batch_size  ; \n"
 
      tuner_main_func_str += "\nfifo_write_batch(fp, result); \n"     
 
      tuner_main_func_str += self.endBatchLoop()
-    
+
+     tuner_main_func_str += "write_accuracy(total_accuracy / test_input_size); \n"
+     tuner_main_func_str += "fclose(fp); \n"
      tuner_main_func_str += HPVM_cleanup + "(); \n "
 
      tuner_main_func_str += "\n}\n\n"  # End of FIFO loop
@@ -783,6 +786,8 @@ class HPVMTranslator:
 
   def addFIFORoutines(self, src_dir):
 
+    abs_src_dir = str(os.getcwd()) + "/" + src_dir 
+
     FIFO_str = """
    
  FILE *open_fifo(const char *path, const char *mode) { 
@@ -797,7 +802,7 @@ class HPVMTranslator:
 
 
 int fifo_wait() {
-    auto* fp = open_fifo(\"/tmp/lenet_mnist_tune/hpvm_fifo_r\", \"r\");
+    auto* fp = open_fifo(\"""" + abs_src_dir + """/hpvm_fifo_r\", \"r\");
     const int maxn = 100;
     char linebuf[maxn];
     fgets(linebuf, maxn, fp);
@@ -822,6 +827,14 @@ void fifo_write_batch(FILE *fp, void *output_ptr) {
     fwrite(output->host_data, 1, output->size_in_bytes, fp);
 }
 
+
+void write_accuracy(float accuracy) {
+  std::ofstream fout("final_accuracy");
+  fout << std::fixed << accuracy;
+}
+
+
+
 """
 
     return FIFO_str