|
MLIR 23.0.0git
|
#include "mlir/Dialect/Arith/IR/Arith.h"#include "mlir/Dialect/Math/IR/Math.h"#include "mlir/Dialect/Math/Transforms/Passes.h"#include "mlir/Dialect/Tensor/IR/Tensor.h"#include "mlir/IR/Builders.h"#include "mlir/IR/Matchers.h"#include "mlir/IR/TypeUtilities.h"#include "mlir/Transforms/GreedyPatternRewriteDriver.h"#include "mlir/Dialect/Math/Transforms/Passes.h.inc"Go to the source code of this file.
Classes | |
| class | mlir::math::impl::MathExpandOpsPassBase< DerivedT > |
Namespaces | |
| namespace | mlir |
| Include the generated interface declarations. | |
| namespace | mlir::math |
| namespace | mlir::math::impl |
Macros | |
| #define | GEN_PASS_DEF_MATHEXPANDOPSPASS |
Functions | |
| std::unique_ptr<::mlir::Pass > | mlir::math::impl::createMathExpandOpsPass () |
| std::unique_ptr<::mlir::Pass > | mlir::math::impl::createMathExpandOpsPass (MathExpandOpsPassOptions options) |
| std::unique_ptr<::mlir::Pass > | mlir::math::createMathExpandOpsPass () |
| std::unique_ptr<::mlir::Pass > | mlir::math::createMathExpandOpsPass (MathExpandOpsPassOptions options) |
| static bool | isUnrankedShaped (Type type) |
| Returns true if the type is an unranked shaped type (e.g., tensor<*xf32>). | |
| static Value | createFloatConst (Location loc, Type type, APFloat value, OpBuilder &b, Value dynamicShapeRef=Value()) |
| Create a float constant. | |
| static Value | createFloatConst (Location loc, Type type, double value, OpBuilder &b, Value dynamicShapeRef=Value()) |
| static Value | createIntConst (Location loc, Type type, int64_t value, OpBuilder &b, Value dynamicShapeRef=Value()) |
| Create an integer constant. | |
| static Value | createTruncatedFPValue (Value operand, ImplicitLocOpBuilder &b) |
| static LogicalResult | convertSinhOp (math::SinhOp op, PatternRewriter &rewriter) |
| static LogicalResult | convertCoshOp (math::CoshOp op, PatternRewriter &rewriter) |
| static LogicalResult | convertTanhOp (math::TanhOp op, PatternRewriter &rewriter) |
| Expands tanh op into 1-exp^{-2x} / 1+exp^{-2x} To avoid overflow we exploit the reflection symmetry tanh(-x) = -tanh(x). | |
| static LogicalResult | convertTanOp (math::TanOp op, PatternRewriter &rewriter) |
| static LogicalResult | convertAsinhOp (math::AsinhOp op, PatternRewriter &rewriter) |
| static LogicalResult | convertAcoshOp (math::AcoshOp op, PatternRewriter &rewriter) |
| static LogicalResult | convertAtanhOp (math::AtanhOp op, PatternRewriter &rewriter) |
| static LogicalResult | convertFmaFOp (math::FmaOp op, PatternRewriter &rewriter) |
| static LogicalResult | convertCeilOp (math::CeilOp op, PatternRewriter &rewriter) |
| static LogicalResult | convertFPowIOp (math::FPowIOp op, PatternRewriter &rewriter) |
| static LogicalResult | convertPowfOp (math::PowFOp op, PatternRewriter &rewriter) |
| static LogicalResult | convertExp2fOp (math::Exp2Op op, PatternRewriter &rewriter) |
| static LogicalResult | convertRoundOp (math::RoundOp op, PatternRewriter &rewriter) |
| static LogicalResult | convertCtlzOp (math::CountLeadingZerosOp op, PatternRewriter &rewriter) |
| static LogicalResult | convertRoundEvenOp (math::RoundEvenOp op, PatternRewriter &rewriter) |
| static LogicalResult | convertRsqrtOp (math::RsqrtOp op, PatternRewriter &rewriter) |
| static LogicalResult | convertClampfOp (math::ClampFOp op, PatternRewriter &rewriter) |
| #define GEN_PASS_DEF_MATHEXPANDOPSPASS |
Definition at line 25 of file ExpandOps.cpp.
|
static |
Definition at line 224 of file ExpandOps.cpp.
References add, b, createFloatConst(), mlir::Value::getType(), isUnrankedShaped(), mlir::RewriterBase::replaceOp(), and success().
Referenced by mlir::math::populateExpansionPatterns().
|
static |
Definition at line 205 of file ExpandOps.cpp.
References add, b, createFloatConst(), mlir::Value::getType(), isUnrankedShaped(), mlir::RewriterBase::replaceOp(), and success().
Referenced by mlir::math::populateExpansionPatterns().
|
static |
Definition at line 244 of file ExpandOps.cpp.
References add, b, createFloatConst(), div, mlir::Value::getType(), isUnrankedShaped(), mlir::RewriterBase::replaceOp(), and success().
Referenced by mlir::math::populateExpansionPatterns().
|
static |
Definition at line 282 of file ExpandOps.cpp.
References add, b, createFloatConst(), createIntConst(), createTruncatedFPValue(), mlir::getElementTypeOrSelf(), mlir::Builder::getIntegerType(), mlir::Value::getType(), isUnrankedShaped(), mlir::RewriterBase::replaceOp(), and success().
Referenced by mlir::math::populateExpansionPatterns().
|
static |
Definition at line 795 of file ExpandOps.cpp.
References mlir::RewriterBase::replaceOpWithNewOp(), and success().
Referenced by mlir::math::populateExpansionPatterns().
|
static |
Definition at line 129 of file ExpandOps.cpp.
References add, b, createFloatConst(), mlir::Value::getType(), isUnrankedShaped(), mlir::RewriterBase::replaceOp(), and success().
Referenced by mlir::math::populateExpansionPatterns().
|
static |
Definition at line 584 of file ExpandOps.cpp.
References add, createIntConst(), mlir::getElementTypeOrSelf(), mlir::Value::getType(), isUnrankedShaped(), mlir::RewriterBase::notifyMatchFailure(), mlir::RewriterBase::replaceOp(), and success().
Referenced by mlir::math::populateExpansionPatterns().
|
static |
Definition at line 504 of file ExpandOps.cpp.
References b, createFloatConst(), mlir::Value::getType(), isUnrankedShaped(), mlir::RewriterBase::replaceOp(), and success().
Referenced by mlir::math::populateExpansionPatterns().
|
static |
Definition at line 265 of file ExpandOps.cpp.
References add, b, mlir::RewriterBase::replaceOp(), and success().
Referenced by mlir::math::populateExpansionPatterns().
|
static |
Definition at line 359 of file ExpandOps.cpp.
References b, createFloatConst(), mlir::getElementTypeOrSelf(), mlir::Value::getType(), mlir::m_Constant(), mlir::m_ConstantInt(), mlir::matchPattern(), mlir::RewriterBase::replaceOp(), and success().
Referenced by mlir::math::populateExpansionPatterns().
|
static |
Definition at line 430 of file ExpandOps.cpp.
References b, createFloatConst(), div, mlir::getElementTypeOrSelf(), mlir::Value::getType(), mlir::m_ConstantFloat(), mlir::matchPattern(), mlir::RewriterBase::replaceOp(), and success().
Referenced by mlir::math::populateExpansionPatterns().
|
static |
Definition at line 636 of file ExpandOps.cpp.
References b, createFloatConst(), createIntConst(), mlir::getElementTypeOrSelf(), mlir::Builder::getIntegerType(), mlir::Type::getIntOrFloatBitWidth(), mlir::Value::getType(), isUnrankedShaped(), mlir::RewriterBase::notifyMatchFailure(), mlir::RewriterBase::replaceOp(), result, and success().
Referenced by mlir::math::populateExpansionPatterns().
|
static |
Definition at line 521 of file ExpandOps.cpp.
References add, b, createFloatConst(), createIntConst(), createTruncatedFPValue(), mlir::getElementTypeOrSelf(), mlir::Value::getType(), mlir::Type::isF32(), isUnrankedShaped(), mlir::RewriterBase::notifyMatchFailure(), mlir::RewriterBase::replaceOp(), result, and success().
Referenced by mlir::math::populateExpansionPatterns().
|
static |
Definition at line 775 of file ExpandOps.cpp.
References createFloatConst(), mlir::getElementTypeOrSelf(), mlir::Value::getType(), isUnrankedShaped(), mlir::RewriterBase::replaceOpWithNewOp(), and success().
Referenced by mlir::math::populateExpansionPatterns().
|
static |
Definition at line 110 of file ExpandOps.cpp.
References b, createFloatConst(), mlir::Value::getType(), isUnrankedShaped(), mlir::RewriterBase::replaceOp(), and success().
Referenced by mlir::math::populateExpansionPatterns().
|
static |
Expands tanh op into 1-exp^{-2x} / 1+exp^{-2x} To avoid overflow we exploit the reflection symmetry tanh(-x) = -tanh(x).
We compute a "signs" value which is -1 if input is negative and +1 if input is positive. Then multiply the input by this value, guaranteeing that the result is positive, which also guarantees exp^{-2x * sign(x)} is in (0, 1]. Expand the computation on the input x * sign(x), then multiply the result by sign(x) to retain sign of the real result.
Definition at line 155 of file ExpandOps.cpp.
References createFloatConst(), mlir::Value::getType(), isUnrankedShaped(), mlir::RewriterBase::replaceOpWithNewOp(), and success().
Referenced by mlir::math::populateExpansionPatterns().
|
static |
Definition at line 193 of file ExpandOps.cpp.
References b, div, mlir::Value::getType(), mlir::RewriterBase::replaceOp(), and success().
Referenced by mlir::math::populateExpansionPatterns().
|
static |
Create a float constant.
For dynamically-shaped tensors, creates a scalar constant and uses tensor.dim + tensor.splat to broadcast to the target shape. The optional dynamicShapeRef provides the runtime dimension sizes.
Definition at line 39 of file ExpandOps.cpp.
Referenced by mlir::math::impl::MathExpandOpsPassBase< DerivedT >::clonePass(), convertAcoshOp(), convertAsinhOp(), convertAtanhOp(), convertCeilOp(), convertCoshOp(), convertExp2fOp(), convertFPowIOp(), convertPowfOp(), convertRoundEvenOp(), convertRoundOp(), convertRsqrtOp(), convertSinhOp(), and convertTanhOp().
|
static |
Definition at line 66 of file ExpandOps.cpp.
|
static |
Create an integer constant.
For dynamically-shaped tensors, creates a scalar constant and uses tensor.dim + tensor.splat to broadcast to the target shape. The optional dynamicShapeRef provides the runtime dimension sizes.
Definition at line 74 of file ExpandOps.cpp.
References b, mlir::DenseElementsAttr::get(), and mlir::getElementTypeOrSelf().
Referenced by convertCeilOp(), convertCtlzOp(), convertRoundEvenOp(), and convertRoundOp().
|
static |
Definition at line 97 of file ExpandOps.cpp.
References b, and mlir::Value::getType().
Referenced by convertCeilOp(), and convertRoundOp().
Returns true if the type is an unranked shaped type (e.g., tensor<*xf32>).
Unranked types can't be expanded because tensor.splat requires ranked types.
Definition at line 31 of file ExpandOps.cpp.
Referenced by convertAcoshOp(), convertAsinhOp(), convertAtanhOp(), convertCeilOp(), convertCoshOp(), convertCtlzOp(), convertExp2fOp(), convertRoundEvenOp(), convertRoundOp(), convertRsqrtOp(), convertSinhOp(), and convertTanhOp().