20LogicalResult mlir::mpi::ReduceScatterBlockOp::verify() {
23 return emitOpError(
"sendbuf and recvbuf must have the same element type");
35template <
typename OpT>
37 using mlir::OpRewritePattern<OpT>::OpRewritePattern;
39 LogicalResult matchAndRewrite(OpT op,
40 mlir::PatternRewriter &
b)
const override {
41 auto mRef = op.getRef();
42 if (mRef.getType().hasStaticShape()) {
43 return mlir::failure();
45 auto defOp = mRef.getDefiningOp();
46 if (!defOp || !mlir::isa<mlir::memref::CastOp>(defOp)) {
47 return mlir::failure();
49 auto src = mlir::cast<mlir::memref::CastOp>(defOp).getSource();
50 if (!src.getType().hasStaticShape()) {
51 return mlir::failure();
53 b.modifyOpInPlace(op, [&]() { op.getRefMutable().assign(src); });
54 return mlir::success();
59 using mlir::OpRewritePattern<mlir::mpi::CommRankOp>::OpRewritePattern;
60 LogicalResult matchAndRewrite(mlir::mpi::CommRankOp op,
61 mlir::PatternRewriter &
b)
const override {
67 using mlir::OpRewritePattern<mlir::mpi::CommSizeOp>::OpRewritePattern;
69 LogicalResult matchAndRewrite(mlir::mpi::CommSizeOp op,
70 mlir::PatternRewriter &
b)
const override {
76void mlir::mpi::SendOp::getCanonicalizationPatterns(
78 results.
add<FoldCast<mlir::mpi::SendOp>>(context);
81void mlir::mpi::RecvOp::getCanonicalizationPatterns(
83 results.
add<FoldCast<mlir::mpi::RecvOp>>(context);
86void mlir::mpi::ISendOp::getCanonicalizationPatterns(
88 results.
add<FoldCast<mlir::mpi::ISendOp>>(context);
91void mlir::mpi::IRecvOp::getCanonicalizationPatterns(
93 results.
add<FoldCast<mlir::mpi::IRecvOp>>(context);
96void mlir::mpi::CommRankOp::getCanonicalizationPatterns(
98 results.
add<FoldRank>(context);
101void mlir::mpi::CommSizeOp::getCanonicalizationPatterns(
103 results.
add<FoldSize>(context);
110#define GET_OP_CLASSES
111#include "mlir/Dialect/MPI/IR/MPIOps.cpp.inc"
static Type getElementType(Type type, ArrayRef< int32_t > indices, function_ref< InFlightDiagnostic(StringRef)> emitErrorFn)
Walks the given type hierarchy with the given indices, potentially down to component granularity,...
MLIRContext is the top-level object for a collection of MLIR operations.
RewritePatternSet & add(ConstructorArg &&arg, ConstructorArgs &&...args)
Add an instance of each of the pattern types 'Ts' to the pattern list with the given arguments.
LogicalResult FoldToDLTIConst(OpT op, const char *key, mlir::PatternRewriter &b)
Include the generated interface declarations.
Type getType(OpFoldResult ofr)
Returns the int type of the integer in ofr.
OpRewritePattern is a wrapper around RewritePattern that allows for matching and rewriting against an...