Skip to content

Commit 95ebcb8

Browse files
Peiming LiuPeimingLiu
authored andcommitted
rebase
1 parent b8e0983 commit 95ebcb8

File tree

9 files changed

+20
-19
lines changed

9 files changed

+20
-19
lines changed

mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorPasses.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,14 @@ struct SparsificationPass
9595
SparsificationPass(const SparsificationPass &pass) = default;
9696
SparsificationPass(const SparsificationOptions &options) {
9797
parallelization = options.parallelizationStrategy;
98-
debugSparseIteration = options.debugSparseIteration;
98+
sparseEmitStrategy = options.sparseEmitStrategy;
9999
enableRuntimeLibrary = options.enableRuntimeLibrary;
100100
}
101101

102102
void runOnOperation() override {
103103
auto *ctx = &getContext();
104104
// Translate strategy flags to strategy options.
105-
SparsificationOptions options(parallelization, debugSparseIteration,
105+
SparsificationOptions options(parallelization, sparseEmitStrategy,
106106
enableRuntimeLibrary);
107107
// Apply sparsification and cleanup rewriting.
108108
RewritePatternSet patterns(ctx);

mlir/lib/Dialect/SparseTensor/Transforms/Sparsification.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1369,7 +1369,7 @@ struct GenericOpSparsifier : public OpRewritePattern<linalg::GenericOp> {
13691369
return failure();
13701370

13711371
// Recursively generates code if admissible.
1372-
env.startEmit(options.debugSparseIteration);
1372+
env.startEmit(options.sparseEmitStrategy);
13731373
genBuffers(env, rewriter);
13741374
// TODO: Constant affine expression should be handled differently when using
13751375
// slice-based codegen, it does not matter now because we already reject the

mlir/lib/Dialect/SparseTensor/Transforms/Utils/CodegenEnv.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ LogicalResult CodegenEnv::initTensorExp() {
5959
return success();
6060
}
6161

62-
void CodegenEnv::startEmit(DebugSparseIteration emitStrategy) {
62+
void CodegenEnv::startEmit(SparseEmitStrategy emitStrategy) {
6363
assert(insChain == nullptr && "must only start emitting once");
6464
if (sparseOut) {
6565
insChain = sparseOut->get();

mlir/lib/Dialect/SparseTensor/Transforms/Utils/CodegenEnv.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class CodegenEnv {
5252
Merger &merger() { return latticeMerger; }
5353
LoopEmitter &emitter() { return loopEmitter; }
5454

55-
void startEmit(DebugSparseIteration emitStrategy);
55+
void startEmit(SparseEmitStrategy emitStrategy);
5656

5757
/// Generates loop boundary statements (entering/exiting loops). The function
5858
/// passes and updates the passed-in parameters.

mlir/lib/Dialect/SparseTensor/Transforms/Utils/LoopEmitter.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,19 +82,19 @@ static Value genSliceStride(OpBuilder &builder, Location loc, Value tensor,
8282
LoopEmitter::LoopEmitter(ValueRange tensors, StringAttr loopTag, bool hasOutput,
8383
bool isSparseOut, unsigned numLoops,
8484
DependentLvlGetter dimGetter,
85-
DebugSparseIteration emitStrategy) {
85+
SparseEmitStrategy emitStrategy) {
8686
initialize(tensors, loopTag, hasOutput, isSparseOut, numLoops, dimGetter);
8787
}
8888

8989
void LoopEmitter::initialize(ValueRange ts, StringAttr loopTag, bool hasOutput,
9090
bool isSparseOut, unsigned numLoops,
9191
DependentLvlGetter dimGetter,
92-
DebugSparseIteration emitStrategy) {
92+
SparseEmitStrategy emitStrategy) {
9393
// First initialize the top-level type of the fields.
9494
this->loopTag = loopTag;
9595
this->hasOutput = hasOutput;
9696
this->isSparseOut = isSparseOut;
97-
SparseIterator::setDebugSparseIteration(emitStrategy);
97+
SparseIterator::setSparseEmitStrategy(emitStrategy);
9898

9999
const unsigned numManifestTensors = ts.size();
100100
const unsigned synTensorId = numManifestTensors;

mlir/lib/Dialect/SparseTensor/Transforms/Utils/LoopEmitter.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,13 @@ class LoopEmitter {
8989
initialize(ValueRange tensors, StringAttr loopTag = nullptr,
9090
bool hasOutput = false, bool isSparseOut = false,
9191
unsigned numLoops = 0, DependentLvlGetter getter = nullptr,
92-
DebugSparseIteration emitStrategy = DebugSparseIteration::kNone);
92+
SparseEmitStrategy emitStrategy = SparseEmitStrategy::kFunctional);
9393

9494
explicit LoopEmitter(
9595
ValueRange tensors, StringAttr loopTag = nullptr, bool hasOutput = false,
9696
bool isSparseOut = false, unsigned numLoops = 0,
9797
DependentLvlGetter getter = nullptr,
98-
DebugSparseIteration emitStrategy = DebugSparseIteration::kNone);
98+
SparseEmitStrategy emitStrategy = SparseEmitStrategy::kFunctional);
9999

100100
/// Starts a loop emitting session by generating all the buffers needed
101101
/// for iterating over the tensors.

mlir/lib/Dialect/SparseTensor/Transforms/Utils/SparseTensorLevel.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -777,11 +777,12 @@ class SubSectIterator : public SparseIterator {
777777
// SparseIterator derived classes implementation.
778778
//===----------------------------------------------------------------------===//
779779

780-
DebugSparseIteration SparseIterator::emitStrategy = DebugSparseIteration::kNone;
780+
SparseEmitStrategy SparseIterator::emitStrategy =
781+
SparseEmitStrategy::kFunctional;
781782

782783
void SparseIterator::genInit(OpBuilder &b, Location l,
783784
const SparseIterator *p) {
784-
if (emitStrategy == DebugSparseIteration::kInterfaceOnly) {
785+
if (emitStrategy == SparseEmitStrategy::kDebugInterface) {
785786
std::string prefix = getDebugInterfacePrefix();
786787
Operation *begin = b.create(l, b.getStringAttr(prefix + ".begin"), {},
787788
getCursorValTypes(b));
@@ -793,7 +794,7 @@ void SparseIterator::genInit(OpBuilder &b, Location l,
793794
}
794795

795796
Value SparseIterator::genNotEnd(OpBuilder &b, Location l) {
796-
if (emitStrategy == DebugSparseIteration::kInterfaceOnly) {
797+
if (emitStrategy == SparseEmitStrategy::kDebugInterface) {
797798
std::string prefix = getDebugInterfacePrefix();
798799
Operation *notEnd = b.create(l, b.getStringAttr(prefix + ".not_end"),
799800
getCursor(), b.getI1Type());
@@ -804,7 +805,7 @@ Value SparseIterator::genNotEnd(OpBuilder &b, Location l) {
804805
}
805806

806807
void SparseIterator::locate(OpBuilder &b, Location l, Value crd) {
807-
if (emitStrategy == DebugSparseIteration::kInterfaceOnly) {
808+
if (emitStrategy == SparseEmitStrategy::kDebugInterface) {
808809
std::string prefix = getDebugInterfacePrefix();
809810
SmallVector<Value> args = getCursor();
810811
args.push_back(crd);
@@ -818,7 +819,7 @@ void SparseIterator::locate(OpBuilder &b, Location l, Value crd) {
818819
}
819820

820821
Value SparseIterator::deref(OpBuilder &b, Location l) {
821-
if (emitStrategy == DebugSparseIteration::kInterfaceOnly) {
822+
if (emitStrategy == SparseEmitStrategy::kDebugInterface) {
822823
std::string prefix = getDebugInterfacePrefix();
823824
SmallVector<Value> args = getCursor();
824825
Operation *deref = b.create(l, b.getStringAttr(prefix + ".deref"),
@@ -830,7 +831,7 @@ Value SparseIterator::deref(OpBuilder &b, Location l) {
830831
}
831832

832833
ValueRange SparseIterator::forward(OpBuilder &b, Location l) {
833-
if (emitStrategy == DebugSparseIteration::kInterfaceOnly) {
834+
if (emitStrategy == SparseEmitStrategy::kDebugInterface) {
834835
std::string prefix = getDebugInterfacePrefix();
835836
Operation *next = b.create(l, b.getStringAttr(prefix + ".next"),
836837
getCursor(), getCursorValTypes(b));

mlir/lib/Dialect/SparseTensor/Transforms/Utils/SparseTensorLevel.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ class SparseIterator {
111111
public:
112112
virtual ~SparseIterator() = default;
113113

114-
static void setDebugSparseIteration(DebugSparseIteration strategy) {
114+
static void setSparseEmitStrategy(SparseEmitStrategy strategy) {
115115
SparseIterator::emitStrategy = strategy;
116116
}
117117

@@ -247,7 +247,7 @@ class SparseIterator {
247247
return ref.take_front(cursorValsCnt);
248248
}
249249

250-
static DebugSparseIteration emitStrategy;
250+
static SparseEmitStrategy emitStrategy;
251251

252252
public:
253253
const IterKind kind; // For LLVM-style RTTI.

mlir/test/Dialect/SparseTensor/sparse_conv_2d_slice_based.mlir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: mlir-opt %s --sparse-reinterpret-map --sparsification="debug-sparse-iteration=interface-only" --canonicalize --cse --allow-unregistered-dialect | FileCheck %s
1+
// RUN: mlir-opt %s --sparse-reinterpret-map --sparsification="sparse-emit-strategy=debug-interface" --canonicalize --cse --allow-unregistered-dialect | FileCheck %s
22

33
#map = affine_map<(d0, d1, d2, d3) -> (d0 + d2, d1 + d3)>
44
#map1 = affine_map<(d0, d1, d2, d3) -> (d2, d3)>

0 commit comments

Comments
 (0)