Skip to content

Commit 3734c07

Browse files
committed
[mlir][sparse] Improving error messages for openSparseTensorCOO
Reviewed By: aartbik Differential Revision: https://reviews.llvm.org/D121333
1 parent 9ce6b1c commit 3734c07

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

mlir/lib/ExecutionEngine/SparseTensorUtils.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -663,7 +663,8 @@ static SparseTensorCOO<V> *openSparseTensorCOO(char *filename, uint64_t rank,
663663
// Open the file.
664664
FILE *file = fopen(filename, "r");
665665
if (!file) {
666-
fprintf(stderr, "Cannot find %s\n", filename);
666+
assert(filename && "Received nullptr for filename");
667+
fprintf(stderr, "Cannot find file %s\n", filename);
667668
exit(1);
668669
}
669670
// Perform some file format dependent set up.
@@ -1180,6 +1181,10 @@ char *getTensorFilename(index_type id) {
11801181
char var[80];
11811182
sprintf(var, "TENSOR%" PRIu64, id);
11821183
char *env = getenv(var);
1184+
if (!env) {
1185+
fprintf(stderr, "Environment variable %s is not set\n", var);
1186+
exit(1);
1187+
}
11831188
return env;
11841189
}
11851190

0 commit comments

Comments
 (0)