Skip to content

Commit 5817142

Browse files
committed
[mlir][gpu] Pass GPU module to TargetAttrInterface::createObject.
This patch adds an argument to `gpu::TargetAttrInterface::createObject` to pass the GPU module. This is useful as `gpu::ObjectAttr` contains a property dict for metadata, and passing the module allows extracting things like the symbol table and adding it to the property dict.
1 parent 26ca782 commit 5817142

File tree

4 files changed

+8
-7
lines changed

4 files changed

+8
-7
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ def GPUTargetAttrInterface : AttrInterface<"TargetAttrInterface"> {
4747
meant to be used for passing additional options that are not in the
4848
attribute.
4949
}], "::mlir::Attribute", "createObject",
50-
(ins "const ::llvm::SmallVector<char, 0>&":$object,
50+
(ins "::mlir::Operation*":$module,
51+
"const ::llvm::SmallVector<char, 0>&":$object,
5152
"const ::mlir::gpu::TargetOptions&":$options)>
5253
];
5354
}

mlir/lib/Target/LLVM/NVVM/Target.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class NVVMTargetAttrImpl
4949
serializeToObject(Attribute attribute, Operation *module,
5050
const gpu::TargetOptions &options) const;
5151

52-
Attribute createObject(Attribute attribute,
52+
Attribute createObject(Attribute attribute, Operation *module,
5353
const SmallVector<char, 0> &object,
5454
const gpu::TargetOptions &options) const;
5555
};
@@ -591,7 +591,7 @@ NVVMTargetAttrImpl::serializeToObject(Attribute attribute, Operation *module,
591591
}
592592

593593
Attribute
594-
NVVMTargetAttrImpl::createObject(Attribute attribute,
594+
NVVMTargetAttrImpl::createObject(Attribute attribute, Operation *module,
595595
const SmallVector<char, 0> &object,
596596
const gpu::TargetOptions &options) const {
597597
auto target = cast<NVVMTargetAttr>(attribute);

mlir/lib/Target/LLVM/ROCDL/Target.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class ROCDLTargetAttrImpl
5959
serializeToObject(Attribute attribute, Operation *module,
6060
const gpu::TargetOptions &options) const;
6161

62-
Attribute createObject(Attribute attribute,
62+
Attribute createObject(Attribute attribute, Operation *module,
6363
const SmallVector<char, 0> &object,
6464
const gpu::TargetOptions &options) const;
6565
};
@@ -500,7 +500,7 @@ std::optional<SmallVector<char, 0>> ROCDLTargetAttrImpl::serializeToObject(
500500
}
501501

502502
Attribute
503-
ROCDLTargetAttrImpl::createObject(Attribute attribute,
503+
ROCDLTargetAttrImpl::createObject(Attribute attribute, Operation *module,
504504
const SmallVector<char, 0> &object,
505505
const gpu::TargetOptions &options) const {
506506
gpu::CompilationTarget format = options.getCompilationTarget();

mlir/lib/Target/SPIRV/Target.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class SPIRVTargetAttrImpl
3434
serializeToObject(Attribute attribute, Operation *module,
3535
const gpu::TargetOptions &options) const;
3636

37-
Attribute createObject(Attribute attribute,
37+
Attribute createObject(Attribute attribute, Operation *module,
3838
const SmallVector<char, 0> &object,
3939
const gpu::TargetOptions &options) const;
4040
};
@@ -89,7 +89,7 @@ std::optional<SmallVector<char, 0>> SPIRVTargetAttrImpl::serializeToObject(
8989

9090
// Prepare Attribute for gpu.binary with serialized kernel object
9191
Attribute
92-
SPIRVTargetAttrImpl::createObject(Attribute attribute,
92+
SPIRVTargetAttrImpl::createObject(Attribute attribute, Operation *module,
9393
const SmallVector<char, 0> &object,
9494
const gpu::TargetOptions &options) const {
9595
gpu::CompilationTarget format = options.getCompilationTarget();

0 commit comments

Comments
 (0)