Skip to content

Commit 3ba88a0

Browse files
committed
[mlir][SMT] add python bindings
1 parent b07fc0f commit 3ba88a0

File tree

4 files changed

+44
-0
lines changed

4 files changed

+44
-0
lines changed

mlir/python/CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,15 @@ declare_mlir_dialect_python_bindings(
403403
"../../include/mlir/Dialect/SparseTensor/IR/SparseTensorAttrDefs.td"
404404
)
405405

406+
declare_mlir_dialect_python_bindings(
407+
ADD_TO_PARENT MLIRPythonSources.Dialects
408+
ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/mlir"
409+
TD_FILE dialects/SMTOps.td
410+
GEN_ENUM_BINDINGS
411+
SOURCES
412+
dialects/smt.py
413+
DIALECT_NAME smt)
414+
406415
declare_mlir_dialect_python_bindings(
407416
ADD_TO_PARENT MLIRPythonSources.Dialects
408417
ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/mlir"

mlir/python/mlir/dialects/SMTOps.td

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
//===- SMTOps.td - Entry point for SMT bindings ------------*- tablegen -*-===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#ifndef BINDINGS_PYTHON_SMT_OPS
10+
#define BINDINGS_PYTHON_SMT_OPS
11+
12+
include "mlir/Dialect/SMT/IR/SMT.td"
13+
14+
#endif // BINDINGS_PYTHON_SMT_OPS

mlir/python/mlir/dialects/smt.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
2+
# See https://llvm.org/LICENSE.txt for license information.
3+
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4+
5+
from ._smt_ops_gen import *

mlir/test/python/dialects/smt.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# REQUIRES: bindings_python
2+
# RUN: %PYTHON% %s | FileCheck %s
3+
4+
import mlir
5+
6+
from mlir.dialects import smt
7+
from mlir.ir import Context, Location, Module, InsertionPoint
8+
9+
with Context() as ctx, Location.unknown():
10+
m = Module.create()
11+
with InsertionPoint(m.body):
12+
true = smt.constant(True)
13+
false = smt.constant(False)
14+
# CHECK: smt.constant true
15+
# CHECK: smt.constant false
16+
print(m)

0 commit comments

Comments
 (0)