[Mlir-commits] [mlir] [MLIR][Transforms] add eliminate-explicit-rounding pass (PR #93443)

Ivy Zhang llvmlistbot at llvm.org
Wed May 29 20:21:59 PDT 2024


crazydemo wrote:

> This seems like a bit of a heavy hammer, I would like to understand the motivation better (why not improve the passes that introduce these extensions/truncations, why only support a few fp types but not the rest).

Thank you for your feedback. I understand your concerns and would like to provide some clarification on the motivation behind this approach:

Objective:
My goal is to eliminate the intermediate truncf/extf pairs inserted during all f32 promotions to improve performance.

1. Why Not Modify the Passes Introducing These Ops:
The promotion passes that introduce these op pairs are quite scattered; some are in the math dialect, while others are in the arith dialect. We cannot be sure if future passes might also introduce similar promotions. Therefore, I believe having a separate, dedicated pass to handle these promotion-generated op pairs uniformly is a more robust and maintainable solution.

2. Why Only Support bf16/f16:
Eliminating these op pairs can introduce some numerical differences. We have tested the elimination of rounding between bf16/f16 and f32 in end-to-end models and found that the impact on precision is minimal and acceptable. However, I haven't conducted similar tests for other data types, so support for them is currently not included.

3. Support List:
I don't think a support list is necessary because the elimination process is solely related to the data type. Currently, it only supports bf16/f16 to f32. If we need to add support for other data types in the future, we can modify the pass accordingly.

4. Regarding @krzysz00‘s Proposal:
Functionally, this PR is consistent with krzysz00's proposal. However, I don't believe adding a fast-math attribute is appropriate as it could cause confusion. Eliminating rounding should not be associated with fast-math attributes, as they are conceptually different.

5. All other comments are resolved.

https://github.com/llvm/llvm-project/pull/93443


More information about the Mlir-commits mailing list