[Mlir-commits] [mlir] [MLIR][Math] Add erfc to math dialect (PR #126439)
Benoit Jacob
llvmlistbot at llvm.org
Thu Feb 13 17:36:26 PST 2025
================
@@ -318,6 +318,24 @@ OpFoldResult math::ErfOp::fold(FoldAdaptor adaptor) {
});
}
+//===----------------------------------------------------------------------===//
+// ErfcOp folder
+//===----------------------------------------------------------------------===//
+
+OpFoldResult math::ErfcOp::fold(FoldAdaptor adaptor) {
+ return constFoldUnaryOpConditional<FloatAttr>(
+ adaptor.getOperands(), [](const APFloat &a) -> std::optional<APFloat> {
+ switch (a.getSizeInBits(a.getSemantics())) {
+ case 64:
+ return APFloat(erfc(a.convertToDouble()));
+ case 32:
----------------
bjacob wrote:
I am not familiar with fltSemantics, but at least the idea is that there could be multiple semantics sharing the same bit width, like there is at 16 bit between fp16 and bf16. So maybe there is something a bit more righteous that could be done here, matching exact semantics of IEEE single / double precision rather than merely the size in bits.
https://github.com/llvm/llvm-project/pull/126439
More information about the Mlir-commits
mailing list