[Mlir-commits] [mlir] [MLIR][NVVM] Add `nvvm.tanh` OP (PR #199525)

Guray Ozen llvmlistbot at llvm.org
Mon May 25 11:53:39 PDT 2026


================
@@ -501,6 +501,30 @@ def NVVM_Ex2Op : NVVM_F32UnaryApproxOp<"ex2"> {
   }];
 }
 
+def NVVM_TanhOp : NVVM_Op<"tanh", [Pure, SameOperandsAndResultType]> {
+  let summary = "Hyperbolic tangent (fast approximation)";
+  let description = [{
+    Computes a fast approximation of the hyperbolic tangent of the input
+    value. Lowers to PTX `tanh.approx.f32` (sm_75+, PTX 7.0+). PTX does not
+    expose an `ftz` modifier for `tanh.approx`, so this op has no `ftz`
+    attribute.
+
+    For more information, see PTX ISA:
+    [tanh](https://docs.nvidia.com/cuda/parallel-thread-execution/#floating-point-instructions-tanh)
+  }];
+  let arguments = (ins F32:$src);
----------------
grypp wrote:

This would be great actually. There are following types
```
tanh.approx.type d, a;

.type = {.f16, .f16x2, .bf16, .bf16x2}
```

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


More information about the Mlir-commits mailing list