Skip to content

Commit 5d05b68

Browse files
committed
[mlir][SPIRV] Fix lookup logic spirv.target_env for gpu.module
The `gpu.module` operation can contain `spirv.target_env` attributes within an array attribute named `"targets"`. So it accounts for that case by iterating over the `"targets"` attribute, if present, and looking up `spirv.target_env`.
1 parent 784bd61 commit 5d05b68

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

mlir/lib/Dialect/SPIRV/IR/TargetAndABI.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,15 @@ spirv::TargetEnvAttr spirv::lookupTargetEnv(Operation *op) {
184184
if (!op)
185185
break;
186186

187+
if (auto arrAttr = op->getAttrOfType<ArrayAttr>("targets")) {
188+
for (auto attr : arrAttr) {
189+
if (auto spirvTargetEnvAttr =
190+
llvm::dyn_cast<spirv::TargetEnvAttr>(attr)) {
191+
return spirvTargetEnvAttr;
192+
}
193+
}
194+
}
195+
187196
if (auto attr = op->getAttrOfType<spirv::TargetEnvAttr>(
188197
spirv::getTargetEnvAttrName()))
189198
return attr;

0 commit comments

Comments
 (0)