[Mlir-commits] [mlir] 0039a2f - [mlir][gpu] Add support for lowering math.erf to __nv_erf (#79848)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Mon Jan 29 11:35:28 PST 2024


Author: David Majnemer
Date: 2024-01-29T19:35:23Z
New Revision: 0039a2ff4fe98ce54654e5f4da90aeee718e1d41

URL: https://github.com/llvm/llvm-project/commit/0039a2ff4fe98ce54654e5f4da90aeee718e1d41
DIFF: https://github.com/llvm/llvm-project/commit/0039a2ff4fe98ce54654e5f4da90aeee718e1d41.diff

LOG: [mlir][gpu] Add support for lowering math.erf to __nv_erf (#79848)

Added: 
    

Modified: 
    mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp
    mlir/test/Conversion/GPUToNVVM/gpu-to-nvvm.mlir

Removed: 
    


################################################################################
diff  --git a/mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp b/mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp
index a7ac2332961ae21..d6a5d8cd74d5f20 100644
--- a/mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp
+++ b/mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp
@@ -367,6 +367,7 @@ void mlir::populateGpuToNVVMConversionPatterns(LLVMTypeConverter &converter,
   populateOpPatterns<math::CeilOp>(converter, patterns, "__nv_ceilf",
                                    "__nv_ceil");
   populateOpPatterns<math::CosOp>(converter, patterns, "__nv_cosf", "__nv_cos");
+  populateOpPatterns<math::ErfOp>(converter, patterns, "__nv_erff", "__nv_erf");
   populateOpPatterns<math::ExpOp>(converter, patterns, "__nv_expf", "__nv_exp");
   populateOpPatterns<math::Exp2Op>(converter, patterns, "__nv_exp2f",
                                    "__nv_exp2");

diff  --git a/mlir/test/Conversion/GPUToNVVM/gpu-to-nvvm.mlir b/mlir/test/Conversion/GPUToNVVM/gpu-to-nvvm.mlir
index 66630d33d118e6e..dd3b6c2080aa21b 100644
--- a/mlir/test/Conversion/GPUToNVVM/gpu-to-nvvm.mlir
+++ b/mlir/test/Conversion/GPUToNVVM/gpu-to-nvvm.mlir
@@ -627,6 +627,19 @@ gpu.module @test_module_31 {
   }
 }
 
+gpu.module @test_module_32 {
+  // CHECK: llvm.func @__nv_erff(f32) -> f32
+  // CHECK: llvm.func @__nv_erf(f64) -> f64
+  // CHECK-LABEL: func @gpu_erf
+  func.func @gpu_erf(%arg_f32 : f32, %arg_f64 : f64) -> (f32, f64) {
+    %result32 = math.erf %arg_f32 : f32
+    // CHECK: llvm.call @__nv_erff(%{{.*}}) : (f32) -> f32
+    %result64 = math.erf %arg_f64 : f64
+    // CHECK: llvm.call @__nv_erf(%{{.*}}) : (f64) -> f64
+    func.return %result32, %result64 : f32, f64
+  }
+}
+
 gpu.module @gpumodule {
 // CHECK-LABEL: func @kernel_with_block_size()
 // CHECK: attributes {gpu.kernel, gpu.known_block_size = array<i32: 128, 1, 1>, nvvm.kernel, nvvm.maxntid = array<i32: 128, 1, 1>} 


        


More information about the Mlir-commits mailing list