[Mlir-commits] [mlir] 1c6bc2c - [MLIR] Add lowerings for atan and atan2 to ROCDL intrinsics
Frederik Gossen
llvmlistbot at llvm.org
Mon Dec 14 01:43:38 PST 2020
Author: Frederik Gossen
Date: 2020-12-14T10:43:19+01:00
New Revision: 1c6bc2c0b5afca9b4e7fdb33ea0ad95336df330c
URL: https://github.com/llvm/llvm-project/commit/1c6bc2c0b5afca9b4e7fdb33ea0ad95336df330c
DIFF: https://github.com/llvm/llvm-project/commit/1c6bc2c0b5afca9b4e7fdb33ea0ad95336df330c.diff
LOG: [MLIR] Add lowerings for atan and atan2 to ROCDL intrinsics
Differential Revision: https://reviews.llvm.org/D93123
Added:
Modified:
mlir/lib/Conversion/GPUToROCDL/LowerGpuOpsToROCDLOps.cpp
mlir/test/Conversion/GPUToROCDL/gpu-to-rocdl.mlir
Removed:
################################################################################
diff --git a/mlir/lib/Conversion/GPUToROCDL/LowerGpuOpsToROCDLOps.cpp b/mlir/lib/Conversion/GPUToROCDL/LowerGpuOpsToROCDLOps.cpp
index 4ed1f0761c92..b6f4238a4a5e 100644
--- a/mlir/lib/Conversion/GPUToROCDL/LowerGpuOpsToROCDLOps.cpp
+++ b/mlir/lib/Conversion/GPUToROCDL/LowerGpuOpsToROCDLOps.cpp
@@ -105,6 +105,10 @@ void mlir::populateGpuToROCDLConversionPatterns(
GPUFuncOpLowering<5>, GPUReturnOpLowering>(converter);
patterns.insert<OpToFuncCallLowering<AbsFOp>>(converter, "__ocml_fabs_f32",
"__ocml_fabs_f64");
+ patterns.insert<OpToFuncCallLowering<AtanOp>>(converter, "__ocml_atan_f32",
+ "__ocml_atan_f64");
+ patterns.insert<OpToFuncCallLowering<Atan2Op>>(converter, "__ocml_atan2_f32",
+ "__ocml_atan2_f64");
patterns.insert<OpToFuncCallLowering<CeilFOp>>(converter, "__ocml_ceil_f32",
"__ocml_ceil_f64");
patterns.insert<OpToFuncCallLowering<CosOp>>(converter, "__ocml_cos_f32",
diff --git a/mlir/test/Conversion/GPUToROCDL/gpu-to-rocdl.mlir b/mlir/test/Conversion/GPUToROCDL/gpu-to-rocdl.mlir
index acc3826cacce..c57f98571df6 100644
--- a/mlir/test/Conversion/GPUToROCDL/gpu-to-rocdl.mlir
+++ b/mlir/test/Conversion/GPUToROCDL/gpu-to-rocdl.mlir
@@ -280,3 +280,33 @@ gpu.module @test_module {
std.return %result32, %result64 : f32, f64
}
}
+
+// -----
+
+gpu.module @test_module {
+ // CHECK: llvm.func @__ocml_atan_f32(!llvm.float) -> !llvm.float
+ // CHECK: llvm.func @__ocml_atan_f64(!llvm.double) -> !llvm.double
+ // CHECK-LABEL: func @gpu_atan
+ func @gpu_atan(%arg_f32 : f32, %arg_f64 : f64) -> (f32, f64) {
+ %result32 = std.atan %arg_f32 : f32
+ // CHECK: llvm.call @__ocml_atan_f32(%{{.*}}) : (!llvm.float) -> !llvm.float
+ %result64 = std.atan %arg_f64 : f64
+ // CHECK: llvm.call @__ocml_atan_f64(%{{.*}}) : (!llvm.double) -> !llvm.double
+ std.return %result32, %result64 : f32, f64
+ }
+}
+
+// -----
+
+gpu.module @test_module {
+ // CHECK: llvm.func @__ocml_atan2_f32(!llvm.float, !llvm.float) -> !llvm.float
+ // CHECK: llvm.func @__ocml_atan2_f64(!llvm.double, !llvm.double) -> !llvm.double
+ // CHECK-LABEL: func @gpu_atan2
+ func @gpu_atan2(%arg_f32 : f32, %arg_f64 : f64) -> (f32, f64) {
+ %result32 = std.atan2 %arg_f32, %arg_f32 : f32
+ // CHECK: llvm.call @__ocml_atan2_f32(%{{.*}}) : (!llvm.float, !llvm.float) -> !llvm.float
+ %result64 = std.atan2 %arg_f64, %arg_f64 : f64
+ // CHECK: llvm.call @__ocml_atan2_f64(%{{.*}}) : (!llvm.double, !llvm.double) -> !llvm.double
+ std.return %result32, %result64 : f32, f64
+ }
+}
More information about the Mlir-commits
mailing list