Skip to content

Commit 0039a2f

Browse files
authored
[mlir][gpu] Add support for lowering math.erf to __nv_erf (#79848)
1 parent d9f1791 commit 0039a2f

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,7 @@ void mlir::populateGpuToNVVMConversionPatterns(LLVMTypeConverter &converter,
367367
populateOpPatterns<math::CeilOp>(converter, patterns, "__nv_ceilf",
368368
"__nv_ceil");
369369
populateOpPatterns<math::CosOp>(converter, patterns, "__nv_cosf", "__nv_cos");
370+
populateOpPatterns<math::ErfOp>(converter, patterns, "__nv_erff", "__nv_erf");
370371
populateOpPatterns<math::ExpOp>(converter, patterns, "__nv_expf", "__nv_exp");
371372
populateOpPatterns<math::Exp2Op>(converter, patterns, "__nv_exp2f",
372373
"__nv_exp2");

mlir/test/Conversion/GPUToNVVM/gpu-to-nvvm.mlir

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -627,6 +627,19 @@ gpu.module @test_module_31 {
627627
}
628628
}
629629

630+
gpu.module @test_module_32 {
631+
// CHECK: llvm.func @__nv_erff(f32) -> f32
632+
// CHECK: llvm.func @__nv_erf(f64) -> f64
633+
// CHECK-LABEL: func @gpu_erf
634+
func.func @gpu_erf(%arg_f32 : f32, %arg_f64 : f64) -> (f32, f64) {
635+
%result32 = math.erf %arg_f32 : f32
636+
// CHECK: llvm.call @__nv_erff(%{{.*}}) : (f32) -> f32
637+
%result64 = math.erf %arg_f64 : f64
638+
// CHECK: llvm.call @__nv_erf(%{{.*}}) : (f64) -> f64
639+
func.return %result32, %result64 : f32, f64
640+
}
641+
}
642+
630643
gpu.module @gpumodule {
631644
// CHECK-LABEL: func @kernel_with_block_size()
632645
// CHECK: attributes {gpu.kernel, gpu.known_block_size = array<i32: 128, 1, 1>, nvvm.kernel, nvvm.maxntid = array<i32: 128, 1, 1>}

0 commit comments

Comments
 (0)