summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwren romano <2998727+wrengr@users.noreply.github.com>2022-03-09 15:53:04 -0800
committerwren romano <2998727+wrengr@users.noreply.github.com>2022-03-10 11:48:19 -0800
commit3734c0783ee5160f6f0176598a0766d86a5ffeca (patch)
treede3bbd7d4970c152efbd3f44ba3c40eeecf2dbc7
parent9ce6b1ca86cdd1c088d4a5056e173d658126ec72 (diff)
[mlir][sparse] Improving error messages for openSparseTensorCOO
Reviewed By: aartbik Differential Revision: https://reviews.llvm.org/D121333
-rw-r--r--mlir/lib/ExecutionEngine/SparseTensorUtils.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/mlir/lib/ExecutionEngine/SparseTensorUtils.cpp b/mlir/lib/ExecutionEngine/SparseTensorUtils.cpp
index 3f9a80947938..6f3d5569f778 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;
}