MLIR  19.0.0git
Functions
ExpandPatterns.cpp File Reference
#include "mlir/Dialect/Arith/IR/Arith.h"
#include "mlir/Dialect/Math/IR/Math.h"
#include "mlir/Dialect/Math/Transforms/Passes.h"
#include "mlir/Dialect/SCF/IR/SCF.h"
#include "mlir/Dialect/Vector/IR/VectorOps.h"
#include "mlir/IR/Builders.h"
#include "mlir/IR/ImplicitLocOpBuilder.h"
#include "mlir/IR/TypeUtilities.h"
#include "mlir/Transforms/DialectConversion.h"

Go to the source code of this file.

Functions

static Value createFloatConst (Location loc, Type type, APFloat value, OpBuilder &b)
 Create a float constant. More...
 
static Value createFloatConst (Location loc, Type type, double value, OpBuilder &b)
 
static Value createIntConst (Location loc, Type type, int64_t value, OpBuilder &b)
 Create an integer constant. More...
 
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). More...
 
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 convertFloorOp (math::FloorOp 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)
 

Function Documentation

◆ convertAcoshOp()

static LogicalResult convertAcoshOp ( math::AcoshOp  op,
PatternRewriter rewriter 
)
static

Definition at line 172 of file ExpandPatterns.cpp.

Referenced by mlir::populateExpandAcoshPattern().

◆ convertAsinhOp()

static LogicalResult convertAsinhOp ( math::AsinhOp  op,
PatternRewriter rewriter 
)
static

Definition at line 156 of file ExpandPatterns.cpp.

Referenced by mlir::populateExpandAsinhPattern().

◆ convertAtanhOp()

static LogicalResult convertAtanhOp ( math::AtanhOp  op,
PatternRewriter rewriter 
)
static

Definition at line 188 of file ExpandPatterns.cpp.

Referenced by mlir::populateExpandAtanhPattern().

◆ convertCeilOp()

static LogicalResult convertCeilOp ( math::CeilOp  op,
PatternRewriter rewriter 
)
static

Definition at line 248 of file ExpandPatterns.cpp.

Referenced by mlir::populateExpandCeilFPattern().

◆ convertCoshOp()

static LogicalResult convertCoshOp ( math::CoshOp  op,
PatternRewriter rewriter 
)
static

Definition at line 88 of file ExpandPatterns.cpp.

Referenced by mlir::populateExpandCoshPattern().

◆ convertCtlzOp()

static LogicalResult convertCtlzOp ( math::CountLeadingZerosOp  op,
PatternRewriter rewriter 
)
static

Definition at line 444 of file ExpandPatterns.cpp.

Referenced by mlir::populateExpandCtlzPattern().

◆ convertExp2fOp()

static LogicalResult convertExp2fOp ( math::Exp2Op  op,
PatternRewriter rewriter 
)
static

Definition at line 372 of file ExpandPatterns.cpp.

Referenced by mlir::populateExpandExp2FPattern().

◆ convertFloorOp()

static LogicalResult convertFloorOp ( math::FloorOp  op,
PatternRewriter rewriter 
)
static

Definition at line 223 of file ExpandPatterns.cpp.

Referenced by mlir::populateExpandFloorFPattern().

◆ convertFmaFOp()

static LogicalResult convertFmaFOp ( math::FmaOp  op,
PatternRewriter rewriter 
)
static

Definition at line 206 of file ExpandPatterns.cpp.

Referenced by mlir::populateExpandFmaFPattern().

◆ convertFPowIOp()

static LogicalResult convertFPowIOp ( math::FPowIOp  op,
PatternRewriter rewriter 
)
static

Definition at line 271 of file ExpandPatterns.cpp.

Referenced by mlir::populateExpandFPowIPattern().

◆ convertPowfOp()

static LogicalResult convertPowfOp ( math::PowFOp  op,
PatternRewriter rewriter 
)
static

Definition at line 340 of file ExpandPatterns.cpp.

Referenced by mlir::populateExpandPowFPattern().

◆ convertRoundEvenOp()

static LogicalResult convertRoundEvenOp ( math::RoundEvenOp  op,
PatternRewriter rewriter 
)
static

Definition at line 487 of file ExpandPatterns.cpp.

Referenced by mlir::populateExpandRoundEvenPattern().

◆ convertRoundOp()

static LogicalResult convertRoundOp ( math::RoundOp  op,
PatternRewriter rewriter 
)
static

Definition at line 384 of file ExpandPatterns.cpp.

Referenced by mlir::populateExpandRoundFPattern().

◆ convertRsqrtOp()

static LogicalResult convertRsqrtOp ( math::RsqrtOp  op,
PatternRewriter rewriter 
)
static

Definition at line 619 of file ExpandPatterns.cpp.

Referenced by mlir::populateExpandRsqrtPattern().

◆ convertSinhOp()

static LogicalResult convertSinhOp ( math::SinhOp  op,
PatternRewriter rewriter 
)
static

Definition at line 72 of file ExpandPatterns.cpp.

Referenced by mlir::populateExpandSinhPattern().

◆ convertTanhOp()

static LogicalResult convertTanhOp ( math::TanhOp  op,
PatternRewriter rewriter 
)
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 111 of file ExpandPatterns.cpp.

Referenced by mlir::populateExpandTanhPattern().

◆ convertTanOp()

static LogicalResult convertTanOp ( math::TanOp  op,
PatternRewriter rewriter 
)
static

Definition at line 144 of file ExpandPatterns.cpp.

Referenced by mlir::populateExpandTanPattern().

◆ createFloatConst() [1/2]

static Value createFloatConst ( Location  loc,
Type  type,
APFloat  value,
OpBuilder b 
)
static

◆ createFloatConst() [2/2]

static Value createFloatConst ( Location  loc,
Type  type,
double  value,
OpBuilder b 
)
static

Definition at line 42 of file ExpandPatterns.cpp.

References createFloatConst().

◆ createIntConst()

static Value createIntConst ( Location  loc,
Type  type,
int64_t  value,
OpBuilder b 
)
static

◆ createTruncatedFPValue()

static Value createTruncatedFPValue ( Value  operand,
ImplicitLocOpBuilder b 
)
static