[all-commits] [llvm/llvm-project] 9c7cde: Fix the lowering of `arith.truncf : f32 to bf16`. ...
Benoit Jacob via All-commits
all-commits at lists.llvm.org
Wed Feb 28 10:56:29 PST 2024
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 9c7cde64e6556f8a04dc4a14cbfb2b277d5ab4d9
https://github.com/llvm/llvm-project/commit/9c7cde64e6556f8a04dc4a14cbfb2b277d5ab4d9
Author: Benoit Jacob <jacob.benoit.1 at gmail.com>
Date: 2024-02-28 (Wed, 28 Feb 2024)
Changed paths:
M mlir/lib/Dialect/Arith/Transforms/ExpandOps.cpp
M mlir/test/Dialect/Arith/expand-ops.mlir
M mlir/test/mlir-cpu-runner/expand-arith-ops.mlir
Log Message:
-----------
Fix the lowering of `arith.truncf : f32 to bf16`. (#83180)
This lowering was not correctly handling the case where saturation of
the mantissa results in an increase of the exponent value. The new code
borrows, with credit, the idea from
https://github.com/pytorch/pytorch/blob/e1502c0cdbfd17548c612f25d5a65b1e4b86224d/c10/util/BFloat16.h#L60-L79
and adds comments to explain the magic trick going on here and why it's
correct. Hat tip to its original author, whom I believe to be
@Maratyszcza.
A testcase was also requiring a tie to be broken upwards in a case where
"to nearest-even" required going downward. The fact that it used to pass
suggests that there was another bug in the old code.
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list