@@ -255,11 +255,13 @@ struct SuiteSparseTensors {
255
255
SuiteSparseTensors () {
256
256
auto ssTensorPath = getTacoTensorPath ();
257
257
ssTensorPath += " suitesparse/" ;
258
- for (auto & entry : std::experimental::filesystem::directory_iterator (ssTensorPath)) {
259
- std::string f (entry.path ());
260
- // Check that the filename ends with .mtx.
261
- if (f.compare (f.size () - 4 , 4 , " .mtx" ) == 0 ) {
262
- this ->tensors .push_back (entry.path ());
258
+ if (std::experimental::filesystem::exists (ssTensorPath)) {
259
+ for (auto & entry : std::experimental::filesystem::directory_iterator (ssTensorPath)) {
260
+ std::string f (entry.path ());
261
+ // Check that the filename ends with .mtx.
262
+ if (f.compare (f.size () - 4 , 4 , " .mtx" ) == 0 ) {
263
+ this ->tensors .push_back (entry.path ());
264
+ }
263
265
}
264
266
}
265
267
}
@@ -269,6 +271,10 @@ struct SuiteSparseTensors {
269
271
SuiteSparseTensors ssTensors;
270
272
271
273
static void bench_suitesparse_ufunc (benchmark::State& state, Func op) {
274
+ if (ssTensors.tensors .size () == 0 ) {
275
+ state.error_occurred ();
276
+ return ;
277
+ }
272
278
int tensorIdx = state.range (0 );
273
279
auto tensorPath = ssTensors.tensors [tensorIdx];
274
280
auto pathSplit = taco::util::split (tensorPath, " /" );
0 commit comments