From 36f9b09b162732f6fc417c824f5c927de31a7670 Mon Sep 17 00:00:00 2001
From: Hashim Sharif <hsharif3@miranda.cs.illinois.edu>
Date: Wed, 30 Jun 2021 23:45:46 -0500
Subject: [PATCH] Adding check for file exists calib.txt

---
 hpvm/lib/Transforms/HPVM2NVDLA/HPVM2NVDLAPass.cpp | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/hpvm/lib/Transforms/HPVM2NVDLA/HPVM2NVDLAPass.cpp b/hpvm/lib/Transforms/HPVM2NVDLA/HPVM2NVDLAPass.cpp
index 977e4b6075..1f5f5be849 100644
--- a/hpvm/lib/Transforms/HPVM2NVDLA/HPVM2NVDLAPass.cpp
+++ b/hpvm/lib/Transforms/HPVM2NVDLA/HPVM2NVDLAPass.cpp
@@ -1019,7 +1019,7 @@ void CGT_NVDLA::generateGemmLayer(DFLeafNode* N, const IntrinsicInst *II) {
 
 		// Get bias mode
 		//if(KernelCHConst->getZExtValue() == numOutputs)
-			biasMode = BiasMode::bCHANNEL;
+		biasMode = BiasMode::bCHANNEL;
 		//else
 		//	biasMode = BiasMode::bUNIFORM;
 	}
@@ -1605,6 +1605,8 @@ fail:
     return e;
 }
 
+
+/* USED in FP16 model: This function for dummy initialization of scales (name is misleading)  */
 NvDlaError CGT_NVDLA::generateTensorScales(const TestAppArgs* appArgs, TestInfo* i, nvdla::INetwork* network) {
     NvDlaError e = NvDlaSuccess;
 
@@ -1649,7 +1651,7 @@ fail:
 }
 
 
-
+/* This s the real tensor scale initialization routine */
 NvDlaError CGT_NVDLA::readTensorScales(const TestAppArgs* appArgs, TestInfo *i, nvdla::INetwork* network) {
 
   NvDlaError e = NvDlaSuccess;
@@ -1657,8 +1659,14 @@ NvDlaError CGT_NVDLA::readTensorScales(const TestAppArgs* appArgs, TestInfo *i,
     std::string calibTableFile = appArgs->calibTable;
 
     errs() << "***********READING TENSOR SCALESi*************\n";
-    
     std::ifstream infile(calibTableFile.c_str());
+
+    if (!infile.good()){
+
+      printf("ERROR: calib.txt could not be found. Place in current directory ** \n\n");
+      abort();
+    }
+    
     std::string line;
     std::map<std::string, float> LayerNameToScaleMap;
     while (std::getline(infile, line)) {
-- 
GitLab