[Mlir-commits] [mlir] [mlir][tosa] Change the start and size of slice to tosa shape type (PR #124209)
TatWai Chong
llvmlistbot at llvm.org
Mon Jan 27 11:40:39 PST 2025
================
@@ -282,17 +298,27 @@ class SliceConverter : public OpConversionPattern<tosa::SliceOp> {
auto dim = rewriter.create<tensor::DimOp>(loc, input, index);
auto offset = rewriter.create<arith::ConstantOp>(
- loc, rewriter.getIndexAttr(starts[index]));
+ loc, rewriter.getIndexAttr(SliceStarts[index]));
dynSizes.push_back(rewriter.create<arith::SubIOp>(loc, dim, offset));
}
auto newSliceOp = rewriter.create<tensor::ExtractSliceOp>(
sliceOp.getLoc(), sliceOp.getType(), input, ValueRange({}), dynSizes,
- ValueRange({}), rewriter.getDenseI64ArrayAttr(starts),
+ ValueRange({}), rewriter.getDenseI64ArrayAttr(SliceStarts),
rewriter.getDenseI64ArrayAttr(sizes),
rewriter.getDenseI64ArrayAttr(strides));
rewriter.replaceOp(sliceOp, newSliceOp.getResult());
+
+ auto removeIfRedundant = [&](Operation *op) {
----------------
tatwaichong wrote:
Good question. It seems the erase policy is operator-dependent. Defining a lambda function for it is likely overkill, this lambda is not much on top of `eraseOp` function. Definitely worth extracting to a common function when we found more use cases, but in this case, it is quite specific as we know the two const shape op can be clean up.
Will drop to use lambda function here.
https://github.com/llvm/llvm-project/pull/124209
More information about the Mlir-commits
mailing list