[Mlir-commits] [mlir] [MLIR][Python] remove unnecessary `arg.none() = nb::none()` pattern (PR #157519)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Mon Sep 8 10:38:24 PDT 2025
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff origin/main HEAD --extensions cpp -- mlir/lib/Bindings/Python/DialectGPU.cpp mlir/lib/Bindings/Python/DialectLLVM.cpp mlir/lib/Bindings/Python/DialectNVGPU.cpp mlir/lib/Bindings/Python/DialectPDL.cpp mlir/lib/Bindings/Python/DialectSMT.cpp mlir/lib/Bindings/Python/DialectSparseTensor.cpp mlir/lib/Bindings/Python/DialectTransform.cpp mlir/lib/Bindings/Python/IRAffine.cpp mlir/lib/Bindings/Python/IRAttributes.cpp mlir/lib/Bindings/Python/IRCore.cpp mlir/lib/Bindings/Python/IRInterfaces.cpp mlir/lib/Bindings/Python/IRTypes.cpp mlir/lib/Bindings/Python/Pass.cpp
``````````
:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/mlir/lib/Bindings/Python/DialectLLVM.cpp b/mlir/lib/Bindings/Python/DialectLLVM.cpp
index f7cdefee1..55b933127 100644
--- a/mlir/lib/Bindings/Python/DialectLLVM.cpp
+++ b/mlir/lib/Bindings/Python/DialectLLVM.cpp
@@ -47,7 +47,7 @@ static void populateDialectLLVMSubmodule(const nanobind::module_ &m) {
return cls(type);
},
"cls"_a, "elements"_a, nb::kw_only(), "packed"_a = false,
- "loc"_a= nb::none());
+ "loc"_a = nb::none());
llvmStructType.def_classmethod(
"get_identified",
@@ -55,7 +55,7 @@ static void populateDialectLLVMSubmodule(const nanobind::module_ &m) {
return cls(mlirLLVMStructTypeIdentifiedGet(
context, mlirStringRefCreate(name.data(), name.size())));
},
- "cls"_a, "name"_a, nb::kw_only(), "context"_a= nb::none());
+ "cls"_a, "name"_a, nb::kw_only(), "context"_a = nb::none());
llvmStructType.def_classmethod(
"get_opaque",
@@ -63,7 +63,7 @@ static void populateDialectLLVMSubmodule(const nanobind::module_ &m) {
return cls(mlirLLVMStructTypeOpaqueGet(
context, mlirStringRefCreate(name.data(), name.size())));
},
- "cls"_a, "name"_a, "context"_a= nb::none());
+ "cls"_a, "name"_a, "context"_a = nb::none());
llvmStructType.def(
"set_body",
@@ -86,7 +86,7 @@ static void populateDialectLLVMSubmodule(const nanobind::module_ &m) {
elements.size(), elements.data(), packed));
},
"cls"_a, "name"_a, "elements"_a, nb::kw_only(), "packed"_a = false,
- "context"_a= nb::none());
+ "context"_a = nb::none());
llvmStructType.def_property_readonly(
"name", [](MlirType type) -> std::optional<std::string> {
@@ -133,8 +133,8 @@ static void populateDialectLLVMSubmodule(const nanobind::module_ &m) {
}
return cls(type);
},
- "cls"_a, "address_space"_a= nb::none(), nb::kw_only(),
- "context"_a= nb::none())
+ "cls"_a, "address_space"_a = nb::none(), nb::kw_only(),
+ "context"_a = nb::none())
.def_property_readonly("address_space", [](MlirType type) {
return mlirLLVMPointerTypeGetAddressSpace(type);
});
diff --git a/mlir/lib/Bindings/Python/DialectNVGPU.cpp b/mlir/lib/Bindings/Python/DialectNVGPU.cpp
index a113029f4..189174164 100644
--- a/mlir/lib/Bindings/Python/DialectNVGPU.cpp
+++ b/mlir/lib/Bindings/Python/DialectNVGPU.cpp
@@ -31,7 +31,7 @@ static void populateDialectNVGPUSubmodule(const nb::module_ &m) {
"Gets an instance of TensorMapDescriptorType in the same context",
nb::arg("cls"), nb::arg("tensor_type"), nb::arg("swizzle"),
nb::arg("l2promo"), nb::arg("oob_fill"), nb::arg("interleave"),
- nb::arg("ctx")= nb::none());
+ nb::arg("ctx") = nb::none());
}
NB_MODULE(_mlirDialectsNVGPU, m) {
diff --git a/mlir/lib/Bindings/Python/DialectPDL.cpp b/mlir/lib/Bindings/Python/DialectPDL.cpp
index 535e33393..ac163b59a 100644
--- a/mlir/lib/Bindings/Python/DialectPDL.cpp
+++ b/mlir/lib/Bindings/Python/DialectPDL.cpp
@@ -36,7 +36,7 @@ static void populateDialectPDLSubmodule(const nanobind::module_ &m) {
return cls(mlirPDLAttributeTypeGet(ctx));
},
"Get an instance of AttributeType in given context.", nb::arg("cls"),
- nb::arg("context")= nb::none());
+ nb::arg("context") = nb::none());
//===-------------------------------------------------------------------===//
// OperationType
@@ -50,7 +50,7 @@ static void populateDialectPDLSubmodule(const nanobind::module_ &m) {
return cls(mlirPDLOperationTypeGet(ctx));
},
"Get an instance of OperationType in given context.", nb::arg("cls"),
- nb::arg("context")= nb::none());
+ nb::arg("context") = nb::none());
//===-------------------------------------------------------------------===//
// RangeType
@@ -81,7 +81,7 @@ static void populateDialectPDLSubmodule(const nanobind::module_ &m) {
return cls(mlirPDLTypeTypeGet(ctx));
},
"Get an instance of TypeType in given context.", nb::arg("cls"),
- nb::arg("context")= nb::none());
+ nb::arg("context") = nb::none());
//===-------------------------------------------------------------------===//
// ValueType
@@ -94,7 +94,7 @@ static void populateDialectPDLSubmodule(const nanobind::module_ &m) {
return cls(mlirPDLValueTypeGet(ctx));
},
"Get an instance of TypeType in given context.", nb::arg("cls"),
- nb::arg("context")= nb::none());
+ nb::arg("context") = nb::none());
}
NB_MODULE(_mlirDialectsPDL, m) {
diff --git a/mlir/lib/Bindings/Python/DialectSMT.cpp b/mlir/lib/Bindings/Python/DialectSMT.cpp
index 9c454d6a9..3123e3bdd 100644
--- a/mlir/lib/Bindings/Python/DialectSMT.cpp
+++ b/mlir/lib/Bindings/Python/DialectSMT.cpp
@@ -32,7 +32,7 @@ static void populateDialectSMTSubmodule(nanobind::module_ &m) {
[](const nb::object &, MlirContext context) {
return mlirSMTTypeGetBool(context);
},
- "cls"_a, "context"_a= nb::none());
+ "cls"_a, "context"_a = nb::none());
auto smtBitVectorType =
mlir_type_subclass(m, "BitVectorType", mlirSMTTypeIsABitVector)
.def_classmethod(
@@ -40,7 +40,7 @@ static void populateDialectSMTSubmodule(nanobind::module_ &m) {
[](const nb::object &, int32_t width, MlirContext context) {
return mlirSMTTypeGetBitVector(context, width);
},
- "cls"_a, "width"_a, "context"_a= nb::none());
+ "cls"_a, "width"_a, "context"_a = nb::none());
auto exportSMTLIB = [](MlirOperation module, bool inlineSingleUseValues,
bool indentLetBody) {
diff --git a/mlir/lib/Bindings/Python/DialectSparseTensor.cpp b/mlir/lib/Bindings/Python/DialectSparseTensor.cpp
index facbbf3f0..00b65ee97 100644
--- a/mlir/lib/Bindings/Python/DialectSparseTensor.cpp
+++ b/mlir/lib/Bindings/Python/DialectSparseTensor.cpp
@@ -53,9 +53,8 @@ static void populateDialectSparseTensorSubmodule(const nb::module_ &m) {
},
nb::arg("cls"), nb::arg("lvl_types"), nb::arg("dim_to_lvl").none(),
nb::arg("lvl_to_dim").none(), nb::arg("pos_width"),
- nb::arg("crd_width"), nb::arg("explicit_val")= nb::none(),
- nb::arg("implicit_val")= nb::none(),
- nb::arg("context")= nb::none(),
+ nb::arg("crd_width"), nb::arg("explicit_val") = nb::none(),
+ nb::arg("implicit_val") = nb::none(), nb::arg("context") = nb::none(),
"Gets a sparse_tensor.encoding from parameters.")
.def_classmethod(
"build_level_type",
diff --git a/mlir/lib/Bindings/Python/DialectTransform.cpp b/mlir/lib/Bindings/Python/DialectTransform.cpp
index ded7b4b94..150c69953 100644
--- a/mlir/lib/Bindings/Python/DialectTransform.cpp
+++ b/mlir/lib/Bindings/Python/DialectTransform.cpp
@@ -33,7 +33,7 @@ static void populateDialectTransformSubmodule(const nb::module_ &m) {
return cls(mlirTransformAnyOpTypeGet(ctx));
},
"Get an instance of AnyOpType in the given context.", nb::arg("cls"),
- nb::arg("context")= nb::none());
+ nb::arg("context") = nb::none());
//===-------------------------------------------------------------------===//
// AnyParamType
@@ -48,7 +48,7 @@ static void populateDialectTransformSubmodule(const nb::module_ &m) {
return cls(mlirTransformAnyParamTypeGet(ctx));
},
"Get an instance of AnyParamType in the given context.", nb::arg("cls"),
- nb::arg("context")= nb::none());
+ nb::arg("context") = nb::none());
//===-------------------------------------------------------------------===//
// AnyValueType
@@ -63,7 +63,7 @@ static void populateDialectTransformSubmodule(const nb::module_ &m) {
return cls(mlirTransformAnyValueTypeGet(ctx));
},
"Get an instance of AnyValueType in the given context.", nb::arg("cls"),
- nb::arg("context")= nb::none());
+ nb::arg("context") = nb::none());
//===-------------------------------------------------------------------===//
// OperationType
@@ -83,7 +83,7 @@ static void populateDialectTransformSubmodule(const nb::module_ &m) {
"Get an instance of OperationType for the given kind in the given "
"context",
nb::arg("cls"), nb::arg("operation_name"),
- nb::arg("context")= nb::none());
+ nb::arg("context") = nb::none());
operationType.def_property_readonly(
"operation_name",
[](MlirType type) {
@@ -106,7 +106,7 @@ static void populateDialectTransformSubmodule(const nb::module_ &m) {
return cls(mlirTransformParamTypeGet(ctx, type));
},
"Get an instance of ParamType for the given type in the given context.",
- nb::arg("cls"), nb::arg("type"), nb::arg("context")= nb::none());
+ nb::arg("cls"), nb::arg("type"), nb::arg("context") = nb::none());
paramType.def_property_readonly(
"type",
[](MlirType type) {
diff --git a/mlir/lib/Bindings/Python/IRAffine.cpp b/mlir/lib/Bindings/Python/IRAffine.cpp
index bc840deb9..bc6aa0dac 100644
--- a/mlir/lib/Bindings/Python/IRAffine.cpp
+++ b/mlir/lib/Bindings/Python/IRAffine.cpp
@@ -142,7 +142,7 @@ public:
static void bindDerived(ClassTy &c) {
c.def_static("get", &PyAffineConstantExpr::get, nb::arg("value"),
- nb::arg("context")= nb::none());
+ nb::arg("context") = nb::none());
c.def_prop_ro("value", [](PyAffineConstantExpr &self) {
return mlirAffineConstantExprGetValue(self);
});
@@ -162,7 +162,7 @@ public:
static void bindDerived(ClassTy &c) {
c.def_static("get", &PyAffineDimExpr::get, nb::arg("position"),
- nb::arg("context")= nb::none());
+ nb::arg("context") = nb::none());
c.def_prop_ro("position", [](PyAffineDimExpr &self) {
return mlirAffineDimExprGetPosition(self);
});
@@ -182,7 +182,7 @@ public:
static void bindDerived(ClassTy &c) {
c.def_static("get", &PyAffineSymbolExpr::get, nb::arg("position"),
- nb::arg("context")= nb::none());
+ nb::arg("context") = nb::none());
c.def_prop_ro("position", [](PyAffineSymbolExpr &self) {
return mlirAffineSymbolExprGetPosition(self);
});
@@ -588,7 +588,7 @@ void mlir::python::populateIRAffine(nb::module_ &m) {
self.getContext(),
mlirAffineExprShiftDims(self, numDims, shift, offset));
},
- nb::arg("num_dims"), nb::arg("shift"), nb::arg("offset")= 0)
+ nb::arg("num_dims"), nb::arg("shift"), nb::arg("offset") = 0)
.def(
"shift_symbols",
[](PyAffineExpr &self, uint32_t numSymbols, uint32_t shift,
@@ -597,8 +597,7 @@ void mlir::python::populateIRAffine(nb::module_ &m) {
self.getContext(),
mlirAffineExprShiftSymbols(self, numSymbols, shift, offset));
},
- nb::arg("num_symbols"), nb::arg("shift"),
- nb::arg("offset")= 0)
+ nb::arg("num_symbols"), nb::arg("shift"), nb::arg("offset") = 0)
.def_static(
"simplify_affine_expr",
[](PyAffineExpr &self, uint32_t numDims, uint32_t numSymbols) {
@@ -655,15 +654,15 @@ void mlir::python::populateIRAffine(nb::module_ &m) {
"Gets an affine expression containing the rounded-up result "
"of dividing an expression by a constant.")
.def_static("get_constant", &PyAffineConstantExpr::get, nb::arg("value"),
- nb::arg("context")= nb::none(),
+ nb::arg("context") = nb::none(),
"Gets a constant affine expression with the given value.")
.def_static(
"get_dim", &PyAffineDimExpr::get, nb::arg("position"),
- nb::arg("context")= nb::none(),
+ nb::arg("context") = nb::none(),
"Gets an affine expression of a dimension at the given position.")
.def_static(
"get_symbol", &PyAffineSymbolExpr::get, nb::arg("position"),
- nb::arg("context")= nb::none(),
+ nb::arg("context") = nb::none(),
"Gets an affine expression of a symbol at the given position.")
.def(
"dump", [](PyAffineExpr &self) { mlirAffineExprDump(self); },
@@ -746,7 +745,7 @@ void mlir::python::populateIRAffine(nb::module_ &m) {
return PyAffineMap(context->getRef(), map);
},
nb::arg("dim_count"), nb::arg("symbol_count"), nb::arg("exprs"),
- nb::arg("context")= nb::none(),
+ nb::arg("context") = nb::none(),
"Gets a map with the given expressions as results.")
.def_static(
"get_constant",
@@ -755,7 +754,7 @@ void mlir::python::populateIRAffine(nb::module_ &m) {
mlirAffineMapConstantGet(context->get(), value);
return PyAffineMap(context->getRef(), affineMap);
},
- nb::arg("value"), nb::arg("context")= nb::none(),
+ nb::arg("value"), nb::arg("context") = nb::none(),
"Gets an affine map with a single constant result")
.def_static(
"get_empty",
@@ -763,7 +762,7 @@ void mlir::python::populateIRAffine(nb::module_ &m) {
MlirAffineMap affineMap = mlirAffineMapEmptyGet(context->get());
return PyAffineMap(context->getRef(), affineMap);
},
- nb::arg("context")= nb::none(), "Gets an empty affine map.")
+ nb::arg("context") = nb::none(), "Gets an empty affine map.")
.def_static(
"get_identity",
[](intptr_t nDims, DefaultingPyMlirContext context) {
@@ -771,7 +770,7 @@ void mlir::python::populateIRAffine(nb::module_ &m) {
mlirAffineMapMultiDimIdentityGet(context->get(), nDims);
return PyAffineMap(context->getRef(), affineMap);
},
- nb::arg("n_dims"), nb::arg("context")= nb::none(),
+ nb::arg("n_dims"), nb::arg("context") = nb::none(),
"Gets an identity map with the given number of dimensions.")
.def_static(
"get_minor_identity",
@@ -782,7 +781,7 @@ void mlir::python::populateIRAffine(nb::module_ &m) {
return PyAffineMap(context->getRef(), affineMap);
},
nb::arg("n_dims"), nb::arg("n_results"),
- nb::arg("context")= nb::none(),
+ nb::arg("context") = nb::none(),
"Gets a minor identity map with the given number of dimensions and "
"results.")
.def_static(
@@ -796,7 +795,7 @@ void mlir::python::populateIRAffine(nb::module_ &m) {
context->get(), permutation.size(), permutation.data());
return PyAffineMap(context->getRef(), affineMap);
},
- nb::arg("permutation"), nb::arg("context")= nb::none(),
+ nb::arg("permutation"), nb::arg("context") = nb::none(),
"Gets an affine map that permutes its inputs.")
.def(
"get_submap",
@@ -923,7 +922,7 @@ void mlir::python::populateIRAffine(nb::module_ &m) {
return PyIntegerSet(context->getRef(), set);
},
nb::arg("num_dims"), nb::arg("num_symbols"), nb::arg("exprs"),
- nb::arg("eq_flags"), nb::arg("context")= nb::none())
+ nb::arg("eq_flags"), nb::arg("context") = nb::none())
.def_static(
"get_empty",
[](intptr_t numDims, intptr_t numSymbols,
@@ -933,7 +932,7 @@ void mlir::python::populateIRAffine(nb::module_ &m) {
return PyIntegerSet(context->getRef(), set);
},
nb::arg("num_dims"), nb::arg("num_symbols"),
- nb::arg("context")= nb::none())
+ nb::arg("context") = nb::none())
.def(
"get_replaced",
[](PyIntegerSet &self, const nb::list &dimExprs,
diff --git a/mlir/lib/Bindings/Python/IRAttributes.cpp b/mlir/lib/Bindings/Python/IRAttributes.cpp
index c3df66c19..b3c768846 100644
--- a/mlir/lib/Bindings/Python/IRAttributes.cpp
+++ b/mlir/lib/Bindings/Python/IRAttributes.cpp
@@ -351,7 +351,7 @@ public:
}
return getAttribute(values, ctx->getRef());
},
- nb::arg("values"), nb::arg("context")= nb::none(),
+ nb::arg("values"), nb::arg("context") = nb::none(),
"Gets a uniqued dense array attribute");
} else {
c.def_static(
@@ -359,7 +359,7 @@ public:
[](const std::vector<EltTy> &values, DefaultingPyMlirContext ctx) {
return getAttribute(values, ctx->getRef());
},
- nb::arg("values"), nb::arg("context")= nb::none(),
+ nb::arg("values"), nb::arg("context") = nb::none(),
"Gets a uniqued dense array attribute");
}
// Bind the array methods.
@@ -515,7 +515,7 @@ public:
context->get(), mlirAttributes.size(), mlirAttributes.data());
return PyArrayAttribute(context->getRef(), attr);
},
- nb::arg("attributes"), nb::arg("context")= nb::none(),
+ nb::arg("attributes"), nb::arg("context") = nb::none(),
"Gets a uniqued Array attribute");
c.def("__getitem__",
[](PyArrayAttribute &arr, intptr_t i) {
@@ -564,7 +564,7 @@ public:
throw MLIRError("Invalid attribute", errors.take());
return PyFloatAttribute(type.getContext(), attr);
},
- nb::arg("type"), nb::arg("value"), nb::arg("loc")= nb::none(),
+ nb::arg("type"), nb::arg("value"), nb::arg("loc") = nb::none(),
"Gets an uniqued float point attribute associated to a type");
c.def_static(
"get_f32",
@@ -573,7 +573,7 @@ public:
context->get(), mlirF32TypeGet(context->get()), value);
return PyFloatAttribute(context->getRef(), attr);
},
- nb::arg("value"), nb::arg("context")= nb::none(),
+ nb::arg("value"), nb::arg("context") = nb::none(),
"Gets an uniqued float point attribute associated to a f32 type");
c.def_static(
"get_f64",
@@ -582,7 +582,7 @@ public:
context->get(), mlirF64TypeGet(context->get()), value);
return PyFloatAttribute(context->getRef(), attr);
},
- nb::arg("value"), nb::arg("context")= nb::none(),
+ nb::arg("value"), nb::arg("context") = nb::none(),
"Gets an uniqued float point attribute associated to a f64 type");
c.def_prop_ro("value", mlirFloatAttrGetValueDouble,
"Returns the value of the float attribute");
@@ -642,7 +642,7 @@ public:
MlirAttribute attr = mlirBoolAttrGet(context->get(), value);
return PyBoolAttribute(context->getRef(), attr);
},
- nb::arg("value"), nb::arg("context")= nb::none(),
+ nb::arg("value"), nb::arg("context") = nb::none(),
"Gets an uniqued bool attribute");
c.def_prop_ro("value", mlirBoolAttrGetValue,
"Returns the value of the bool attribute");
@@ -679,7 +679,7 @@ public:
DefaultingPyMlirContext context) {
return PySymbolRefAttribute::fromList(symbols, context.resolve());
},
- nb::arg("symbols"), nb::arg("context")= nb::none(),
+ nb::arg("symbols"), nb::arg("context") = nb::none(),
"Gets a uniqued SymbolRef attribute from a list of symbol names");
c.def_prop_ro(
"value",
@@ -713,7 +713,7 @@ public:
mlirFlatSymbolRefAttrGet(context->get(), toMlirStringRef(value));
return PyFlatSymbolRefAttribute(context->getRef(), attr);
},
- nb::arg("value"), nb::arg("context")= nb::none(),
+ nb::arg("value"), nb::arg("context") = nb::none(),
"Gets a uniqued FlatSymbolRef attribute");
c.def_prop_ro(
"value",
@@ -746,7 +746,7 @@ public:
return PyOpaqueAttribute(context->getRef(), attr);
},
nb::arg("dialect_namespace"), nb::arg("buffer"), nb::arg("type"),
- nb::arg("context")= nb::none(), "Gets an Opaque attribute.");
+ nb::arg("context") = nb::none(), "Gets an Opaque attribute.");
c.def_prop_ro(
"dialect_namespace",
[](PyOpaqueAttribute &self) {
@@ -780,7 +780,7 @@ public:
mlirStringAttrGet(context->get(), toMlirStringRef(value));
return PyStringAttribute(context->getRef(), attr);
},
- nb::arg("value"), nb::arg("context")= nb::none(),
+ nb::arg("value"), nb::arg("context") = nb::none(),
"Gets a uniqued string attribute");
c.def_static(
"get",
@@ -789,7 +789,7 @@ public:
mlirStringAttrGet(context->get(), toMlirStringRef(value));
return PyStringAttribute(context->getRef(), attr);
},
- nb::arg("value"), nb::arg("context")= nb::none(),
+ nb::arg("value"), nb::arg("context") = nb::none(),
"Gets a uniqued string attribute");
c.def_static(
"get_typed",
@@ -1030,13 +1030,12 @@ public:
c.def("__len__", &PyDenseElementsAttribute::dunderLen)
.def_static("get", PyDenseElementsAttribute::getFromBuffer,
nb::arg("array"), nb::arg("signless") = true,
- nb::arg("type")= nb::none(),
- nb::arg("shape")= nb::none(),
- nb::arg("context")= nb::none(),
+ nb::arg("type") = nb::none(), nb::arg("shape") = nb::none(),
+ nb::arg("context") = nb::none(),
kDenseElementsAttrGetDocstring)
.def_static("get", PyDenseElementsAttribute::getFromList,
- nb::arg("attrs"), nb::arg("type")= nb::none(),
- nb::arg("context")= nb::none(),
+ nb::arg("attrs"), nb::arg("type") = nb::none(),
+ nb::arg("context") = nb::none(),
kDenseElementsAttrGetFromListDocstring)
.def_static("get_splat", PyDenseElementsAttribute::getSplat,
nb::arg("shaped_type"), nb::arg("element_attr"),
@@ -1505,12 +1504,12 @@ public:
}
static void bindDerived(ClassTy &c) {
- c.def_static(
- "get_from_buffer", PyDenseResourceElementsAttribute::getFromBuffer,
- nb::arg("array"), nb::arg("name"), nb::arg("type"),
- nb::arg("alignment")= nb::none(), nb::arg("is_mutable") = false,
- nb::arg("context")= nb::none(),
- kDenseResourceElementsAttrGetFromBufferDocstring);
+ c.def_static("get_from_buffer",
+ PyDenseResourceElementsAttribute::getFromBuffer,
+ nb::arg("array"), nb::arg("name"), nb::arg("type"),
+ nb::arg("alignment") = nb::none(),
+ nb::arg("is_mutable") = false, nb::arg("context") = nb::none(),
+ kDenseResourceElementsAttrGetFromBufferDocstring);
}
};
@@ -1550,7 +1549,7 @@ public:
mlirNamedAttributes.data());
return PyDictAttribute(context->getRef(), attr);
},
- nb::arg("value") = nb::dict(), nb::arg("context")= nb::none(),
+ nb::arg("value") = nb::dict(), nb::arg("context") = nb::none(),
"Gets an uniqued dict attribute");
c.def("__getitem__", [](PyDictAttribute &self, const std::string &name) {
MlirAttribute attr =
@@ -1622,7 +1621,7 @@ public:
MlirAttribute attr = mlirTypeAttrGet(value.get());
return PyTypeAttribute(context->getRef(), attr);
},
- nb::arg("value"), nb::arg("context")= nb::none(),
+ nb::arg("value"), nb::arg("context") = nb::none(),
"Gets a uniqued Type attribute");
c.def_prop_ro("value", [](PyTypeAttribute &self) {
return mlirTypeAttrGetValue(self.get());
@@ -1646,7 +1645,7 @@ public:
return PyUnitAttribute(context->getRef(),
mlirUnitAttrGet(context->get()));
},
- nb::arg("context")= nb::none(), "Create a Unit attribute.");
+ nb::arg("context") = nb::none(), "Create a Unit attribute.");
}
};
@@ -1669,8 +1668,7 @@ public:
ctx->get(), offset, strides.size(), strides.data());
return PyStridedLayoutAttribute(ctx->getRef(), attr);
},
- nb::arg("offset"), nb::arg("strides"),
- nb::arg("context")= nb::none(),
+ nb::arg("offset"), nb::arg("strides"), nb::arg("context") = nb::none(),
"Gets a strided layout attribute.");
c.def_static(
"get_fully_dynamic",
@@ -1682,7 +1680,7 @@ public:
ctx->get(), dynamic, strides.size(), strides.data());
return PyStridedLayoutAttribute(ctx->getRef(), attr);
},
- nb::arg("rank"), nb::arg("context")= nb::none(),
+ nb::arg("rank"), nb::arg("context") = nb::none(),
"Gets a strided layout attribute with dynamic offset and strides of "
"a "
"given rank.");
diff --git a/mlir/lib/Bindings/Python/IRCore.cpp b/mlir/lib/Bindings/Python/IRCore.cpp
index 16fa7ed51..8273a9346 100644
--- a/mlir/lib/Bindings/Python/IRCore.cpp
+++ b/mlir/lib/Bindings/Python/IRCore.cpp
@@ -3104,7 +3104,7 @@ void mlir::python::populateIRCore(nb::module_ &m) {
return PyLocation(context->getRef(),
mlirLocationUnknownGet(context->get()));
},
- nb::arg("context")= nb::none(),
+ nb::arg("context") = nb::none(),
"Gets a Location representing an unknown location")
.def_static(
"callsite",
@@ -3119,8 +3119,7 @@ void mlir::python::populateIRCore(nb::module_ &m) {
return PyLocation(context->getRef(),
mlirLocationCallSiteGet(callee.get(), caller));
},
- nb::arg("callee"), nb::arg("frames"),
- nb::arg("context")= nb::none(),
+ nb::arg("callee"), nb::arg("frames"), nb::arg("context") = nb::none(),
kContextGetCallSiteLocationDocstring)
.def("is_a_callsite", mlirLocationIsACallSite)
.def_prop_ro("callee", mlirLocationCallSiteGetCallee)
@@ -3135,8 +3134,7 @@ void mlir::python::populateIRCore(nb::module_ &m) {
context->get(), toMlirStringRef(filename), line, col));
},
nb::arg("filename"), nb::arg("line"), nb::arg("col"),
- nb::arg("context")= nb::none(),
- kContextGetFileLocationDocstring)
+ nb::arg("context") = nb::none(), kContextGetFileLocationDocstring)
.def_static(
"file",
[](std::string filename, int startLine, int startCol, int endLine,
@@ -3148,7 +3146,7 @@ void mlir::python::populateIRCore(nb::module_ &m) {
},
nb::arg("filename"), nb::arg("start_line"), nb::arg("start_col"),
nb::arg("end_line"), nb::arg("end_col"),
- nb::arg("context")= nb::none(), kContextGetFileRangeDocstring)
+ nb::arg("context") = nb::none(), kContextGetFileRangeDocstring)
.def("is_a_file", mlirLocationIsAFileLineColRange)
.def_prop_ro("filename",
[](MlirLocation loc) {
@@ -3173,9 +3171,8 @@ void mlir::python::populateIRCore(nb::module_ &m) {
metadata ? metadata->get() : MlirAttribute{0});
return PyLocation(context->getRef(), location);
},
- nb::arg("locations"), nb::arg("metadata")= nb::none(),
- nb::arg("context")= nb::none(),
- kContextGetFusedLocationDocstring)
+ nb::arg("locations"), nb::arg("metadata") = nb::none(),
+ nb::arg("context") = nb::none(), kContextGetFusedLocationDocstring)
.def("is_a_fused", mlirLocationIsAFused)
.def_prop_ro("locations",
[](MlirLocation loc) {
@@ -3197,9 +3194,8 @@ void mlir::python::populateIRCore(nb::module_ &m) {
childLoc ? childLoc->get()
: mlirLocationUnknownGet(context->get())));
},
- nb::arg("name"), nb::arg("childLoc")= nb::none(),
- nb::arg("context")= nb::none(),
- kContextGetNameLocationDocString)
+ nb::arg("name"), nb::arg("childLoc") = nb::none(),
+ nb::arg("context") = nb::none(), kContextGetNameLocationDocString)
.def("is_a_name", mlirLocationIsAName)
.def_prop_ro("name_str",
[](MlirLocation loc) {
@@ -3212,7 +3208,7 @@ void mlir::python::populateIRCore(nb::module_ &m) {
return PyLocation(context->getRef(),
mlirLocationFromAttribute(attribute));
},
- nb::arg("attribute"), nb::arg("context")= nb::none(),
+ nb::arg("attribute"), nb::arg("context") = nb::none(),
"Gets a Location from a LocationAttr")
.def_prop_ro(
"context",
@@ -3253,7 +3249,7 @@ void mlir::python::populateIRCore(nb::module_ &m) {
throw MLIRError("Unable to parse module assembly", errors.take());
return PyModule::forModule(module).releaseObject();
},
- nb::arg("asm"), nb::arg("context")= nb::none(),
+ nb::arg("asm"), nb::arg("context") = nb::none(),
kModuleParseDocstring)
.def_static(
"parse",
@@ -3265,7 +3261,7 @@ void mlir::python::populateIRCore(nb::module_ &m) {
throw MLIRError("Unable to parse module assembly", errors.take());
return PyModule::forModule(module).releaseObject();
},
- nb::arg("asm"), nb::arg("context")= nb::none(),
+ nb::arg("asm"), nb::arg("context") = nb::none(),
kModuleParseDocstring)
.def_static(
"parseFile",
@@ -3277,7 +3273,7 @@ void mlir::python::populateIRCore(nb::module_ &m) {
throw MLIRError("Unable to parse module assembly", errors.take());
return PyModule::forModule(module).releaseObject();
},
- nb::arg("path"), nb::arg("context")= nb::none(),
+ nb::arg("path"), nb::arg("context") = nb::none(),
kModuleParseDocstring)
.def_static(
"create",
@@ -3286,7 +3282,7 @@ void mlir::python::populateIRCore(nb::module_ &m) {
MlirModule module = mlirModuleCreateEmpty(pyLoc.get());
return PyModule::forModule(module).releaseObject();
},
- nb::arg("loc")= nb::none(), "Creates an empty module")
+ nb::arg("loc") = nb::none(), "Creates an empty module")
.def_prop_ro(
"context",
[](PyModule &self) { return self.getContext().getObject(); },
@@ -3427,31 +3423,31 @@ void mlir::python::populateIRCore(nb::module_ &m) {
.def("print",
nb::overload_cast<PyAsmState &, nb::object, bool>(
&PyOperationBase::print),
- nb::arg("state"), nb::arg("file")= nb::none(),
+ nb::arg("state"), nb::arg("file") = nb::none(),
nb::arg("binary") = false, kOperationPrintStateDocstring)
.def("print",
nb::overload_cast<std::optional<int64_t>, std::optional<int64_t>,
bool, bool, bool, bool, bool, bool, nb::object,
bool, bool>(&PyOperationBase::print),
// Careful: Lots of arguments must match up with print method.
- nb::arg("large_elements_limit")= nb::none(),
- nb::arg("large_resource_limit")= nb::none(),
+ nb::arg("large_elements_limit") = nb::none(),
+ nb::arg("large_resource_limit") = nb::none(),
nb::arg("enable_debug_info") = false,
nb::arg("pretty_debug_info") = false,
nb::arg("print_generic_op_form") = false,
nb::arg("use_local_scope") = false,
nb::arg("use_name_loc_as_prefix") = false,
- nb::arg("assume_verified") = false,
- nb::arg("file")= nb::none(), nb::arg("binary") = false,
- nb::arg("skip_regions") = false, kOperationPrintDocstring)
+ nb::arg("assume_verified") = false, nb::arg("file") = nb::none(),
+ nb::arg("binary") = false, nb::arg("skip_regions") = false,
+ kOperationPrintDocstring)
.def("write_bytecode", &PyOperationBase::writeBytecode, nb::arg("file"),
- nb::arg("desired_version")= nb::none(),
+ nb::arg("desired_version") = nb::none(),
kOperationPrintBytecodeDocstring)
.def("get_asm", &PyOperationBase::getAsm,
// Careful: Lots of arguments must match up with get_asm method.
nb::arg("binary") = false,
- nb::arg("large_elements_limit")= nb::none(),
- nb::arg("large_resource_limit")= nb::none(),
+ nb::arg("large_elements_limit") = nb::none(),
+ nb::arg("large_resource_limit") = nb::none(),
nb::arg("enable_debug_info") = false,
nb::arg("pretty_debug_info") = false,
nb::arg("print_generic_op_form") = false,
@@ -3480,7 +3476,7 @@ void mlir::python::populateIRCore(nb::module_ &m) {
[](PyOperationBase &self, nb::object ip) {
return self.getOperation().clone(ip);
},
- nb::arg("ip")= nb::none())
+ nb::arg("ip") = nb::none())
.def(
"detach_from_parent",
[](PyOperationBase &self) {
@@ -3531,11 +3527,10 @@ void mlir::python::populateIRCore(nb::module_ &m) {
successors, regions, pyLoc, maybeIp,
inferType);
},
- nb::arg("name"), nb::arg("results")= nb::none(),
- nb::arg("operands")= nb::none(),
- nb::arg("attributes")= nb::none(),
- nb::arg("successors")= nb::none(), nb::arg("regions") = 0,
- nb::arg("loc")= nb::none(), nb::arg("ip")= nb::none(),
+ nb::arg("name"), nb::arg("results") = nb::none(),
+ nb::arg("operands") = nb::none(), nb::arg("attributes") = nb::none(),
+ nb::arg("successors") = nb::none(), nb::arg("regions") = 0,
+ nb::arg("loc") = nb::none(), nb::arg("ip") = nb::none(),
nb::arg("infer_type") = false, kOperationCreateDocstring)
.def_static(
"parse",
@@ -3545,7 +3540,7 @@ void mlir::python::populateIRCore(nb::module_ &m) {
->createOpView();
},
nb::arg("source"), nb::kw_only(), nb::arg("source_name") = "",
- nb::arg("context")= nb::none(),
+ nb::arg("context") = nb::none(),
"Parses an operation. Supports both text assembly format and binary "
"bytecode format.")
.def_prop_ro(MLIR_PYTHON_CAPI_PTR_ATTR, &PyOperation::getCapsule)
@@ -3584,15 +3579,13 @@ void mlir::python::populateIRCore(nb::module_ &m) {
attributes, successors, regions, pyLoc, maybeIp));
},
nb::arg("name"), nb::arg("opRegionSpec"),
- nb::arg("operandSegmentSpecObj")= nb::none(),
- nb::arg("resultSegmentSpecObj")= nb::none(),
- nb::arg("results")= nb::none(),
- nb::arg("operands")= nb::none(),
- nb::arg("attributes")= nb::none(),
- nb::arg("successors")= nb::none(),
- nb::arg("regions")= nb::none(),
- nb::arg("loc")= nb::none(),
- nb::arg("ip")= nb::none())
+ nb::arg("operandSegmentSpecObj") = nb::none(),
+ nb::arg("resultSegmentSpecObj") = nb::none(),
+ nb::arg("results") = nb::none(), nb::arg("operands") = nb::none(),
+ nb::arg("attributes") = nb::none(),
+ nb::arg("successors") = nb::none(),
+ nb::arg("regions") = nb::none(), nb::arg("loc") = nb::none(),
+ nb::arg("ip") = nb::none())
.def_prop_ro("operation", &PyOpView::getOperationObject)
.def_prop_ro("opview", [](nb::object self) { return self; })
@@ -3632,12 +3625,10 @@ void mlir::python::populateIRCore(nb::module_ &m) {
operandList, attributes, successors,
regions, pyLoc, maybeIp);
},
- nb::arg("cls"), nb::arg("results")= nb::none(),
- nb::arg("operands")= nb::none(),
- nb::arg("attributes")= nb::none(),
- nb::arg("successors")= nb::none(),
- nb::arg("regions")= nb::none(),
- nb::arg("loc")= nb::none(), nb::arg("ip")= nb::none(),
+ nb::arg("cls"), nb::arg("results") = nb::none(),
+ nb::arg("operands") = nb::none(), nb::arg("attributes") = nb::none(),
+ nb::arg("successors") = nb::none(), nb::arg("regions") = nb::none(),
+ nb::arg("loc") = nb::none(), nb::arg("ip") = nb::none(),
"Builds a specific, generated OpView based on class level attributes.");
opViewClass.attr("parse") = classmethod(
[](const nb::object &cls, const std::string &sourceStr,
@@ -3661,7 +3652,7 @@ void mlir::python::populateIRCore(nb::module_ &m) {
return PyOpView::constructDerived(cls, parsed.getObject());
},
nb::arg("cls"), nb::arg("source"), nb::kw_only(),
- nb::arg("source_name") = "", nb::arg("context")= nb::none(),
+ nb::arg("source_name") = "", nb::arg("context") = nb::none(),
"Parses a specific, generated OpView based on class level attributes");
//----------------------------------------------------------------------------
@@ -3911,7 +3902,7 @@ void mlir::python::populateIRCore(nb::module_ &m) {
throw MLIRError("Unable to parse attribute", errors.take());
return attr;
},
- nb::arg("asm"), nb::arg("context")= nb::none(),
+ nb::arg("asm"), nb::arg("context") = nb::none(),
"Parses an attribute from an assembly form. Raises an MLIRError on "
"failure.")
.def_prop_ro(
@@ -4028,7 +4019,7 @@ void mlir::python::populateIRCore(nb::module_ &m) {
throw MLIRError("Unable to parse type", errors.take());
return type;
},
- nb::arg("asm"), nb::arg("context")= nb::none(),
+ nb::arg("asm"), nb::arg("context") = nb::none(),
kContextParseTypeDocstring)
.def_prop_ro(
"context", [](PyType &self) { return self.getContext().getObject(); },
diff --git a/mlir/lib/Bindings/Python/IRInterfaces.cpp b/mlir/lib/Bindings/Python/IRInterfaces.cpp
index baf885d99..6aa057c2a 100644
--- a/mlir/lib/Bindings/Python/IRInterfaces.cpp
+++ b/mlir/lib/Bindings/Python/IRInterfaces.cpp
@@ -195,7 +195,7 @@ public:
static void bind(nb::module_ &m) {
nb::class_<ConcreteIface> cls(m, ConcreteIface::pyClassName);
cls.def(nb::init<nb::object, DefaultingPyMlirContext>(), nb::arg("object"),
- nb::arg("context")= nb::none(), constructorDoc)
+ nb::arg("context") = nb::none(), constructorDoc)
.def_prop_ro("operation", &PyConcreteOpInterface::getOperationObject,
operationDoc)
.def_prop_ro("opview", &PyConcreteOpInterface::getOpView, opviewDoc);
@@ -303,12 +303,11 @@ public:
static void bindDerived(ClassTy &cls) {
cls.def("inferReturnTypes", &PyInferTypeOpInterface::inferReturnTypes,
- nb::arg("operands")= nb::none(),
- nb::arg("attributes")= nb::none(),
- nb::arg("properties")= nb::none(),
- nb::arg("regions")= nb::none(),
- nb::arg("context")= nb::none(),
- nb::arg("loc")= nb::none(), inferReturnTypesDoc);
+ nb::arg("operands") = nb::none(),
+ nb::arg("attributes") = nb::none(),
+ nb::arg("properties") = nb::none(), nb::arg("regions") = nb::none(),
+ nb::arg("context") = nb::none(), nb::arg("loc") = nb::none(),
+ inferReturnTypesDoc);
}
};
@@ -463,12 +462,10 @@ public:
static void bindDerived(ClassTy &cls) {
cls.def("inferReturnTypeComponents",
&PyInferShapedTypeOpInterface::inferReturnTypeComponents,
- nb::arg("operands")= nb::none(),
- nb::arg("attributes")= nb::none(),
- nb::arg("regions")= nb::none(),
- nb::arg("properties")= nb::none(),
- nb::arg("context")= nb::none(),
- nb::arg("loc")= nb::none(), inferReturnTypeComponentsDoc);
+ nb::arg("operands") = nb::none(),
+ nb::arg("attributes") = nb::none(), nb::arg("regions") = nb::none(),
+ nb::arg("properties") = nb::none(), nb::arg("context") = nb::none(),
+ nb::arg("loc") = nb::none(), inferReturnTypeComponentsDoc);
}
};
diff --git a/mlir/lib/Bindings/Python/IRTypes.cpp b/mlir/lib/Bindings/Python/IRTypes.cpp
index 5ad7e966f..745b9c48c 100644
--- a/mlir/lib/Bindings/Python/IRTypes.cpp
+++ b/mlir/lib/Bindings/Python/IRTypes.cpp
@@ -49,7 +49,7 @@ public:
MlirType t = mlirIntegerTypeGet(context->get(), width);
return PyIntegerType(context->getRef(), t);
},
- nb::arg("width"), nb::arg("context")= nb::none(),
+ nb::arg("width"), nb::arg("context") = nb::none(),
"Create a signless integer type");
c.def_static(
"get_signed",
@@ -57,7 +57,7 @@ public:
MlirType t = mlirIntegerTypeSignedGet(context->get(), width);
return PyIntegerType(context->getRef(), t);
},
- nb::arg("width"), nb::arg("context")= nb::none(),
+ nb::arg("width"), nb::arg("context") = nb::none(),
"Create a signed integer type");
c.def_static(
"get_unsigned",
@@ -65,7 +65,7 @@ public:
MlirType t = mlirIntegerTypeUnsignedGet(context->get(), width);
return PyIntegerType(context->getRef(), t);
},
- nb::arg("width"), nb::arg("context")= nb::none(),
+ nb::arg("width"), nb::arg("context") = nb::none(),
"Create an unsigned integer type");
c.def_prop_ro(
"width",
@@ -108,7 +108,7 @@ public:
MlirType t = mlirIndexTypeGet(context->get());
return PyIndexType(context->getRef(), t);
},
- nb::arg("context")= nb::none(), "Create a index type.");
+ nb::arg("context") = nb::none(), "Create a index type.");
}
};
@@ -142,7 +142,7 @@ public:
MlirType t = mlirFloat4E2M1FNTypeGet(context->get());
return PyFloat4E2M1FNType(context->getRef(), t);
},
- nb::arg("context")= nb::none(), "Create a float4_e2m1fn type.");
+ nb::arg("context") = nb::none(), "Create a float4_e2m1fn type.");
}
};
@@ -163,7 +163,7 @@ public:
MlirType t = mlirFloat6E2M3FNTypeGet(context->get());
return PyFloat6E2M3FNType(context->getRef(), t);
},
- nb::arg("context")= nb::none(), "Create a float6_e2m3fn type.");
+ nb::arg("context") = nb::none(), "Create a float6_e2m3fn type.");
}
};
@@ -184,7 +184,7 @@ public:
MlirType t = mlirFloat6E3M2FNTypeGet(context->get());
return PyFloat6E3M2FNType(context->getRef(), t);
},
- nb::arg("context")= nb::none(), "Create a float6_e3m2fn type.");
+ nb::arg("context") = nb::none(), "Create a float6_e3m2fn type.");
}
};
@@ -205,7 +205,7 @@ public:
MlirType t = mlirFloat8E4M3FNTypeGet(context->get());
return PyFloat8E4M3FNType(context->getRef(), t);
},
- nb::arg("context")= nb::none(), "Create a float8_e4m3fn type.");
+ nb::arg("context") = nb::none(), "Create a float8_e4m3fn type.");
}
};
@@ -225,7 +225,7 @@ public:
MlirType t = mlirFloat8E5M2TypeGet(context->get());
return PyFloat8E5M2Type(context->getRef(), t);
},
- nb::arg("context")= nb::none(), "Create a float8_e5m2 type.");
+ nb::arg("context") = nb::none(), "Create a float8_e5m2 type.");
}
};
@@ -245,7 +245,7 @@ public:
MlirType t = mlirFloat8E4M3TypeGet(context->get());
return PyFloat8E4M3Type(context->getRef(), t);
},
- nb::arg("context")= nb::none(), "Create a float8_e4m3 type.");
+ nb::arg("context") = nb::none(), "Create a float8_e4m3 type.");
}
};
@@ -266,8 +266,7 @@ public:
MlirType t = mlirFloat8E4M3FNUZTypeGet(context->get());
return PyFloat8E4M3FNUZType(context->getRef(), t);
},
- nb::arg("context")= nb::none(),
- "Create a float8_e4m3fnuz type.");
+ nb::arg("context") = nb::none(), "Create a float8_e4m3fnuz type.");
}
};
@@ -288,8 +287,7 @@ public:
MlirType t = mlirFloat8E4M3B11FNUZTypeGet(context->get());
return PyFloat8E4M3B11FNUZType(context->getRef(), t);
},
- nb::arg("context")= nb::none(),
- "Create a float8_e4m3b11fnuz type.");
+ nb::arg("context") = nb::none(), "Create a float8_e4m3b11fnuz type.");
}
};
@@ -310,8 +308,7 @@ public:
MlirType t = mlirFloat8E5M2FNUZTypeGet(context->get());
return PyFloat8E5M2FNUZType(context->getRef(), t);
},
- nb::arg("context")= nb::none(),
- "Create a float8_e5m2fnuz type.");
+ nb::arg("context") = nb::none(), "Create a float8_e5m2fnuz type.");
}
};
@@ -331,7 +328,7 @@ public:
MlirType t = mlirFloat8E3M4TypeGet(context->get());
return PyFloat8E3M4Type(context->getRef(), t);
},
- nb::arg("context")= nb::none(), "Create a float8_e3m4 type.");
+ nb::arg("context") = nb::none(), "Create a float8_e3m4 type.");
}
};
@@ -352,8 +349,7 @@ public:
MlirType t = mlirFloat8E8M0FNUTypeGet(context->get());
return PyFloat8E8M0FNUType(context->getRef(), t);
},
- nb::arg("context")= nb::none(),
- "Create a float8_e8m0fnu type.");
+ nb::arg("context") = nb::none(), "Create a float8_e8m0fnu type.");
}
};
@@ -373,7 +369,7 @@ public:
MlirType t = mlirBF16TypeGet(context->get());
return PyBF16Type(context->getRef(), t);
},
- nb::arg("context")= nb::none(), "Create a bf16 type.");
+ nb::arg("context") = nb::none(), "Create a bf16 type.");
}
};
@@ -393,7 +389,7 @@ public:
MlirType t = mlirF16TypeGet(context->get());
return PyF16Type(context->getRef(), t);
},
- nb::arg("context")= nb::none(), "Create a f16 type.");
+ nb::arg("context") = nb::none(), "Create a f16 type.");
}
};
@@ -413,7 +409,7 @@ public:
MlirType t = mlirTF32TypeGet(context->get());
return PyTF32Type(context->getRef(), t);
},
- nb::arg("context")= nb::none(), "Create a tf32 type.");
+ nb::arg("context") = nb::none(), "Create a tf32 type.");
}
};
@@ -433,7 +429,7 @@ public:
MlirType t = mlirF32TypeGet(context->get());
return PyF32Type(context->getRef(), t);
},
- nb::arg("context")= nb::none(), "Create a f32 type.");
+ nb::arg("context") = nb::none(), "Create a f32 type.");
}
};
@@ -453,7 +449,7 @@ public:
MlirType t = mlirF64TypeGet(context->get());
return PyF64Type(context->getRef(), t);
},
- nb::arg("context")= nb::none(), "Create a f64 type.");
+ nb::arg("context") = nb::none(), "Create a f64 type.");
}
};
@@ -473,7 +469,7 @@ public:
MlirType t = mlirNoneTypeGet(context->get());
return PyNoneType(context->getRef(), t);
},
- nb::arg("context")= nb::none(), "Create a none type.");
+ nb::arg("context") = nb::none(), "Create a none type.");
}
};
@@ -639,9 +635,9 @@ public:
static void bindDerived(ClassTy &c) {
c.def_static("get", &PyVectorType::get, nb::arg("shape"),
nb::arg("element_type"), nb::kw_only(),
- nb::arg("scalable")= nb::none(),
- nb::arg("scalable_dims")= nb::none(),
- nb::arg("loc")= nb::none(), "Create a vector type")
+ nb::arg("scalable") = nb::none(),
+ nb::arg("scalable_dims") = nb::none(),
+ nb::arg("loc") = nb::none(), "Create a vector type")
.def_prop_ro(
"scalable",
[](MlirType self) { return mlirVectorTypeIsScalable(self); })
@@ -720,8 +716,8 @@ public:
return PyRankedTensorType(elementType.getContext(), t);
},
nb::arg("shape"), nb::arg("element_type"),
- nb::arg("encoding")= nb::none(),
- nb::arg("loc")= nb::none(), "Create a ranked tensor type");
+ nb::arg("encoding") = nb::none(), nb::arg("loc") = nb::none(),
+ "Create a ranked tensor type");
c.def_prop_ro("encoding",
[](PyRankedTensorType &self) -> std::optional<MlirAttribute> {
MlirAttribute encoding =
@@ -753,7 +749,7 @@ public:
throw MLIRError("Invalid type", errors.take());
return PyUnrankedTensorType(elementType.getContext(), t);
},
- nb::arg("element_type"), nb::arg("loc")= nb::none(),
+ nb::arg("element_type"), nb::arg("loc") = nb::none(),
"Create a unranked tensor type");
}
};
@@ -785,9 +781,8 @@ public:
return PyMemRefType(elementType.getContext(), t);
},
nb::arg("shape"), nb::arg("element_type"),
- nb::arg("layout")= nb::none(),
- nb::arg("memory_space")= nb::none(),
- nb::arg("loc")= nb::none(), "Create a memref type")
+ nb::arg("layout") = nb::none(), nb::arg("memory_space") = nb::none(),
+ nb::arg("loc") = nb::none(), "Create a memref type")
.def_prop_ro(
"layout",
[](PyMemRefType &self) -> MlirAttribute {
@@ -852,7 +847,7 @@ public:
return PyUnrankedMemRefType(elementType.getContext(), t);
},
nb::arg("element_type"), nb::arg("memory_space").none(),
- nb::arg("loc")= nb::none(), "Create a unranked memref type")
+ nb::arg("loc") = nb::none(), "Create a unranked memref type")
.def_prop_ro(
"memory_space",
[](PyUnrankedMemRefType &self) -> std::optional<MlirAttribute> {
@@ -882,7 +877,7 @@ public:
elements.data());
return PyTupleType(context->getRef(), t);
},
- nb::arg("elements"), nb::arg("context")= nb::none(),
+ nb::arg("elements"), nb::arg("context") = nb::none(),
"Create a tuple type");
c.def(
"get_type",
@@ -918,8 +913,7 @@ public:
results.size(), results.data());
return PyFunctionType(context->getRef(), t);
},
- nb::arg("inputs"), nb::arg("results"),
- nb::arg("context")= nb::none(),
+ nb::arg("inputs"), nb::arg("results"), nb::arg("context") = nb::none(),
"Gets a FunctionType from a list of input and result types");
c.def_prop_ro(
"inputs",
@@ -971,7 +965,7 @@ public:
return PyOpaqueType(context->getRef(), type);
},
nb::arg("dialect_namespace"), nb::arg("buffer"),
- nb::arg("context")= nb::none(),
+ nb::arg("context") = nb::none(),
"Create an unregistered (opaque) dialect type.");
c.def_prop_ro(
"dialect_namespace",
diff --git a/mlir/lib/Bindings/Python/Pass.cpp b/mlir/lib/Bindings/Python/Pass.cpp
index 5b6de4786..72bf8ed8f 100644
--- a/mlir/lib/Bindings/Python/Pass.cpp
+++ b/mlir/lib/Bindings/Python/Pass.cpp
@@ -67,7 +67,7 @@ void mlir::python::populatePassManagerSubmodule(nb::module_ &m) {
mlirStringRefCreate(anchorOp.data(), anchorOp.size()));
new (&self) PyPassManager(passManager);
},
- "anchor_op"_a = nb::str("any"), "context"_a= nb::none(),
+ "anchor_op"_a = nb::str("any"), "context"_a = nb::none(),
"Create a new PassManager for the current (or provided) Context.")
.def_prop_ro(MLIR_PYTHON_CAPI_PTR_ATTR, &PyPassManager::getCapsule)
.def(MLIR_PYTHON_CAPI_FACTORY_ATTR, &PyPassManager::createFromCapsule)
@@ -109,10 +109,10 @@ void mlir::python::populatePassManagerSubmodule(nb::module_ &m) {
"print_before_all"_a = false, "print_after_all"_a = true,
"print_module_scope"_a = false, "print_after_change"_a = false,
"print_after_failure"_a = false,
- "large_elements_limit"_a= nb::none(),
- "large_resource_limit"_a= nb::none(),
- "enable_debug_info"_a = false, "print_generic_op_form"_a = false,
- "tree_printing_dir_path"_a= nb::none(),
+ "large_elements_limit"_a = nb::none(),
+ "large_resource_limit"_a = nb::none(), "enable_debug_info"_a = false,
+ "print_generic_op_form"_a = false,
+ "tree_printing_dir_path"_a = nb::none(),
"Enable IR printing, default as mlir-print-ir-after-all.")
.def(
"enable_verifier",
@@ -139,7 +139,7 @@ void mlir::python::populatePassManagerSubmodule(nb::module_ &m) {
throw nb::value_error(errorMsg.join().c_str());
return new PyPassManager(passManager);
},
- "pipeline"_a, "context"_a= nb::none(),
+ "pipeline"_a, "context"_a = nb::none(),
"Parse a textual pass-pipeline and return a top-level PassManager "
"that can be applied on a Module. Throw a ValueError if the pipeline "
"can't be parsed")
``````````
</details>
https://github.com/llvm/llvm-project/pull/157519
More information about the Mlir-commits
mailing list