-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[mlir][python] UB dialect python bindings #157127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@llvm/pr-subscribers-mlir Author: Ivan Butygin (Hardcode84) ChangesFull diff: https://github.com/llvm/llvm-project/pull/157127.diff 5 Files Affected:
diff --git a/mlir/include/mlir/Dialect/UB/IR/UBOps.td b/mlir/include/mlir/Dialect/UB/IR/UBOps.td
index f3d5a26ef6f9b..c400a2ef2cc7a 100644
--- a/mlir/include/mlir/Dialect/UB/IR/UBOps.td
+++ b/mlir/include/mlir/Dialect/UB/IR/UBOps.td
@@ -12,7 +12,7 @@
include "mlir/Interfaces/SideEffectInterfaces.td"
include "mlir/IR/AttrTypeBase.td"
-include "UBOpsInterfaces.td"
+include "mlir/Dialect/UB/IR/UBOpsInterfaces.td"
def UB_Dialect : Dialect {
let name = "ub";
diff --git a/mlir/python/CMakeLists.txt b/mlir/python/CMakeLists.txt
index 7a0c95ebb8200..c983914722ce1 100644
--- a/mlir/python/CMakeLists.txt
+++ b/mlir/python/CMakeLists.txt
@@ -453,6 +453,14 @@ declare_mlir_dialect_python_bindings(
DIALECT_NAME tosa
)
+declare_mlir_dialect_python_bindings(
+ ADD_TO_PARENT MLIRPythonSources.Dialects
+ ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/mlir"
+ TD_FILE dialects/UBOps.td
+ SOURCES dialects/ub.py
+ DIALECT_NAME ub
+)
+
declare_mlir_dialect_python_bindings(
ADD_TO_PARENT MLIRPythonSources.Dialects
ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/mlir"
@@ -847,4 +855,3 @@ add_mlir_python_modules(MLIRPythonModules
COMMON_CAPI_LINK_LIBS
MLIRPythonCAPI
)
-
diff --git a/mlir/python/mlir/dialects/UBOps.td b/mlir/python/mlir/dialects/UBOps.td
new file mode 100644
index 0000000000000..b84e7f15fa78f
--- /dev/null
+++ b/mlir/python/mlir/dialects/UBOps.td
@@ -0,0 +1,14 @@
+//===-- UBOps.td - Entry point for UB 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_UB_OPS
+#define PYTHON_BINDINGS_UB_OPS
+
+include "mlir/Dialect/UB/IR/UBOps.td"
+
+#endif // PYTHON_BINDINGS_UB_OPS
diff --git a/mlir/python/mlir/dialects/ub.py b/mlir/python/mlir/dialects/ub.py
new file mode 100644
index 0000000000000..32e8706745302
--- /dev/null
+++ b/mlir/python/mlir/dialects/ub.py
@@ -0,0 +1,5 @@
+# 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
+
+from ._ub_ops_gen import *
diff --git a/mlir/test/python/dialects/ub.py b/mlir/test/python/dialects/ub.py
new file mode 100644
index 0000000000000..0d88da82c5e7b
--- /dev/null
+++ b/mlir/test/python/dialects/ub.py
@@ -0,0 +1,27 @@
+# RUN: %PYTHON %s | FileCheck %s
+# This is just a smoke test that the dialect is functional.
+from array import array
+
+from mlir.ir import *
+from mlir.dialects import ub
+from mlir.extras import types as T
+
+
+def constructAndPrintInModule(f):
+ print("\nTEST:", f.__name__)
+ with Context(), Location.unknown():
+ module = Module.create()
+ with InsertionPoint(module.body):
+ f()
+ print(module)
+ return f
+
+
+# CHECK-LABEL: testSmoke
+@constructAndPrintInModule
+def testSmoke():
+ # CHECK: Value(%{{.*}} = ub.poison : f32
+ f32 = F32Type.get()
+ poison = ub.poison(f32)
+ print(poison)
+ assert isinstance(poison, Value)
|
@llvm/pr-subscribers-mlir-ub Author: Ivan Butygin (Hardcode84) ChangesFull diff: https://github.com/llvm/llvm-project/pull/157127.diff 5 Files Affected:
diff --git a/mlir/include/mlir/Dialect/UB/IR/UBOps.td b/mlir/include/mlir/Dialect/UB/IR/UBOps.td
index f3d5a26ef6f9b..c400a2ef2cc7a 100644
--- a/mlir/include/mlir/Dialect/UB/IR/UBOps.td
+++ b/mlir/include/mlir/Dialect/UB/IR/UBOps.td
@@ -12,7 +12,7 @@
include "mlir/Interfaces/SideEffectInterfaces.td"
include "mlir/IR/AttrTypeBase.td"
-include "UBOpsInterfaces.td"
+include "mlir/Dialect/UB/IR/UBOpsInterfaces.td"
def UB_Dialect : Dialect {
let name = "ub";
diff --git a/mlir/python/CMakeLists.txt b/mlir/python/CMakeLists.txt
index 7a0c95ebb8200..c983914722ce1 100644
--- a/mlir/python/CMakeLists.txt
+++ b/mlir/python/CMakeLists.txt
@@ -453,6 +453,14 @@ declare_mlir_dialect_python_bindings(
DIALECT_NAME tosa
)
+declare_mlir_dialect_python_bindings(
+ ADD_TO_PARENT MLIRPythonSources.Dialects
+ ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/mlir"
+ TD_FILE dialects/UBOps.td
+ SOURCES dialects/ub.py
+ DIALECT_NAME ub
+)
+
declare_mlir_dialect_python_bindings(
ADD_TO_PARENT MLIRPythonSources.Dialects
ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/mlir"
@@ -847,4 +855,3 @@ add_mlir_python_modules(MLIRPythonModules
COMMON_CAPI_LINK_LIBS
MLIRPythonCAPI
)
-
diff --git a/mlir/python/mlir/dialects/UBOps.td b/mlir/python/mlir/dialects/UBOps.td
new file mode 100644
index 0000000000000..b84e7f15fa78f
--- /dev/null
+++ b/mlir/python/mlir/dialects/UBOps.td
@@ -0,0 +1,14 @@
+//===-- UBOps.td - Entry point for UB 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_UB_OPS
+#define PYTHON_BINDINGS_UB_OPS
+
+include "mlir/Dialect/UB/IR/UBOps.td"
+
+#endif // PYTHON_BINDINGS_UB_OPS
diff --git a/mlir/python/mlir/dialects/ub.py b/mlir/python/mlir/dialects/ub.py
new file mode 100644
index 0000000000000..32e8706745302
--- /dev/null
+++ b/mlir/python/mlir/dialects/ub.py
@@ -0,0 +1,5 @@
+# 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
+
+from ._ub_ops_gen import *
diff --git a/mlir/test/python/dialects/ub.py b/mlir/test/python/dialects/ub.py
new file mode 100644
index 0000000000000..0d88da82c5e7b
--- /dev/null
+++ b/mlir/test/python/dialects/ub.py
@@ -0,0 +1,27 @@
+# RUN: %PYTHON %s | FileCheck %s
+# This is just a smoke test that the dialect is functional.
+from array import array
+
+from mlir.ir import *
+from mlir.dialects import ub
+from mlir.extras import types as T
+
+
+def constructAndPrintInModule(f):
+ print("\nTEST:", f.__name__)
+ with Context(), Location.unknown():
+ module = Module.create()
+ with InsertionPoint(module.body):
+ f()
+ print(module)
+ return f
+
+
+# CHECK-LABEL: testSmoke
+@constructAndPrintInModule
+def testSmoke():
+ # CHECK: Value(%{{.*}} = ub.poison : f32
+ f32 = F32Type.get()
+ poison = ub.poison(f32)
+ print(poison)
+ assert isinstance(poison, Value)
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
No description provided.