[Mlir-commits] [mlir] [mlir] Change `tensor.extract/insert` to take static/dynamic indices. (PR #104488)
Jacques Pienaar
llvmlistbot at llvm.org
Fri Aug 16 10:51:40 PDT 2024
================
@@ -1736,6 +1736,32 @@ struct ShapeOfFromReshape : public OpRewritePattern<shape::ShapeOfOp> {
}
};
+struct ExtractFromShapeOfExtentTensor
+ : public OpRewritePattern<tensor::ExtractOp> {
+ using OpRewritePattern<tensor::ExtractOp>::OpRewritePattern;
+
+ LogicalResult matchAndRewrite(tensor::ExtractOp op,
+ PatternRewriter &rewriter) const override {
+ auto tensorShapeOfOp = op.getTensor().getDefiningOp<shape::ShapeOfOp>();
+ if (!tensorShapeOfOp)
+ return rewriter.notifyMatchFailure(op, "producer is not shape.shape_of");
+
+ int64_t staticIndice = op.getStaticIndices()[0];
+ Type indexType = rewriter.getIndexType();
+ Value indice =
+ staticIndice != ShapedType::kDynamic
----------------
jpienaar wrote:
Prefer using isDynamic(staticIndex)
https://github.com/llvm/llvm-project/pull/104488
More information about the Mlir-commits
mailing list