[llvm] [mlir][python] smaller scope for vector enumgen (PR #66992)

Oleksandr Alex Zinenko via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 21 03:57:25 PDT 2023


https://github.com/ftynse updated https://github.com/llvm/llvm-project/pull/66992

>From 3d6029dfde1b99543ca00c52f8df25e79fc49d2f Mon Sep 17 00:00:00 2001
From: Alex Zinenko <zinenko at google.com>
Date: Thu, 21 Sep 2023 09:19:49 +0000
Subject: [PATCH 1/2] [mlir][python] smaller scope for vector enumgen

Don't generate enums from the main VectorOps.td file as that
transitively includes enums from Arith.
---
 mlir/python/CMakeLists.txt                    |  3 ++-
 mlir/python/mlir/dialects/VectorAttributes.td | 14 ++++++++++++++
 2 files changed, 16 insertions(+), 1 deletion(-)
 create mode 100644 mlir/python/mlir/dialects/VectorAttributes.td

diff --git a/mlir/python/CMakeLists.txt b/mlir/python/CMakeLists.txt
index 25be18fced0f7ac..9368cb4c2f1657f 100644
--- a/mlir/python/CMakeLists.txt
+++ b/mlir/python/CMakeLists.txt
@@ -381,7 +381,8 @@ declare_mlir_dialect_python_bindings(
   TD_FILE dialects/VectorOps.td
   SOURCES dialects/vector.py
   DIALECT_NAME vector
-  GEN_ENUM_BINDINGS)
+  GEN_ENUM_BINDINGS_TD_FILE
+    "dialects/VectorAttributes.td")
 
 ################################################################################
 # Python extensions.
diff --git a/mlir/python/mlir/dialects/VectorAttributes.td b/mlir/python/mlir/dialects/VectorAttributes.td
new file mode 100644
index 000000000000000..038e0ba21c3b25e
--- /dev/null
+++ b/mlir/python/mlir/dialects/VectorAttributes.td
@@ -0,0 +1,14 @@
+//===-- VectorAttributes.td - Entry point for bindings -----*- tablegen -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef PYTHON_BINDINGS_VECTOR_ATTRDEFS_TD
+#define PYTHON_BINDINGS_VECTOR_ATTRDEFS_TD
+
+include "mlir/Dialect/Vector/IR/VectorAttributes.td"
+
+#endif // PYTHON_BINDINGS_VECTOR_ATTRDEFS_TD

>From b9404fd1768b4006cdb87ca43a244eeb24148602 Mon Sep 17 00:00:00 2001
From: Nicolas Vasilache <ntv at google.com>
Date: Thu, 21 Sep 2023 10:56:28 +0000
Subject: [PATCH 2/2] bazel

---
 .../mlir/python/BUILD.bazel                   | 23 +++++++++++++++----
 1 file changed, 18 insertions(+), 5 deletions(-)

diff --git a/utils/bazel/llvm-project-overlay/mlir/python/BUILD.bazel b/utils/bazel/llvm-project-overlay/mlir/python/BUILD.bazel
index 8d5e921fa6b01dc..208604bcc3a8b7f 100644
--- a/utils/bazel/llvm-project-overlay/mlir/python/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/mlir/python/BUILD.bazel
@@ -1353,21 +1353,34 @@ gentbl_filegroup(
     tbl_outs = [
         (
             [
-                "-gen-python-enum-bindings",
+                "-gen-python-op-bindings",
                 "-bind-dialect=vector",
             ],
-            "mlir/dialects/_vector_enum_gen.py",
+            "mlir/dialects/_vector_ops_gen.py",
         ),
+    ],
+    tblgen = "//mlir:mlir-tblgen",
+    td_file = "mlir/dialects/VectorOps.td",
+    deps = [
+        "//mlir:ArithOpsTdFiles",
+        "//mlir:OpBaseTdFiles",
+        "//mlir:VectorOpsTdFiles",
+    ],
+)
+
+gentbl_filegroup(
+    name = "VectorAttributesPyGen",
+    tbl_outs = [
         (
             [
-                "-gen-python-op-bindings",
+                "-gen-python-enum-bindings",
                 "-bind-dialect=vector",
             ],
-            "mlir/dialects/_vector_ops_gen.py",
+            "mlir/dialects/_vector_enum_gen.py",
         ),
     ],
     tblgen = "//mlir:mlir-tblgen",
-    td_file = "mlir/dialects/VectorOps.td",
+    td_file = "mlir/dialects/VectorAttributes.td",
     deps = [
         "//mlir:ArithOpsTdFiles",
         "//mlir:OpBaseTdFiles",



More information about the llvm-commits mailing list