Since most of the operations in the `math` dialect don't have low-precision implementations, add the -math-legalize-to-f32 pass that goes through and brackets low-precision math funcitons (like `math.sin %0 : f16`) with `arith.extf` and `arith.truncf`. This preserves the original semantics of the math operation but allows lowering to proceed. Versions of this lowering are already implicitly present in some passes, like ConvertGPUToROCDL. However, because those are implicit rewrites, they hide the floating-point extension and truncation, preventing anyone from writing passes that operate on those implitic extf/truncf pairs. Exposing this legalization explicitly is needed to allow lowening 8-bit floats on AMD GPUs, as the implementation of extf and truncf on that platform requires the complex logic found in ArithToAMDGPU, which runs before the GPU to ROCDL lowering.
25 lines
460 B
CMake
25 lines
460 B
CMake
add_mlir_dialect_library(MLIRMathTransforms
|
|
AlgebraicSimplification.cpp
|
|
ExpandPatterns.cpp
|
|
LegalizeToF32.cpp
|
|
PolynomialApproximation.cpp
|
|
UpliftToFMA.cpp
|
|
|
|
ADDITIONAL_HEADER_DIRS
|
|
${MLIR_MAIN_INCLUDE_DIR}/mlir/Dialect/Math/Transforms
|
|
|
|
DEPENDS
|
|
MLIRMathTransformsIncGen
|
|
|
|
LINK_LIBS PUBLIC
|
|
MLIRArithDialect
|
|
MLIRDialectUtils
|
|
MLIRIR
|
|
MLIRMathDialect
|
|
MLIRSCFDialect
|
|
MLIRPass
|
|
MLIRTransforms
|
|
MLIRX86VectorDialect
|
|
MLIRVectorDialect
|
|
)
|