[Mlir-commits] [mlir] [ROCDL] Use attached target on the GPU module when lowering GPU ops to ROCDL (PR #110735)

Fabian Mora llvmlistbot at llvm.org
Fri Oct 4 07:02:37 PDT 2024


================
@@ -219,6 +219,28 @@ struct LowerGpuOpsToROCDLOpsPass
     gpu::GPUModuleOp m = getOperation();
     MLIRContext *ctx = m.getContext();
 
+    ArrayAttr targets = m.getTargetsAttr();
+    if (chipset == "infer") {
+      if (!targets) {
+        m->emitError("ROCDLTargetAttr is empty on GPU module");
+        return signalPassFailure();
+      }
+      if (targets.size() != 1) {
+        m->emitError("ROCDLTargetAttrs has more specified more than one "
+                     "gpu-arch on GPU module");
+        return signalPassFailure();
+      }
+      const ROCDL::ROCDLTargetAttr targetAttr =
+          mlir::dyn_cast<ROCDL::ROCDLTargetAttr>(targets.getValue().front());
----------------
fabianmcg wrote:

```suggestion
      ROCDL::ROCDLTargetAttr targetAttr =
          dyn_cast<ROCDL::ROCDLTargetAttr>(targets[0]);
```

https://github.com/llvm/llvm-project/pull/110735


More information about the Mlir-commits mailing list