Skip to content

Commit 7e581d6

Browse files
committed
[MLIR] Apply clang-tidy fixes for performance-unnecessary-value-param in IRAffine.cpp (NFC)
1 parent 40d8d41 commit 7e581d6

File tree

2 files changed

+16
-13
lines changed

2 files changed

+16
-13
lines changed

mlir/lib/Bindings/Python/IRAffine.cpp

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ static void pyListToVector(const nb::list &list,
6464
}
6565

6666
template <typename PermutationTy>
67-
static bool isPermutation(std::vector<PermutationTy> permutation) {
67+
static bool isPermutation(const std::vector<PermutationTy> &permutation) {
6868
llvm::SmallVector<bool, 8> seen(permutation.size(), false);
6969
for (auto val : permutation) {
7070
if (val < permutation.size()) {
@@ -366,7 +366,7 @@ nb::object PyAffineExpr::getCapsule() {
366366
return nb::steal<nb::object>(mlirPythonAffineExprToCapsule(*this));
367367
}
368368

369-
PyAffineExpr PyAffineExpr::createFromCapsule(nb::object capsule) {
369+
PyAffineExpr PyAffineExpr::createFromCapsule(const nb::object &capsule) {
370370
MlirAffineExpr rawAffineExpr = mlirPythonCapsuleToAffineExpr(capsule.ptr());
371371
if (mlirAffineExprIsNull(rawAffineExpr))
372372
throw nb::python_error();
@@ -424,7 +424,7 @@ nb::object PyAffineMap::getCapsule() {
424424
return nb::steal<nb::object>(mlirPythonAffineMapToCapsule(*this));
425425
}
426426

427-
PyAffineMap PyAffineMap::createFromCapsule(nb::object capsule) {
427+
PyAffineMap PyAffineMap::createFromCapsule(const nb::object &capsule) {
428428
MlirAffineMap rawAffineMap = mlirPythonCapsuleToAffineMap(capsule.ptr());
429429
if (mlirAffineMapIsNull(rawAffineMap))
430430
throw nb::python_error();
@@ -500,7 +500,7 @@ nb::object PyIntegerSet::getCapsule() {
500500
return nb::steal<nb::object>(mlirPythonIntegerSetToCapsule(*this));
501501
}
502502

503-
PyIntegerSet PyIntegerSet::createFromCapsule(nb::object capsule) {
503+
PyIntegerSet PyIntegerSet::createFromCapsule(const nb::object &capsule) {
504504
MlirIntegerSet rawIntegerSet = mlirPythonCapsuleToIntegerSet(capsule.ptr());
505505
if (mlirIntegerSetIsNull(rawIntegerSet))
506506
throw nb::python_error();
@@ -708,7 +708,8 @@ void mlir::python::populateIRAffine(nb::module_ &m) {
708708
return static_cast<size_t>(llvm::hash_value(self.get().ptr));
709709
})
710710
.def_static("compress_unused_symbols",
711-
[](nb::list affineMaps, DefaultingPyMlirContext context) {
711+
[](const nb::list &affineMaps,
712+
DefaultingPyMlirContext context) {
712713
SmallVector<MlirAffineMap> maps;
713714
pyListToVector<PyAffineMap, MlirAffineMap>(
714715
affineMaps, maps, "attempting to create an AffineMap");
@@ -734,7 +735,7 @@ void mlir::python::populateIRAffine(nb::module_ &m) {
734735
kDumpDocstring)
735736
.def_static(
736737
"get",
737-
[](intptr_t dimCount, intptr_t symbolCount, nb::list exprs,
738+
[](intptr_t dimCount, intptr_t symbolCount, const nb::list &exprs,
738739
DefaultingPyMlirContext context) {
739740
SmallVector<MlirAffineExpr> affineExprs;
740741
pyListToVector<PyAffineExpr, MlirAffineExpr>(
@@ -869,7 +870,8 @@ void mlir::python::populateIRAffine(nb::module_ &m) {
869870
.def(MLIR_PYTHON_CAPI_FACTORY_ATTR, &PyIntegerSet::createFromCapsule)
870871
.def("__eq__", [](PyIntegerSet &self,
871872
PyIntegerSet &other) { return self == other; })
872-
.def("__eq__", [](PyIntegerSet &self, nb::object other) { return false; })
873+
.def("__eq__",
874+
[](PyIntegerSet &self, const nb::object &other) { return false; })
873875
.def("__str__",
874876
[](PyIntegerSet &self) {
875877
PyPrintAccumulator printAccum;
@@ -898,7 +900,7 @@ void mlir::python::populateIRAffine(nb::module_ &m) {
898900
kDumpDocstring)
899901
.def_static(
900902
"get",
901-
[](intptr_t numDims, intptr_t numSymbols, nb::list exprs,
903+
[](intptr_t numDims, intptr_t numSymbols, const nb::list &exprs,
902904
std::vector<bool> eqFlags, DefaultingPyMlirContext context) {
903905
if (exprs.size() != eqFlags.size())
904906
throw nb::value_error(
@@ -934,8 +936,9 @@ void mlir::python::populateIRAffine(nb::module_ &m) {
934936
nb::arg("context").none() = nb::none())
935937
.def(
936938
"get_replaced",
937-
[](PyIntegerSet &self, nb::list dimExprs, nb::list symbolExprs,
938-
intptr_t numResultDims, intptr_t numResultSymbols) {
939+
[](PyIntegerSet &self, const nb::list &dimExprs,
940+
const nb::list &symbolExprs, intptr_t numResultDims,
941+
intptr_t numResultSymbols) {
939942
if (static_cast<intptr_t>(dimExprs.size()) !=
940943
mlirIntegerSetGetNumDims(self))
941944
throw nb::value_error(

mlir/lib/Bindings/Python/IRModule.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1216,7 +1216,7 @@ class PyAffineExpr : public BaseContextObject {
12161216
/// Note that PyAffineExpr instances are uniqued, so the returned object
12171217
/// may be a pre-existing object. Ownership of the underlying MlirAffineExpr
12181218
/// is taken by calling this function.
1219-
static PyAffineExpr createFromCapsule(nanobind::object capsule);
1219+
static PyAffineExpr createFromCapsule(const nanobind::object &capsule);
12201220

12211221
PyAffineExpr add(const PyAffineExpr &other) const;
12221222
PyAffineExpr mul(const PyAffineExpr &other) const;
@@ -1243,7 +1243,7 @@ class PyAffineMap : public BaseContextObject {
12431243
/// Note that PyAffineMap instances are uniqued, so the returned object
12441244
/// may be a pre-existing object. Ownership of the underlying MlirAffineMap
12451245
/// is taken by calling this function.
1246-
static PyAffineMap createFromCapsule(nanobind::object capsule);
1246+
static PyAffineMap createFromCapsule(const nanobind::object &capsule);
12471247

12481248
private:
12491249
MlirAffineMap affineMap;
@@ -1263,7 +1263,7 @@ class PyIntegerSet : public BaseContextObject {
12631263
/// Creates a PyIntegerSet from the MlirAffineMap wrapped by a capsule.
12641264
/// Note that PyIntegerSet instances may be uniqued, so the returned object
12651265
/// may be a pre-existing object. Integer sets are owned by the context.
1266-
static PyIntegerSet createFromCapsule(nanobind::object capsule);
1266+
static PyIntegerSet createFromCapsule(const nanobind::object &capsule);
12671267

12681268
private:
12691269
MlirIntegerSet integerSet;

0 commit comments

Comments
 (0)