[Mlir-commits] [mlir] [mlir][tensor] Add more tensor.extract_slice canonicalization (PR #212974)

Tuomas Kärnä llvmlistbot at llvm.org
Tue Aug 4 02:10:47 PDT 2026


tkarna wrote:

Update: looking at existing opt-in patterns, only one new pattern is in fact needed:

### 1. Fold full-slice rank-reducing extract of expand_shape

This pattern already exists as `FoldEmptyTensorWithExtractSliceOp` and is included in tensor `FoldTensorEmptyPatterns`.

### 2. Fold full rank-reducing extract_slice of tensor.empty to a smaller tensor.empty

This pattern does not exists. Added `FoldExtractSliceOfExpandShape` to `ReassociativeReshapeFoldingPatterns`.

### 3. Fold extract_slice of linalg.fill over tensor.empty by shrinking destination

This pattern can be achieved as a combination of linalg `SwapExtractSliceWithFillPatterns` and aforementioned tensor `FoldEmptyTensorWithExtractSlice` pattern. Currently `SwapExtractSliceWithFillPatterns` is not exposed as a transform op pattern -- will address in another PR.

Force pushed to include only change 2.

https://github.com/llvm/llvm-project/pull/212974


More information about the Mlir-commits mailing list