[all-commits] [llvm/llvm-project] 05e85e: [mlir][Math] Add pass to legalize math functions t...
Krzysztof Drewniak via All-commits
all-commits at lists.llvm.org
Thu Jan 18 07:37:56 PST 2024
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 05e85e4fc5ac67612245efe56c3423cc9b47bc6d
https://github.com/llvm/llvm-project/commit/05e85e4fc5ac67612245efe56c3423cc9b47bc6d
Author: Krzysztof Drewniak <Krzysztof.Drewniak at amd.com>
Date: 2024-01-18 (Thu, 18 Jan 2024)
Changed paths:
M mlir/include/mlir/Dialect/Math/Transforms/Passes.h
M mlir/include/mlir/Dialect/Math/Transforms/Passes.td
M mlir/lib/Dialect/Math/Transforms/CMakeLists.txt
A mlir/lib/Dialect/Math/Transforms/LegalizeToF32.cpp
A mlir/test/Dialect/Math/legalize-to-f32.mlir
Log Message:
-----------
[mlir][Math] Add pass to legalize math functions to f32-or-higher (#78361)
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.
More information about the All-commits
mailing list