Skip to content

Commit aaed557

Browse files
fabianmcgjoker-eph
andauthored
[mlir][GPU] Fix docs modified by llvm#94910 (llvm#106295)
Fix docs modified by llvm#94910 by adding information about the `module` argument in `gpu::TargetAttrInterface::createObject`. --------- Co-authored-by: Mehdi Amini <joker.eph@gmail.com>
1 parent 51aceb5 commit aaed557

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

mlir/include/mlir/Dialect/GPU/IR/CompilationAttrInterfaces.td

+2
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ def GPUTargetAttrInterface : AttrInterface<"TargetAttrInterface"> {
4343
InterfaceMethod<[{
4444
Creates a GPU object attribute from a binary string.
4545

46+
The `module` parameter must be a `GPUModuleOp` and can be used to
47+
retrieve additional information like the list of kernels in the binary.
4648
The `object` parameter is a binary string. The `options` parameter is
4749
meant to be used for passing additional options that are not in the
4850
attribute.

mlir/unittests/Target/LLVM/SerializeToLLVMBitcode.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ TEST_F(MLIRTargetLLVM, SKIP_WITHOUT_NATIVE(SerializeToLLVMBitcode)) {
102102
std::optional<SmallVector<char, 0>>
103103
TargetAttrImpl::serializeToObject(Attribute attribute, Operation *module,
104104
const gpu::TargetOptions &options) const {
105+
// Set a dummy attr to be retrieved by `createObject`.
105106
module->setAttr("serialize_attr", UnitAttr::get(module->getContext()));
106107
std::string targetTriple = llvm::sys::getProcessTriple();
107108
LLVM::ModuleToObject serializer(*module, targetTriple, "", "");
@@ -112,13 +113,18 @@ Attribute
112113
TargetAttrImpl::createObject(Attribute attribute, Operation *module,
113114
const SmallVector<char, 0> &object,
114115
const gpu::TargetOptions &options) const {
116+
// Create a GPU object with the GPU module dictionary as the object
117+
// properties.
115118
return gpu::ObjectAttr::get(
116119
module->getContext(), attribute, gpu::CompilationTarget::Offload,
117120
StringAttr::get(module->getContext(),
118121
StringRef(object.data(), object.size())),
119122
module->getAttrDictionary(), /*kernels=*/nullptr);
120123
}
121124

125+
// This test checks the correct functioning of `TargetAttrInterface` as an API.
126+
// In particular, it shows how `TargetAttrInterface::createObject` can leverage
127+
// the `module` operation argument to retrieve information from the module.
122128
TEST_F(MLIRTargetLLVM, SKIP_WITHOUT_NATIVE(TargetAttrAPI)) {
123129
MLIRContext context(registry);
124130
context.loadAllAvailableDialects();

0 commit comments

Comments
 (0)