[Mlir-commits] [mlir] 3734c07 - [mlir][sparse] Improving error messages for openSparseTensorCOO

wren romano llvmlistbot at llvm.org
Thu Mar 10 11:48:31 PST 2022


Author: wren romano
Date: 2022-03-10T11:48:19-08:00
New Revision: 3734c0783ee5160f6f0176598a0766d86a5ffeca

URL: https://github.com/llvm/llvm-project/commit/3734c0783ee5160f6f0176598a0766d86a5ffeca
DIFF: https://github.com/llvm/llvm-project/commit/3734c0783ee5160f6f0176598a0766d86a5ffeca.diff

LOG: [mlir][sparse] Improving error messages for openSparseTensorCOO

Reviewed By: aartbik

Differential Revision: https://reviews.llvm.org/D121333

Added: 
    

Modified: 
    mlir/lib/ExecutionEngine/SparseTensorUtils.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/lib/ExecutionEngine/SparseTensorUtils.cpp b/mlir/lib/ExecutionEngine/SparseTensorUtils.cpp
index 3f9a80947938e..6f3d5569f7782 100644
--- a/mlir/lib/ExecutionEngine/SparseTensorUtils.cpp
+++ b/mlir/lib/ExecutionEngine/SparseTensorUtils.cpp
@@ -663,7 +663,8 @@ static SparseTensorCOO<V> *openSparseTensorCOO(char *filename, uint64_t rank,
   // Open the file.
   FILE *file = fopen(filename, "r");
   if (!file) {
-    fprintf(stderr, "Cannot find %s\n", filename);
+    assert(filename && "Received nullptr for filename");
+    fprintf(stderr, "Cannot find file %s\n", filename);
     exit(1);
   }
   // Perform some file format dependent set up.
@@ -1180,6 +1181,10 @@ char *getTensorFilename(index_type id) {
   char var[80];
   sprintf(var, "TENSOR%" PRIu64, id);
   char *env = getenv(var);
+  if (!env) {
+    fprintf(stderr, "Environment variable %s is not set\n", var);
+    exit(1);
+  }
   return env;
 }
 


        


More information about the Mlir-commits mailing list