Verification for gpu.launch_func should rely on function type and not on the

actual body of a kernel function. This enables using gpu.launch_func with
external kernel declarations.

PiperOrigin-RevId: 253639770
This commit is contained in:
Stephan Herhut 2019-06-17 12:47:09 -07:00 committed by Mehdi Amini
parent 31e2a6efe5
commit cf74e41277
2 changed files with 10 additions and 2 deletions

View File

@ -369,9 +369,9 @@ LogicalResult LaunchFuncOp::verify() {
<< getNumKernelOperands() << " kernel operands but expected "
<< numKernelFuncArgs;
}
auto functionType = kernelFunc->getType();
for (unsigned i = 0; i < numKernelFuncArgs; ++i) {
if (getKernelOperand(i)->getType() !=
kernelFunc->getArgument(i)->getType()) {
if (getKernelOperand(i)->getType() != functionType.getInput(i)) {
return emitOpError("type of function argument ")
<< i << " does not match";
}

View File

@ -81,6 +81,9 @@ func @kernel_1(%arg0 : f32, %arg1 : memref<?xf32, 1>)
return
}
func @kernel_2(f32, memref<?xf32, 1>)
attributes { gpu.kernel }
func @foo() {
%0 = "op"() : () -> (f32)
%1 = "op"() : () -> (memref<?xf32, 1>)
@ -90,5 +93,10 @@ func @foo() {
// CHECK: "gpu.launch_func"(%c8, %c8, %c8, %c8, %c8, %c8, %0, %1) {kernel: @kernel_1} : (index, index, index, index, index, index, f32, memref<?xf32, 1>) -> ()
"gpu.launch_func"(%cst, %cst, %cst, %cst, %cst, %cst, %0, %1) { kernel: @kernel_1 }
: (index, index, index, index, index, index, f32, memref<?xf32, 1>) -> ()
// CHECK: "gpu.launch_func"(%c8, %c8, %c8, %c8, %c8, %c8, %0, %1) {kernel: @kernel_2} : (index, index, index, index, index, index, f32, memref<?xf32, 1>) -> ()
"gpu.launch_func"(%cst, %cst, %cst, %cst, %cst, %cst, %0, %1) { kernel: @kernel_2 }
: (index, index, index, index, index, index, f32, memref<?xf32, 1>) -> ()
return
}