| 1 | //===- MathTransformOps.cpp - Implementation of Math transform ops --------===// |
|---|---|
| 2 | // |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | // See https://llvm.org/LICENSE.txt for license information. |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | |
| 9 | #include "mlir/Dialect/Math/TransformOps/MathTransformOps.h" |
| 10 | |
| 11 | #include "mlir/Dialect/Arith/IR/Arith.h" |
| 12 | #include "mlir/Dialect/Math/IR/Math.h" |
| 13 | #include "mlir/Dialect/Math/Transforms/Passes.h" |
| 14 | #include "mlir/Dialect/Transform/IR/TransformDialect.h" |
| 15 | #include "mlir/Dialect/Vector/IR/VectorOps.h" |
| 16 | |
| 17 | using namespace mlir; |
| 18 | |
| 19 | //===----------------------------------------------------------------------===// |
| 20 | // Apply...PatternsOp |
| 21 | //===----------------------------------------------------------------------===// |
| 22 | |
| 23 | void transform::ApplyF32ExpansionPatternsOp::populatePatterns( |
| 24 | RewritePatternSet &patterns) { |
| 25 | populateMathF32ExpansionPatterns(patterns, predicate: [](StringRef) { return true; }); |
| 26 | } |
| 27 | |
| 28 | void transform::ApplyPolynomialApproximationPatternsOp::populatePatterns( |
| 29 | RewritePatternSet &patterns) { |
| 30 | populateMathPolynomialApproximationPatterns(patterns, |
| 31 | predicate: [](StringRef) { return true; }); |
| 32 | } |
| 33 | |
| 34 | //===----------------------------------------------------------------------===// |
| 35 | // Transform op registration |
| 36 | //===----------------------------------------------------------------------===// |
| 37 | |
| 38 | namespace { |
| 39 | class MathTransformDialectExtension |
| 40 | : public transform::TransformDialectExtension< |
| 41 | MathTransformDialectExtension> { |
| 42 | public: |
| 43 | MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(MathTransformDialectExtension) |
| 44 | |
| 45 | MathTransformDialectExtension() { |
| 46 | declareGeneratedDialect<arith::ArithDialect>(); |
| 47 | declareGeneratedDialect<math::MathDialect>(); |
| 48 | declareGeneratedDialect<vector::VectorDialect>(); |
| 49 | registerTransformOps< |
| 50 | #define GET_OP_LIST |
| 51 | #include "mlir/Dialect/Math/TransformOps/MathTransformOps.cpp.inc" |
| 52 | >(); |
| 53 | } |
| 54 | }; |
| 55 | } // namespace |
| 56 | |
| 57 | #define GET_OP_CLASSES |
| 58 | #include "mlir/Dialect/Math/TransformOps/MathTransformOps.cpp.inc" |
| 59 | |
| 60 | void mlir::math::registerTransformDialectExtension(DialectRegistry ®istry) { |
| 61 | registry.addExtensions<MathTransformDialectExtension>(); |
| 62 | } |
| 63 |