[Mlir-commits] [mlir] [mlir][GPU] Fix docs modified by #94910 (PR #106295)
Fabian Mora
llvmlistbot at llvm.org
Tue Aug 27 14:43:27 PDT 2024
https://github.com/fabianmcg updated https://github.com/llvm/llvm-project/pull/106295
>From bc81997ad818c4456e3a1275eed29ead0e13aa44 Mon Sep 17 00:00:00 2001
From: Fabian Mora <fmora.dev at gmail.com>
Date: Tue, 27 Aug 2024 19:49:27 +0000
Subject: [PATCH 1/2] [mlir][GPU] Fix docs modified by #94910
Fix docs modified by #94910 by adding information about the `module` argument in
`gpu::TargetAttrInterface::createObject`.
---
.../mlir/Dialect/GPU/IR/CompilationAttrInterfaces.td | 2 ++
mlir/unittests/Target/LLVM/SerializeToLLVMBitcode.cpp | 6 ++++++
2 files changed, 8 insertions(+)
diff --git a/mlir/include/mlir/Dialect/GPU/IR/CompilationAttrInterfaces.td b/mlir/include/mlir/Dialect/GPU/IR/CompilationAttrInterfaces.td
index 3d73d00ecfdd7e..de637b48835314 100644
--- a/mlir/include/mlir/Dialect/GPU/IR/CompilationAttrInterfaces.td
+++ b/mlir/include/mlir/Dialect/GPU/IR/CompilationAttrInterfaces.td
@@ -43,6 +43,8 @@ def GPUTargetAttrInterface : AttrInterface<"TargetAttrInterface"> {
InterfaceMethod<[{
Creates a GPU object attribute from a binary string.
+ The `module` parameter must be a GPU Module Op and can be used to
+ retrieve additional information like the list of kernels in the binary.
The `object` parameter is a binary string. The `options` parameter is
meant to be used for passing additional options that are not in the
attribute.
diff --git a/mlir/unittests/Target/LLVM/SerializeToLLVMBitcode.cpp b/mlir/unittests/Target/LLVM/SerializeToLLVMBitcode.cpp
index 37dbfe62036871..8910a6505993bc 100644
--- a/mlir/unittests/Target/LLVM/SerializeToLLVMBitcode.cpp
+++ b/mlir/unittests/Target/LLVM/SerializeToLLVMBitcode.cpp
@@ -102,6 +102,7 @@ TEST_F(MLIRTargetLLVM, SKIP_WITHOUT_NATIVE(SerializeToLLVMBitcode)) {
std::optional<SmallVector<char, 0>>
TargetAttrImpl::serializeToObject(Attribute attribute, Operation *module,
const gpu::TargetOptions &options) const {
+ // Set a dummy attr to be retrieved by `createObject`.
module->setAttr("serialize_attr", UnitAttr::get(module->getContext()));
std::string targetTriple = llvm::sys::getProcessTriple();
LLVM::ModuleToObject serializer(*module, targetTriple, "", "");
@@ -112,6 +113,8 @@ Attribute
TargetAttrImpl::createObject(Attribute attribute, Operation *module,
const SmallVector<char, 0> &object,
const gpu::TargetOptions &options) const {
+ // Create a GPU object with the GPU module dictionary as the object
+ // properties.
return gpu::ObjectAttr::get(
module->getContext(), attribute, gpu::CompilationTarget::Offload,
StringAttr::get(module->getContext(),
@@ -119,6 +122,9 @@ TargetAttrImpl::createObject(Attribute attribute, Operation *module,
module->getAttrDictionary());
}
+// This test checks the correct functioning of `TargetAttrInterface` as an API.
+// In particular, it shows how `TargetAttrInterface::createObject` can leverage
+// the `module` operation argument to retrieve information from the module.
TEST_F(MLIRTargetLLVM, SKIP_WITHOUT_NATIVE(TargetAttrAPI)) {
MLIRContext context(registry);
context.loadAllAvailableDialects();
>From d4317446ab98e1dc4b80fb67cb726c5a86e4966e Mon Sep 17 00:00:00 2001
From: Fabian Mora <fmora.dev at gmail.com>
Date: Tue, 27 Aug 2024 17:43:20 -0400
Subject: [PATCH 2/2] Update
mlir/include/mlir/Dialect/GPU/IR/CompilationAttrInterfaces.td
Co-authored-by: Mehdi Amini <joker.eph at gmail.com>
---
mlir/include/mlir/Dialect/GPU/IR/CompilationAttrInterfaces.td | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mlir/include/mlir/Dialect/GPU/IR/CompilationAttrInterfaces.td b/mlir/include/mlir/Dialect/GPU/IR/CompilationAttrInterfaces.td
index de637b48835314..6d5fd014991213 100644
--- a/mlir/include/mlir/Dialect/GPU/IR/CompilationAttrInterfaces.td
+++ b/mlir/include/mlir/Dialect/GPU/IR/CompilationAttrInterfaces.td
@@ -43,7 +43,7 @@ def GPUTargetAttrInterface : AttrInterface<"TargetAttrInterface"> {
InterfaceMethod<[{
Creates a GPU object attribute from a binary string.
- The `module` parameter must be a GPU Module Op and can be used to
+ The `module` parameter must be a `GPUModuleOp` and can be used to
retrieve additional information like the list of kernels in the binary.
The `object` parameter is a binary string. The `options` parameter is
meant to be used for passing additional options that are not in the
More information about the Mlir-commits
mailing list