Hi folks,
I am encountered some issues when trying to emit gpu dialect with python binding.
This snippet
with Context(), Location.unknown():
module = Module.create()
with InsertionPoint(module.body):
# gpu.GPUModuleOp(operation: object)
# Cannot find any clue about what should be passed to above API.
# Use general operation creation API instead
gpu_module = Operation.create(
name="gpu.module",
results=[], operands=[],
attributes={"sym_name": StringAttr.get("ops")},
successors=None,
regions=1
)
gpu_module_block = Block.create_at_start(gpu_module.body)
with InsertionPoint(gpu_module_block):
gpu.ModuleEndOp()
with InsertionPoint.at_block_terminator(gpu_module_block):
# gpu.GPUFuncOp(operation: object)
# Cannot find any clue about what should be passed to above API.
# Use general operation creation API instead
f = Operation.create(
name="gpu.func",
results=[], operands=[],
attributes={
"sym_name": StringAttr.get("kernel"),
"function_type": TypeAttr.get(FunctionType.get([], [])),
},
successors=None,
regions=1
)
with InsertionPoint(Block.create_at_start(f.regions[0])):
gpu.ReturnOp([])
print(module)
gives me a segmentation fault, but follows are workable.
with Context(), Location.unknown():
module = Module.create()
with InsertionPoint(module.body):
# gpu.GPUModuleOp(operation: object)
# Cannot find any clue about what should be passed to above API.
# Use general operation creation API instead
gpu_module = Operation.create(
name="gpu.module",
results=[], operands=[],
attributes={"sym_name": StringAttr.get("ops")},
successors=None,
regions=1
)
gpu_module_block = Block.create_at_start(gpu_module.body)
with InsertionPoint(gpu_module_block):
gpu.ModuleEndOp()
print(module)
gives
module {
gpu.module @ops {
}
}
and
with Context(), Location.unknown():
module = Module.create()
with InsertionPoint(module.body):
# gpu.GPUModuleOp(operation: object)
# Cannot find any clue about which operation object should be passed to above API.
# Use general operation creation API instead
gpu_module = Operation.create(
name="gpu.module",
results=[], operands=[],
attributes={"sym_name": StringAttr.get("ops")},
successors=None,
regions=1
)
gpu_module_block = Block.create_at_start(gpu_module.body)
with InsertionPoint(gpu_module_block):
gpu.ModuleEndOp()
with InsertionPoint.at_block_terminator(gpu_module_block):
f = func.FuncOp("kernel", ([], []))
with InsertionPoint(f.add_entry_block()):
func.ReturnOp([])
print(module)
gives
module {
gpu.module @ops {
func.func @kernel() {
return
}
}
}
and
with Context(), Location.unknown():
module = Module.create()
with InsertionPoint(module.body):
# gpu.GPUModuleOp(operation: object)
# Cannot find any clue about what should be passed to above API.
# Use general operation creation API instead
gpu_module = Operation.create(
name="gpu.module",
results=[], operands=[],
attributes={"sym_name": StringAttr.get("ops")},
successors=None,
regions=1
)
gpu_module_block = Block.create_at_start(gpu_module.body)
with InsertionPoint(gpu_module_block):
gpu.ModuleEndOp()
with InsertionPoint.at_block_terminator(gpu_module_block):
f = Operation.create(
name="func.func",
results=[], operands=[],
attributes={
"sym_name": StringAttr.get("kernel"),
"function_type": TypeAttr.get(FunctionType.get([], [])),
},
successors=None,
regions=1
)
with InsertionPoint(Block.create_at_start(f.regions[0])):
func.ReturnOp([])
print(module)
also gives
module {
gpu.module @ops {
func.func @kernel() {
return
}
}
}
Ddi I miss anything?