[MLIR][ROCDL] add gpu to rocdl erf support
authorManupa Karunaratne <manupa.karunaratne@amd.com>
Mon, 15 May 2023 14:41:49 +0000 (14:41 +0000)
committerKrzysztof Drewniak <Krzysztof.Drewniak@amd.com>
Mon, 15 May 2023 14:42:52 +0000 (14:42 +0000)
This commit adds lowering of lib func
call to support erf in rocdl.

Reviewed By: ThomasRaoux

Differential Revision: https://reviews.llvm.org/D150355

mlir/lib/Conversion/GPUToROCDL/LowerGpuOpsToROCDLOps.cpp
mlir/test/Conversion/GPUToROCDL/gpu-to-rocdl.mlir

index 1ac4e8ed00051b99918d7d52ca96aba8f09e4a4c..bd8201303748379dd4c92ffa4fdfab2bf4e15816 100644 (file)
@@ -280,6 +280,8 @@ void mlir::populateGpuToROCDLConversionPatterns(
                                    "__ocml_tanh_f64");
   populateOpPatterns<math::TanOp>(converter, patterns, "__ocml_tan_f32",
                                   "__ocml_tan_f64");
+  populateOpPatterns<math::ErfOp>(converter, patterns, "__ocml_erf_f32",
+                                  "__ocml_erf_f64");
 }
 
 std::unique_ptr<OperationPass<gpu::GPUModuleOp>>
index 31e78274fea32c857df6e06560f303c011876250..aec44034451fbe0e3cdc713f5ac4bbe7d662200c 100644 (file)
@@ -437,6 +437,21 @@ gpu.module @test_module {
 
 // -----
 
+gpu.module @test_module {
+  // CHECK: llvm.func @__ocml_erf_f32(f32) -> f32
+  // CHECK: llvm.func @__ocml_erf_f64(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 @__ocml_erf_f32(%{{.*}}) : (f32) -> f32
+    %result64 = math.erf %arg_f64 : f64
+    // CHECK: llvm.call @__ocml_erf_f64(%{{.*}}) : (f64) -> f64
+    func.return %result32, %result64 : f32, f64
+  }
+}
+
+// -----
+
 gpu.module @test_module {
   // CHECK-LABEL: func @gpu_unroll
   func.func @gpu_unroll(%arg0 : vector<4xf32>) -> vector<4xf32> {