[mlir][sparse] moving inbound check for slice driven loop into before block of the...
authorPeiming Liu <peiming@google.com>
Wed, 7 Jun 2023 23:34:44 +0000 (23:34 +0000)
committerPeiming Liu <peiming@google.com>
Fri, 9 Jun 2023 17:03:15 +0000 (17:03 +0000)
commit853d704fd0c4744731870df67ade7249d5440438
treed06e3e43daa62da9f197ce6ccacf45cc4a40ccff
parentdcda3e67e729ab8f2566563bd26f6ec018ce21d7
[mlir][sparse] moving inbound check for slice driven loop into before block of the WhileOp

This patch changes the while loop generated for iterating over a fully reduced sparse level with affine index expression.
Before:
```
cont = true
while (cont) {
  if (inBound()) {
    ....
    cont = true;
  } else {
    cont = false;
  }
}
```
After:
```
while(inBound()) {
  ....
}
```

Reviewed By: K-Wu

Differential Revision: https://reviews.llvm.org/D152463
mlir/lib/Dialect/SparseTensor/Transforms/LoopEmitter.cpp
mlir/test/Dialect/SparseTensor/sparse_conv_2d_slice_based.mlir