diff --git a/mlir/lib/ExecutionEngine/SparseTensorUtils.cpp b/mlir/lib/ExecutionEngine/SparseTensorUtils.cpp --- a/mlir/lib/ExecutionEngine/SparseTensorUtils.cpp +++ b/mlir/lib/ExecutionEngine/SparseTensorUtils.cpp @@ -173,7 +173,7 @@ class SparseTensorStorageBase { public: /// Dimension size query. - virtual uint64_t getDimSize(uint64_t) = 0; + virtual uint64_t getDimSize(uint64_t) const = 0; /// Overhead storage. virtual void getPointers(std::vector **, uint64_t) { fatal("p64"); } @@ -227,7 +227,7 @@ virtual ~SparseTensorStorageBase() = default; private: - void fatal(const char *tp) { + static void fatal(const char *tp) { fprintf(stderr, "unsupported %s\n", tp); exit(1); } @@ -296,7 +296,7 @@ uint64_t getRank() const { return sizes.size(); } /// Get the size of the given dimension of the tensor. - uint64_t getDimSize(uint64_t d) override { + uint64_t getDimSize(uint64_t d) const override { assert(d < getRank()); return sizes[d]; } @@ -553,7 +553,7 @@ } /// Finds the lexicographic differing dimension. - uint64_t lexDiff(const uint64_t *cursor) { + uint64_t lexDiff(const uint64_t *cursor) const { for (uint64_t r = 0, rank = getRank(); r < rank; r++) if (cursor[r] > idx[r]) return r; @@ -570,7 +570,7 @@ } private: - std::vector sizes; // per-dimension sizes + const std::vector sizes; // per-dimension sizes std::vector rev; // "reverse" permutation std::vector idx; // index cursor std::vector> pointers; @@ -722,7 +722,7 @@ /// Writes the sparse tensor to extended FROSTT format. template -void outSparseTensor(void *tensor, void *dest, bool sort) { +static void outSparseTensor(void *tensor, void *dest, bool sort) { assert(tensor && dest); auto coo = static_cast *>(tensor); if (sort) @@ -753,7 +753,7 @@ /// Initializes sparse tensor from an external COO-flavored format. template -SparseTensorStorage * +static SparseTensorStorage * toMLIRSparseTensor(uint64_t rank, uint64_t nse, uint64_t *shape, V *values, uint64_t *indices, uint64_t *perm, uint8_t *sparse) { const DimLevelType *sparsity = (DimLevelType *)(sparse); @@ -795,8 +795,9 @@ /// Converts a sparse tensor to an external COO-flavored format. template -void fromMLIRSparseTensor(void *tensor, uint64_t *pRank, uint64_t *pNse, - uint64_t **pShape, V **pValues, uint64_t **pIndices) { +static void fromMLIRSparseTensor(void *tensor, uint64_t *pRank, uint64_t *pNse, + uint64_t **pShape, V **pValues, + uint64_t **pIndices) { auto sparseTensor = static_cast *>(tensor); uint64_t rank = sparseTensor->getRank();