[Mlir-commits] [mlir] 74b8880 - [mlir][rocdl] Add math::Exp2Op lowering to ROCDL
Adrian Kuegel
llvmlistbot at llvm.org
Thu Jul 15 05:33:20 PDT 2021
Author: Adrian Kuegel
Date: 2021-07-15T14:33:04+02:00
New Revision: 74b88807ae761da3ae1d5eb947d242a3492e23d0
URL: https://github.com/llvm/llvm-project/commit/74b88807ae761da3ae1d5eb947d242a3492e23d0
DIFF: https://github.com/llvm/llvm-project/commit/74b88807ae761da3ae1d5eb947d242a3492e23d0.diff
LOG: [mlir][rocdl] Add math::Exp2Op lowering to ROCDL
Differential Revision: https://reviews.llvm.org/D106057
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 001c45e653c0..356496598b66 100644
--- a/mlir/lib/Conversion/GPUToROCDL/LowerGpuOpsToROCDLOps.cpp
+++ b/mlir/lib/Conversion/GPUToROCDL/LowerGpuOpsToROCDLOps.cpp
@@ -91,9 +91,9 @@ void mlir::configureGpuToROCDLConversionLegality(ConversionTarget &target) {
target.addLegalDialect<::mlir::LLVM::LLVMDialect>();
target.addLegalDialect<ROCDL::ROCDLDialect>();
target.addIllegalDialect<gpu::GPUDialect>();
- target.addIllegalOp<LLVM::CosOp, LLVM::ExpOp, LLVM::FAbsOp, LLVM::FCeilOp,
- LLVM::FFloorOp, LLVM::LogOp, LLVM::Log10Op, LLVM::Log2Op,
- LLVM::PowOp, LLVM::SinOp, LLVM::SqrtOp>();
+ target.addIllegalOp<LLVM::CosOp, LLVM::ExpOp, LLVM::Exp2Op, LLVM::FAbsOp,
+ LLVM::FCeilOp, LLVM::FFloorOp, LLVM::LogOp, LLVM::Log10Op,
+ LLVM::Log2Op, LLVM::PowOp, LLVM::SinOp, LLVM::SqrtOp>();
// TODO: Remove once we support replacing non-root ops.
target.addLegalOp<gpu::YieldOp, gpu::GPUModuleOp, gpu::ModuleEndOp>();
@@ -128,6 +128,8 @@ void mlir::populateGpuToROCDLConversionPatterns(LLVMTypeConverter &converter,
"__ocml_cos_f64");
patterns.add<OpToFuncCallLowering<math::ExpOp>>(converter, "__ocml_exp_f32",
"__ocml_exp_f64");
+ patterns.add<OpToFuncCallLowering<math::Exp2Op>>(converter, "__ocml_exp2_f32",
+ "__ocml_exp2_f64");
patterns.add<OpToFuncCallLowering<math::ExpM1Op>>(
converter, "__ocml_expm1_f32", "__ocml_expm1_f64");
patterns.add<OpToFuncCallLowering<FloorFOp>>(converter, "__ocml_floor_f32",
diff --git a/mlir/test/Conversion/GPUToROCDL/gpu-to-rocdl.mlir b/mlir/test/Conversion/GPUToROCDL/gpu-to-rocdl.mlir
index 901e5ab4ed25..a7efd9ff202a 100644
--- a/mlir/test/Conversion/GPUToROCDL/gpu-to-rocdl.mlir
+++ b/mlir/test/Conversion/GPUToROCDL/gpu-to-rocdl.mlir
@@ -159,6 +159,22 @@ gpu.module @test_module {
}
}
+// -----
+
+gpu.module @test_module {
+ // CHECK: llvm.func @__ocml_exp2_f32(f32) -> f32
+ // CHECK: llvm.func @__ocml_exp2_f64(f64) -> f64
+ // CHECK-LABEL: func @gpu_exp2
+ func @gpu_exp2(%arg_f32 : f32, %arg_f64 : f64) -> (f32, f64) {
+ %exp2_f32 = math.exp2 %arg_f32 : f32
+ // CHECK: llvm.call @__ocml_exp2_f32(%{{.*}}) : (f32) -> f32
+ %result32 = math.exp2 %exp2_f32 : f32
+ // CHECK: llvm.call @__ocml_exp2_f32(%{{.*}}) : (f32) -> f32
+ %result64 = math.exp2 %arg_f64 : f64
+ // CHECK: llvm.call @__ocml_exp2_f64(%{{.*}}) : (f64) -> f64
+ std.return %result32, %result64 : f32, f64
+ }
+}
// -----
More information about the Mlir-commits
mailing list