[Mlir-commits] [mlir] [mlir][spirv] Make gen_spirv_dialect.py more precise when finding inst_category (PR #111777)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Wed Oct 9 18:01:09 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-mlir

Author: Caio Oliveira (cmarcelo)

<details>
<summary>Changes</summary>

Use a word boundary, current code was currently failing when parsing the definition of because it would also match
`CooperativeMatrixOp` from a later mention of
`SPIRV_KHR_CooperativeMatrixOperandsAttr`.

---
Full diff: https://github.com/llvm/llvm-project/pull/111777.diff


1 Files Affected:

- (modified) mlir/utils/spirv/gen_spirv_dialect.py (+1-1) 


``````````diff
diff --git a/mlir/utils/spirv/gen_spirv_dialect.py b/mlir/utils/spirv/gen_spirv_dialect.py
index 78c1022428d8a1..605812fc1a7e82 100755
--- a/mlir/utils/spirv/gen_spirv_dialect.py
+++ b/mlir/utils/spirv/gen_spirv_dialect.py
@@ -979,7 +979,7 @@ def extract_td_op_info(op_def):
     # Get instruction category
     prefix = "SPIRV_"
     inst_category = [
-        o[len(prefix) :] for o in re.findall(prefix + "\w+Op", op_def.split(":", 1)[1])
+        o[len(prefix) :] for o in re.findall(prefix + r"\w+Op\b", op_def.split(":", 1)[1])
     ]
     assert len(inst_category) <= 1, "more than one ops in the same section!"
     inst_category = inst_category[0] if len(inst_category) == 1 else "Op"

``````````

</details>


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


More information about the Mlir-commits mailing list