Skip to content

Commit 93b6e0a

Browse files
committed
Address reviewer comments
1 parent 838a41a commit 93b6e0a

File tree

5 files changed

+28
-31
lines changed

5 files changed

+28
-31
lines changed

mlir/lib/Bindings/Python/DialectSMT.cpp

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -26,28 +26,26 @@ using namespace mlir::python::nanobind_adaptors;
2626

2727
static void populateDialectSMTSubmodule(nanobind::module_ &m) {
2828

29-
auto smtBoolType = mlir_type_subclass(m, "BoolType", mlirSMTTypeIsABool)
30-
.def_classmethod(
31-
"get",
32-
[](const nb::object &, MlirContext context) {
33-
return mlirSMTTypeGetBool(context);
34-
},
35-
"cls"_a, "context"_a = nb::none());
29+
auto smtBoolType =
30+
mlir_type_subclass(m, "BoolType", mlirSMTTypeIsABool)
31+
.def_staticmethod(
32+
"get",
33+
[](MlirContext context) { return mlirSMTTypeGetBool(context); },
34+
"context"_a = nb::none());
3635
auto smtBitVectorType =
3736
mlir_type_subclass(m, "BitVectorType", mlirSMTTypeIsABitVector)
38-
.def_classmethod(
37+
.def_staticmethod(
3938
"get",
40-
[](const nb::object &, int32_t width, MlirContext context) {
39+
[](int32_t width, MlirContext context) {
4140
return mlirSMTTypeGetBitVector(context, width);
4241
},
43-
"cls"_a, "width"_a, "context"_a = nb::none());
44-
auto smtIntType = mlir_type_subclass(m, "IntType", mlirSMTTypeIsAInt)
45-
.def_classmethod(
46-
"get",
47-
[](const nb::object &, MlirContext context) {
48-
return mlirSMTTypeGetInt(context);
49-
},
50-
"cls"_a, "context"_a.none() = nb::none());
42+
"width"_a, "context"_a = nb::none());
43+
auto smtIntType =
44+
mlir_type_subclass(m, "IntType", mlirSMTTypeIsAInt)
45+
.def_staticmethod(
46+
"get",
47+
[](MlirContext context) { return mlirSMTTypeGetInt(context); },
48+
"context"_a = nb::none());
5149

5250
auto exportSMTLIB = [](MlirOperation module, bool inlineSingleUseValues,
5351
bool indentLetBody) {

mlir/lib/Dialect/Transform/SMTExtension/SMTExtensionOps.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ DiagnosedSilenceableFailure
2929
transform::smt::ConstrainParamsOp::apply(transform::TransformRewriter &rewriter,
3030
transform::TransformResults &results,
3131
transform::TransformState &state) {
32-
// TODO: Proper operational semantics are to chuck the SMT problem in the body
33-
// to a SMT solver with the arguments of the body constrained to the
32+
// TODO: Proper operational semantics are to check the SMT problem in the body
33+
// with a SMT solver with the arguments of the body constrained to the
3434
// values passed into the op. Success or failure is then determined by
3535
// the solver's result.
3636
// One way to support this is to just promise the TransformOpInterface

mlir/python/mlir/dialects/transform/smt.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ def __init__(
2424
loc=None,
2525
ip=None,
2626
):
27-
assert len(params) == len(arg_types)
27+
if len(params) != len(arg_types):
28+
raise ValueError(f"{params=} not same length as {arg_types=}")
2829
super().__init__(
2930
params,
3031
loc=loc,

mlir/test/Dialect/Transform/test-smt-extension-invalid.mlir

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ module attributes {transform.with_named_sequence} {
2424
// expected-error@below {{must have the same number of block arguments as operands}}
2525
transform.smt.constrain_params(%param_as_param) : !transform.param<i64> {
2626
^bb0(%param_as_smt_var: !smt.int, %param_as_another_smt_var: !smt.int):
27-
// This is the kind of thing one might think works:
28-
//arith.remsi %param_as_smt_var, %c4 : i32
2927
}
3028
transform.yield
3129
}

mlir/test/python/dialects/transform_smt_ext.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
# RUN: %PYTHON %s | FileCheck %s
22

3-
from mlir.ir import *
3+
from mlir import ir
44
from mlir.dialects import transform, smt
55
from mlir.dialects.transform import smt as transform_smt
66

77

88
def run(f):
99
print("\nTEST:", f.__name__)
10-
with Context(), Location.unknown():
11-
module = Module.create()
12-
with InsertionPoint(module.body):
10+
with ir.Context(), ir.Location.unknown():
11+
module = ir.Module.create()
12+
with ir.InsertionPoint(module.body):
1313
sequence = transform.SequenceOp(
1414
transform.FailurePropagationMode.Propagate,
1515
[],
1616
transform.AnyOpType.get(),
1717
)
18-
with InsertionPoint(sequence.body):
18+
with ir.InsertionPoint(sequence.body):
1919
f(sequence.bodyTarget)
2020
transform.YieldOp()
2121
print(module)
@@ -25,7 +25,7 @@ def run(f):
2525
# CHECK-LABEL: TEST: testConstrainParamsOp
2626
@run
2727
def testConstrainParamsOp(target):
28-
dummy_value = IntegerAttr.get(IntegerType.get_signless(32), 42)
28+
dummy_value = ir.IntegerAttr.get(ir.IntegerType.get_signless(32), 42)
2929
# CHECK: %[[PARAM_AS_PARAM:.*]] = transform.param.constant
3030
symbolic_value = transform.ParamConstantOp(
3131
transform.AnyParamType.get(), dummy_value
@@ -35,11 +35,11 @@ def testConstrainParamsOp(target):
3535
[symbolic_value], [smt.IntType.get()]
3636
)
3737
# CHECK-NEXT: ^bb{{.*}}(%[[PARAM_AS_SMT_SYMB:.*]]: !smt.int):
38-
with InsertionPoint(constrain_params.body):
38+
with ir.InsertionPoint(constrain_params.body):
3939
# CHECK: %[[C0:.*]] = smt.int.constant 0
40-
c0 = smt.IntConstantOp(IntegerAttr.get(IntegerType.get_signless(32), 0))
40+
c0 = smt.IntConstantOp(ir.IntegerAttr.get(ir.IntegerType.get_signless(32), 0))
4141
# CHECK: %[[C43:.*]] = smt.int.constant 43
42-
c43 = smt.IntConstantOp(IntegerAttr.get(IntegerType.get_signless(32), 43))
42+
c43 = smt.IntConstantOp(ir.IntegerAttr.get(ir.IntegerType.get_signless(32), 43))
4343
# CHECK: %[[LB:.*]] = smt.int.cmp le %[[C0]], %[[PARAM_AS_SMT_SYMB]]
4444
lb = smt.IntCmpOp(smt.IntPredicate.le, c0, constrain_params.body.arguments[0])
4545
# CHECK: %[[UB:.*]] = smt.int.cmp le %[[PARAM_AS_SMT_SYMB]], %[[C43]]

0 commit comments

Comments
 (0)