[PATCH] D73471: Add tanh lowering from Standard dialect to NVVM and ROCDL.
Julian Gross via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 27 07:47:00 PST 2020
dfki-jugr updated this revision to Diff 240586.
dfki-jugr added a comment.
Fixed clang format issue.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D73471/new/
https://reviews.llvm.org/D73471
Files:
mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp
mlir/lib/Conversion/GPUToROCDL/LowerGpuOpsToROCDLOps.cpp
mlir/test/Conversion/GPUToNVVM/gpu-to-nvvm.mlir
mlir/test/Conversion/GPUToROCDL/gpu-to-rocdl.mlir
Index: mlir/test/Conversion/GPUToROCDL/gpu-to-rocdl.mlir
===================================================================
--- mlir/test/Conversion/GPUToROCDL/gpu-to-rocdl.mlir
+++ mlir/test/Conversion/GPUToROCDL/gpu-to-rocdl.mlir
@@ -83,6 +83,20 @@
// -----
+gpu.module @kernel_module {
+ // CHECK: llvm.func @_ocml_tanh_f32(!llvm.float) -> !llvm.float
+ // CHECK: llvm.func @_ocml_tanh_f64(!llvm.double) -> !llvm.double
+ // CHECK-LABEL: func @gpu_tanh
+ func @gpu_tanh(%arg_f32 : f32, %arg_f64 : f64) {
+ %result32 = std.tanh %arg_f32 : f32
+ // CHECK: llvm.call @_ocml_tanh_f32(%{{.*}}) : (!llvm.float) -> !llvm.float
+ %result64 = std.tanh %arg_f64 : f64
+ // CHECK: llvm.call @_ocml_tanh_f64(%{{.*}}) : (!llvm.double) -> !llvm.double
+ std.return
+ }
+}
+
+// -----
gpu.module @kernel_module {
// CHECK: llvm.func @_ocml_exp_f32(!llvm.float) -> !llvm.float
// CHECK: llvm.func @_ocml_exp_f64(!llvm.double) -> !llvm.double
Index: mlir/test/Conversion/GPUToNVVM/gpu-to-nvvm.mlir
===================================================================
--- mlir/test/Conversion/GPUToNVVM/gpu-to-nvvm.mlir
+++ mlir/test/Conversion/GPUToNVVM/gpu-to-nvvm.mlir
@@ -156,6 +156,20 @@
// -----
+gpu.module @test_module {
+ // CHECK: llvm.func @__nv_tanhf(!llvm.float) -> !llvm.float
+ // CHECK: llvm.func @__nv_tanh(!llvm.double) -> !llvm.double
+ // CHECK-LABEL: func @gpu_tanh
+ func @gpu_tanh(%arg_f32 : f32, %arg_f64 : f64) {
+ %result32 = std.tanh %arg_f32 : f32
+ // CHECK: llvm.call @__nv_tanhf(%{{.*}}) : (!llvm.float) -> !llvm.float
+ %result64 = std.tanh %arg_f64 : f64
+ // CHECK: llvm.call @__nv_tanh(%{{.*}}) : (!llvm.double) -> !llvm.double
+ std.return
+ }
+}
+
+// -----
gpu.module @test_module {
// CHECK: llvm.func @__nv_expf(!llvm.float) -> !llvm.float
// CHECK: llvm.func @__nv_exp(!llvm.double) -> !llvm.double
Index: mlir/lib/Conversion/GPUToROCDL/LowerGpuOpsToROCDLOps.cpp
===================================================================
--- mlir/lib/Conversion/GPUToROCDL/LowerGpuOpsToROCDLOps.cpp
+++ mlir/lib/Conversion/GPUToROCDL/LowerGpuOpsToROCDLOps.cpp
@@ -58,6 +58,8 @@
"_ocml_cos_f64");
patterns.insert<OpToFuncCallLowering<ExpOp>>(converter, "_ocml_exp_f32",
"_ocml_exp_f64");
+ patterns.insert<OpToFuncCallLowering<TanhOp>>(converter, "_ocml_tanh_f32",
+ "_ocml_tanh_f64");
ConversionTarget target(getContext());
target.addLegalDialect<LLVM::LLVMDialect, ROCDL::ROCDLDialect>();
Index: mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp
===================================================================
--- mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp
+++ mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp
@@ -746,6 +746,8 @@
"__nv_cos");
patterns.insert<OpToFuncCallLowering<ExpOp>>(converter, "__nv_expf",
"__nv_exp");
+ patterns.insert<OpToFuncCallLowering<TanhOp>>(converter, "__nv_tanhf",
+ "__nv_tanh");
}
std::unique_ptr<OpPassBase<gpu::GPUModuleOp>>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D73471.240586.patch
Type: text/x-patch
Size: 3293 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200127/634d5f42/attachment.bin>
More information about the llvm-commits
mailing list