diff --git a/mlir/include/mlir/ExecutionEngine/SparseTensor/File.h b/mlir/include/mlir/ExecutionEngine/SparseTensor/File.h --- a/mlir/include/mlir/ExecutionEngine/SparseTensor/File.h +++ b/mlir/include/mlir/ExecutionEngine/SparseTensor/File.h @@ -261,7 +261,19 @@ /// for the generated library. /// /// Precondition: `indices` is valid for `getRank()`. - char *readCOOIndices(uint64_t *indices); + template + char *readCOOIndices(I *indices) { + readLine(); + // Local variable for tracking the parser's position in the `line` buffer. + char *linePtr = line; + for (uint64_t dimRank = getRank(), d = 0; d < dimRank; ++d) { + // Parse the 1-based index. + uint64_t idx = strtoul(linePtr, &linePtr, 10); + // Store the 0-based index. + indices[d] = static_cast(idx - 1); + } + return linePtr; + } /// The internal implementation of `readCOO`. We template over /// `IsPattern` and `IsSymmetric` in order to perform LICM without diff --git a/mlir/lib/ExecutionEngine/SparseTensor/File.cpp b/mlir/lib/ExecutionEngine/SparseTensor/File.cpp --- a/mlir/lib/ExecutionEngine/SparseTensor/File.cpp +++ b/mlir/lib/ExecutionEngine/SparseTensor/File.cpp @@ -53,19 +53,6 @@ MLIR_SPARSETENSOR_FATAL("Cannot read next line of %s\n", filename); } -char *SparseTensorReader::readCOOIndices(uint64_t *indices) { - readLine(); - // Local variable for tracking the parser's position in the `line` buffer. - char *linePtr = line; - for (uint64_t rank = getRank(), r = 0; r < rank; ++r) { - // Parse the 1-based index. - uint64_t idx = strtoul(linePtr, &linePtr, 10); - // Store the 0-based index. - indices[r] = idx - 1; - } - return linePtr; -} - /// Reads and parses the file's header. void SparseTensorReader::readHeader() { assert(file && "Attempt to readHeader() before openFile()");