[Mlir-commits] [mlir] [mlir] Convert `expand_shape` to more static form (PR #112265)
Han-Chung Wang
llvmlistbot at llvm.org
Tue Oct 15 11:06:20 PDT 2024
hanhanW wrote:
> My main concern here is that the generated casts are not guaranteed to fold with other casts.
There is [ChainedTensorCast pattern](https://github.com/llvm/llvm-project/blob/060d151476b871b48662dbd1947b67d9b0ae9d13/mlir/lib/Dialect/Tensor/IR/TensorOps.cpp#L419C8-L419C25), which folds the tensor.cast ops into a single tensor.cast op. Then you can follow what Mahesh suggested, which folds the producer tensor.cast into the expand_shape op. There is a [canFoldIntoProducerOp](https://github.com/llvm/llvm-project/blob/fb858b4f6ba454565abecbc107364a444668840b/mlir/include/mlir/Dialect/Tensor/IR/Tensor.h#L110C6-L110C27), which can be used in the `expand_shape -> tensor.cast` folding. I'm not pretty sure if they work or not, please take a look at these two functions.
https://github.com/llvm/llvm-project/pull/112265
More information about the Mlir-commits
mailing list