Skip to content

Commit

Permalink
Add a test for lowering GPU ops that cover cases where the symbol tab…
Browse files Browse the repository at this point in the history
…le isn't held by a ModuleOp (NFC)

PiperOrigin-RevId: 277752004
  • Loading branch information
joker-eph authored and tensorflower-gardener committed Oct 31, 2019
1 parent 07b4ce7 commit ce94779
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
22 changes: 22 additions & 0 deletions mlir/test/Conversion/GPUToNVVM/gpu-to-nvvm.mlir
Expand Up @@ -100,3 +100,25 @@ module attributes {gpu.kernel_module} {
std.return
}
}

// -----

// Test that we handled properly operation with SymbolTable other than module op
module attributes {gpu.kernel_module} {
"test.symbol_scope"() ({
// CHECK: test.symbol_scope
// CHECK: llvm.func @__nv_expf(!llvm.float) -> !llvm.float
// CHECK: llvm.func @__nv_exp(!llvm.double) -> !llvm.double
// CHECK-LABEL: func @gpu_exp
func @gpu_exp(%arg_f32 : f32, %arg_f64 : f64) {
%exp_f32 = std.exp %arg_f32 : f32
// CHECK: llvm.call @__nv_expf(%{{.*}}) : (!llvm.float) -> !llvm.float
%result_f32 = std.exp %exp_f32 : f32
// CHECK: llvm.call @__nv_expf(%{{.*}}) : (!llvm.float) -> !llvm.float
%result64 = std.exp %arg_f64 : f64
// CHECK: llvm.call @__nv_exp(%{{.*}}) : (!llvm.double) -> !llvm.double
std.return
}
"test.finish" () : () -> ()
}) : () -> ()
}
23 changes: 23 additions & 0 deletions mlir/test/Conversion/GPUToROCDL/gpu-to-rocdl.mlir
Expand Up @@ -52,3 +52,26 @@ module attributes {gpu.kernel_module} {
std.return
}
}


// -----

// Test that we handled properly operation with SymbolTable other than module op
module attributes {gpu.kernel_module} {
"test.symbol_scope"() ({
// CHECK: test.symbol_scope
// CHECK: llvm.func @_ocml_exp_f32(!llvm.float) -> !llvm.float
// CHECK: llvm.func @_ocml_exp_f64(!llvm.double) -> !llvm.double
// CHECK-LABEL: func @gpu_exp
func @gpu_exp(%arg_f32 : f32, %arg_f64 : f64) {
%exp_f32 = std.exp %arg_f32 : f32
// CHECK: llvm.call @_ocml_exp_f32(%{{.*}}) : (!llvm.float) -> !llvm.float
%result_f32 = std.exp %exp_f32 : f32
// CHECK: llvm.call @_ocml_exp_f32(%{{.*}}) : (!llvm.float) -> !llvm.float
%result64 = std.exp %arg_f64 : f64
// CHECK: llvm.call @_ocml_exp_f64(%{{.*}}) : (!llvm.double) -> !llvm.double
std.return
}
"test.finish" () : () -> ()
}) : () -> ()
}

0 comments on commit ce94779

Please sign in to comment.