Skip to content

Commit 14c58cf

Browse files
committed
[mlir][sparse] simplification of sparse runtime support lib
Incorporated two header files directly into other since other parts were used (and it makes it hard to find the definitions). Removed TODOs that are less likely to be done. Reviewed By: Peiming Differential Revision: https://reviews.llvm.org/D159330
1 parent f93c271 commit 14c58cf

File tree

10 files changed

+124
-320
lines changed

10 files changed

+124
-320
lines changed

mlir/include/mlir/ExecutionEngine/SparseTensor/ArithmeticUtils.h

+3-18
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,13 @@
66
//
77
//===----------------------------------------------------------------------===//
88
//
9-
// This header is not part of the public API. It is placed in the
10-
// includes directory only because that's required by the implementations
11-
// of template-classes.
12-
//
13-
// This file is part of the lightweight runtime support library for sparse
14-
// tensor manipulations. The functionality of the support library is meant
15-
// to simplify benchmarking, testing, and debugging MLIR code operating on
16-
// sparse tensors. However, the provided functionality is **not** part of
17-
// core MLIR itself.
9+
// A collection of "safe" arithmetic helper methods.
1810
//
1911
//===----------------------------------------------------------------------===//
2012

2113
#ifndef MLIR_EXECUTIONENGINE_SPARSETENSOR_ARITHMETICUTILS_H
2214
#define MLIR_EXECUTIONENGINE_SPARSETENSOR_ARITHMETICUTILS_H
2315

24-
#include "mlir/ExecutionEngine/SparseTensor/Attributes.h"
25-
2616
#include <cassert>
2717
#include <cinttypes>
2818
#include <limits>
@@ -108,12 +98,6 @@ constexpr bool safelyGE(T t, U u) noexcept {
10898
//
10999
//===----------------------------------------------------------------------===//
110100

111-
// TODO: we would like to be able to pass in custom error messages, to
112-
// improve the user experience. We should be able to use something like
113-
// `assert(((void)(msg ? msg : defaultMsg), cond))`; but I'm not entirely
114-
// sure that'll work as intended when done within a function-definition
115-
// rather than within a macro-definition.
116-
117101
/// A version of `static_cast<To>` which checks for overflow/underflow.
118102
/// The implementation avoids performing runtime assertions whenever
119103
/// the types alone are sufficient to statically prove that overflow
@@ -140,7 +124,8 @@ inline uint64_t checkedMul(uint64_t lhs, uint64_t rhs) {
140124
// If assertions are enabled and we have the intrinsic, then use it to
141125
// avoid the expensive division. If assertions are disabled, then don't
142126
// bother with intrinsics (to avoid any possible slowdown vs `operator*`).
143-
#if !defined(NDEBUG) && MLIR_SPARSETENSOR_HAS_BUILTIN(__builtin_mul_overflow)
127+
#if !defined(NDEBUG) && defined(__has_builtin) && \
128+
__has_builtin(__builtin_mul_overflow)
144129
uint64_t result;
145130
bool overflowed = __builtin_mul_overflow(lhs, rhs, &result);
146131
assert(!overflowed && "Integer overflow");

mlir/include/mlir/ExecutionEngine/SparseTensor/Attributes.h

-85
This file was deleted.

mlir/include/mlir/ExecutionEngine/SparseTensor/ErrorHandling.h

-10
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,10 @@
66
//
77
//===----------------------------------------------------------------------===//
88
//
9-
// This header is not part of the public API. It is placed in the
10-
// includes directory only because that's required by the implementations
11-
// of template-classes.
12-
//
139
// This file defines an extremely lightweight API for fatal errors (not
1410
// arising from assertions). The API does not attempt to be sophisticated
1511
// in any way, it's just the usual "I give up" style of error reporting.
1612
//
17-
// This file is part of the lightweight runtime support library for sparse
18-
// tensor manipulations. The functionality of the support library is meant
19-
// to simplify benchmarking, testing, and debugging MLIR code operating on
20-
// sparse tensors. However, the provided functionality is **not** part of
21-
// core MLIR itself.
22-
//
2313
//===----------------------------------------------------------------------===//
2414

2515
#ifndef MLIR_EXECUTIONENGINE_SPARSETENSOR_ERRORHANDLING_H

mlir/include/mlir/ExecutionEngine/SparseTensor/File.h

-14
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,11 @@
1515
// (2) Formidable Repository of Open Sparse Tensors and Tools (FROSTT): *.tns
1616
// http://frostt.io/tensors/file-formats.html
1717
//
18-
// This file is part of the lightweight runtime support library for sparse
19-
// tensor manipulations. The functionality of the support library is meant
20-
// to simplify benchmarking, testing, and debugging MLIR code operating on
21-
// sparse tensors. However, the provided functionality is **not** part of
22-
// core MLIR itself.
23-
//
2418
//===----------------------------------------------------------------------===//
2519

2620
#ifndef MLIR_EXECUTIONENGINE_SPARSETENSOR_FILE_H
2721
#define MLIR_EXECUTIONENGINE_SPARSETENSOR_FILE_H
2822

29-
#include "mlir/ExecutionEngine/SparseTensor/PermutationRef.h"
3023
#include "mlir/ExecutionEngine/SparseTensor/Storage.h"
3124

3225
#include <fstream>
@@ -84,13 +77,6 @@ inline V readValue(char **linePtr, bool isPattern) {
8477

8578
//===----------------------------------------------------------------------===//
8679

87-
// TODO: benchmark whether to keep various methods inline vs moving them
88-
// off to the cpp file.
89-
90-
// TODO: consider distinguishing separate classes for before vs
91-
// after reading the header; so as to statically avoid the need
92-
// to `assert(isValid())`.
93-
9480
/// This class abstracts over the information stored in file headers,
9581
/// as well as providing the buffers and methods for parsing those headers.
9682
class SparseTensorReader final {

mlir/include/mlir/ExecutionEngine/SparseTensor/PermutationRef.h

-141
This file was deleted.

0 commit comments

Comments
 (0)