diff --git a/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h b/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h --- a/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h +++ b/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h @@ -842,66 +842,6 @@ //===----------------------------------------------------------------------===// // Transformations exposed as rewrite patterns. //===----------------------------------------------------------------------===// -/// -/// Linalg lowering patterns. -/// -/// Apply the `linalgLowerOpToLoops` transformation as a pattern. -/// `filter` controls LinalgTransformMarker matching and update when specified. -/// See `linalgLowerOpToLoops` for more details. -enum class LinalgLoweringType { - LibraryCall = 0, - Loops = 1, - AffineLoops = 2, - ParallelLoops = 3 -}; - -template -struct LinalgLoweringPattern : public RewritePattern { - LinalgLoweringPattern( - MLIRContext *context, LinalgLoweringType loweringType, - LinalgTransformationFilter f = LinalgTransformationFilter(), - PatternBenefit benefit = 1) - : RewritePattern(OpTy::getOperationName(), benefit, context), - filter(std::move(f)), loweringType(loweringType) {} - - // TODO: Move implementation to .cpp once named ops are auto-generated. - LogicalResult matchAndRewrite(Operation *op, - PatternRewriter &rewriter) const override { - LinalgOp linalgOp = dyn_cast(op); - if (!linalgOp) - return failure(); - if (failed(filter.checkAndNotify(rewriter, linalgOp))) - return failure(); - - switch (loweringType) { - case LinalgLoweringType::LibraryCall: - // TODO: Move lowering to library calls here. - return failure(); - case LinalgLoweringType::Loops: - if (failed(linalgOpToLoops(rewriter, op))) - return failure(); - break; - case LinalgLoweringType::AffineLoops: - if (failed(linalgOpToAffineLoops(rewriter, op))) - return failure(); - break; - case LinalgLoweringType::ParallelLoops: - if (failed(linalgOpToParallelLoops(rewriter, op))) - return failure(); - break; - } - - rewriter.eraseOp(op); - return success(); - } - -private: - /// LinalgTransformMarker handles special attribute manipulations. - LinalgTransformationFilter filter; - /// Controls whether the pattern lowers to library calls, scf.for, affine.for - /// or scf.parallel. - LinalgLoweringType loweringType; -}; /// Linalg generalization patterns diff --git a/mlir/test/Dialect/Linalg/transform-patterns.mlir b/mlir/test/Dialect/Linalg/transform-patterns.mlir --- a/mlir/test/Dialect/Linalg/transform-patterns.mlir +++ b/mlir/test/Dialect/Linalg/transform-patterns.mlir @@ -19,16 +19,9 @@ // CHECK-LABEL: func @dot // CHECK-DAG: %[[c0:.*]] = arith.constant 0 : index -// CHECK-DAG: %[[c1:.*]] = arith.constant 1 : index // CHECK-DAG: %[[c8000:.*]] = arith.constant 8000 : index // CHECK: scf.for {{.*}} = %[[c0]] to {{.*}} step %[[c8000]] { -// CHECK: scf.for {{.*}} = %[[c0]] to {{.*}} step %[[c1]] { -// CHECK: load -// CHECK: load -// CHECK: load -// CHECK: arith.mulf -// CHECK: arith.addf -// CHECK: store +// CHECK: linalg.dot // ----- diff --git a/mlir/test/lib/Dialect/Linalg/TestLinalgTransforms.cpp b/mlir/test/lib/Dialect/Linalg/TestLinalgTransforms.cpp --- a/mlir/test/lib/Dialect/Linalg/TestLinalgTransforms.cpp +++ b/mlir/test/lib/Dialect/Linalg/TestLinalgTransforms.cpp @@ -124,13 +124,6 @@ MLIRContext *ctx = funcOp.getContext(); RewritePatternSet patterns(ctx); - //===--------------------------------------------------------------------===// - // Linalg to loops patterns. - //===--------------------------------------------------------------------===// - patterns.add>( - ctx, - /*loweringType=*/LinalgLoweringType::Loops); - //===--------------------------------------------------------------------===// // Linalg distribution patterns. //===--------------------------------------------------------------------===//