Skip to content

Commit a4ad4f1

Browse files
committed
address reviewer comments
1 parent 1ba1fc7 commit a4ad4f1

File tree

5 files changed

+13
-12
lines changed

5 files changed

+13
-12
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,10 @@ def GPU_KernelTableAttr : GPU_Attr<"KernelTable", "kernel_table"> {
120120

121121
Examples:
122122
```mlir
123-
// Empty table
123+
// Empty table.
124124
#gpu.kernel_table<>
125125

126-
// Table with a single kernel
126+
// Table with a single kernel.
127127
#gpu.kernel_table<[#gpu.kernel<kernel0, () -> () >]>
128128

129129
// Table with multiple kernels.

mlir/lib/Dialect/GPU/IR/GPUDialect.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2274,15 +2274,13 @@ KernelTableAttr::verify(function_ref<InFlightDiagnostic()> emitError,
22742274
}
22752275

22762276
KernelAttr KernelTableAttr::lookup(StringRef key) const {
2277-
std::pair<ArrayRef<KernelAttr>::iterator, bool> it =
2278-
impl::findAttrSorted(begin(), end(), key);
2279-
return it.second ? *it.first : KernelAttr();
2277+
auto [iterator, found] = impl::findAttrSorted(begin(), end(), key);
2278+
return found ? *iterator : KernelAttr();
22802279
}
22812280

22822281
KernelAttr KernelTableAttr::lookup(StringAttr key) const {
2283-
std::pair<ArrayRef<KernelAttr>::iterator, bool> it =
2284-
impl::findAttrSorted(begin(), end(), key);
2285-
return it.second ? *it.first : KernelAttr();
2282+
auto [iterator, found] = impl::findAttrSorted(begin(), end(), key);
2283+
return found ? *iterator : KernelAttr();
22862284
}
22872285

22882286
//===----------------------------------------------------------------------===//

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -506,12 +506,15 @@ ROCDLTargetAttrImpl::createObject(Attribute attribute, Operation *module,
506506
gpu::CompilationTarget format = options.getCompilationTarget();
507507
// If format is `fatbin` transform it to binary as `fatbin` is not yet
508508
// supported.
509-
if (format > gpu::CompilationTarget::Binary)
509+
gpu::KernelTableAttr kernels;
510+
if (format > gpu::CompilationTarget::Binary) {
510511
format = gpu::CompilationTarget::Binary;
512+
kernels = ROCDL::getKernelMetadata(module, object);
513+
}
511514
DictionaryAttr properties{};
512515
Builder builder(attribute.getContext());
513516
StringAttr objectStr =
514517
builder.getStringAttr(StringRef(object.data(), object.size()));
515518
return builder.getAttr<gpu::ObjectAttr>(attribute, format, objectStr,
516-
properties, nullptr);
519+
properties, kernels);
517520
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ mlir::ROCDL::getAMDHSAKernelsELFMetadata(Builder &builder,
3131
llvm::Error error = llvm::offloading::amdgpu::getAMDGPUMetaDataFromImage(
3232
buffer, kernels, elfABIVersion);
3333
// Return `nullopt` if the metadata couldn't be retrieved.
34-
if (!error) {
34+
if (error) {
3535
llvm::consumeError(std::move(error));
3636
return std::nullopt;
3737
}

mlir/unittests/Target/LLVM/SerializeToLLVMBitcode.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ TargetAttrImpl::createObject(Attribute attribute, Operation *module,
116116
module->getContext(), attribute, gpu::CompilationTarget::Offload,
117117
StringAttr::get(module->getContext(),
118118
StringRef(object.data(), object.size())),
119-
module->getAttrDictionary());
119+
module->getAttrDictionary(), nullptr);
120120
}
121121

122122
TEST_F(MLIRTargetLLVM, SKIP_WITHOUT_NATIVE(TargetAttrAPI)) {

0 commit comments

Comments
 (0)