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

Pradeep Kumar llvmlistbot at llvm.org
Mon May 25 08:59:31 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);
----------------
schwarzschild-radius wrote:

Should we enable support for other types like f16, bf16?

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


More information about the Mlir-commits mailing list