@@ -505,7 +505,7 @@ class PyArrayAttribute : public PyConcreteAttribute<PyArrayAttribute> {
505505 static void bindDerived (ClassTy &c) {
506506 c.def_static (
507507 " get" ,
508- [](nb::list attributes, DefaultingPyMlirContext context) {
508+ [](const nb::list & attributes, DefaultingPyMlirContext context) {
509509 SmallVector<MlirAttribute> mlirAttributes;
510510 mlirAttributes.reserve (nb::len (attributes));
511511 for (auto attribute : attributes) {
@@ -530,7 +530,7 @@ class PyArrayAttribute : public PyConcreteAttribute<PyArrayAttribute> {
530530 .def (" __iter__" , [](const PyArrayAttribute &arr) {
531531 return PyArrayAttributeIterator (arr);
532532 });
533- c.def (" __add__" , [](PyArrayAttribute arr, nb::list extras) {
533+ c.def (" __add__" , [](PyArrayAttribute arr, const nb::list & extras) {
534534 std::vector<MlirAttribute> attributes;
535535 intptr_t numOldElements = mlirArrayAttrGetNumElements (arr);
536536 attributes.reserve (numOldElements + nb::len (extras));
@@ -708,7 +708,7 @@ class PyFlatSymbolRefAttribute
708708 static void bindDerived (ClassTy &c) {
709709 c.def_static (
710710 " get" ,
711- [](std::string value, DefaultingPyMlirContext context) {
711+ [](const std::string & value, DefaultingPyMlirContext context) {
712712 MlirAttribute attr =
713713 mlirFlatSymbolRefAttrGet (context->get (), toMlirStringRef (value));
714714 return PyFlatSymbolRefAttribute (context->getRef (), attr);
@@ -736,8 +736,8 @@ class PyOpaqueAttribute : public PyConcreteAttribute<PyOpaqueAttribute> {
736736 static void bindDerived (ClassTy &c) {
737737 c.def_static (
738738 " get" ,
739- [](std::string dialectNamespace, nb_buffer buffer, PyType &type ,
740- DefaultingPyMlirContext context) {
739+ [](const std::string & dialectNamespace, const nb_buffer &buffer ,
740+ PyType &type, DefaultingPyMlirContext context) {
741741 const nb_buffer_info bufferInfo = buffer.request ();
742742 intptr_t bufferSize = bufferInfo.size ;
743743 MlirAttribute attr = mlirOpaqueAttrGet (
@@ -775,7 +775,7 @@ class PyStringAttribute : public PyConcreteAttribute<PyStringAttribute> {
775775 static void bindDerived (ClassTy &c) {
776776 c.def_static (
777777 " get" ,
778- [](std::string value, DefaultingPyMlirContext context) {
778+ [](const std::string & value, DefaultingPyMlirContext context) {
779779 MlirAttribute attr =
780780 mlirStringAttrGet (context->get (), toMlirStringRef (value));
781781 return PyStringAttribute (context->getRef (), attr);
@@ -784,7 +784,7 @@ class PyStringAttribute : public PyConcreteAttribute<PyStringAttribute> {
784784 " Gets a uniqued string attribute" );
785785 c.def_static (
786786 " get" ,
787- [](nb::bytes value, DefaultingPyMlirContext context) {
787+ [](const nb::bytes & value, DefaultingPyMlirContext context) {
788788 MlirAttribute attr =
789789 mlirStringAttrGet (context->get (), toMlirStringRef (value));
790790 return PyStringAttribute (context->getRef (), attr);
@@ -793,7 +793,7 @@ class PyStringAttribute : public PyConcreteAttribute<PyStringAttribute> {
793793 " Gets a uniqued string attribute" );
794794 c.def_static (
795795 " get_typed" ,
796- [](PyType &type, std::string value) {
796+ [](PyType &type, const std::string & value) {
797797 MlirAttribute attr =
798798 mlirStringAttrTypedGet (type, toMlirStringRef (value));
799799 return PyStringAttribute (type.getContext (), attr);
@@ -826,7 +826,7 @@ class PyDenseElementsAttribute
826826 using PyConcreteAttribute::PyConcreteAttribute;
827827
828828 static PyDenseElementsAttribute
829- getFromList (nb::list attributes, std::optional<PyType> explicitType,
829+ getFromList (const nb::list & attributes, std::optional<PyType> explicitType,
830830 DefaultingPyMlirContext contextWrapper) {
831831 const size_t numAttributes = nb::len (attributes);
832832 if (numAttributes == 0 )
@@ -878,8 +878,8 @@ class PyDenseElementsAttribute
878878 }
879879
880880 static PyDenseElementsAttribute
881- getFromBuffer (nb_buffer array, bool signless,
882- std::optional<PyType> explicitType,
881+ getFromBuffer (const nb_buffer & array, bool signless,
882+ const std::optional<PyType> & explicitType,
883883 std::optional<std::vector<int64_t >> explicitShape,
884884 DefaultingPyMlirContext contextWrapper) {
885885 // Request a contiguous view. In exotic cases, this will cause a copy.
@@ -894,8 +894,8 @@ class PyDenseElementsAttribute
894894 auto freeBuffer = llvm::make_scope_exit ([&]() { PyBuffer_Release (&view); });
895895
896896 MlirContext context = contextWrapper->get ();
897- MlirAttribute attr = getAttributeFromBuffer (view, signless, explicitType,
898- explicitShape, context);
897+ MlirAttribute attr = getAttributeFromBuffer (
898+ view, signless, explicitType, std::move ( explicitShape) , context);
899899 if (mlirAttributeIsNull (attr)) {
900900 throw std::invalid_argument (
901901 " DenseElementsAttr could not be constructed from the given buffer. "
@@ -1100,7 +1100,8 @@ class PyDenseElementsAttribute
11001100
11011101 static MlirAttribute getAttributeFromBuffer (
11021102 Py_buffer &view, bool signless, std::optional<PyType> explicitType,
1103- std::optional<std::vector<int64_t >> explicitShape, MlirContext &context) {
1103+ const std::optional<std::vector<int64_t >> &explicitShape,
1104+ MlirContext &context) {
11041105 // Detect format codes that are suitable for bulk loading. This includes
11051106 // all byte aligned integer and floating point types up to 8 bytes.
11061107 // Notably, this excludes exotics types which do not have a direct
@@ -1204,8 +1205,8 @@ class PyDenseElementsAttribute
12041205 packbitsFunc (nb::cast (unpackedArray), " bitorder" _a = " little" );
12051206 nb_buffer_info pythonBuffer = nb::cast<nb_buffer>(packedBooleans).request ();
12061207
1207- MlirType bitpackedType =
1208- getShapedType ( mlirIntegerTypeGet (context, 1 ), explicitShape, view);
1208+ MlirType bitpackedType = getShapedType ( mlirIntegerTypeGet (context, 1 ),
1209+ std::move ( explicitShape) , view);
12091210 assert (pythonBuffer.itemsize == 1 && " Packbits must return uint8" );
12101211 // Notice that `mlirDenseElementsAttrRawBufferGet` copies the memory of
12111212 // packedBooleans, hence the MlirAttribute will remain valid even when
@@ -1442,9 +1443,9 @@ class PyDenseResourceElementsAttribute
14421443 using PyConcreteAttribute::PyConcreteAttribute;
14431444
14441445 static PyDenseResourceElementsAttribute
1445- getFromBuffer (nb_buffer buffer, const std::string &name, const PyType &type ,
1446- std::optional<size_t > alignment, bool isMutable ,
1447- DefaultingPyMlirContext contextWrapper) {
1446+ getFromBuffer (const nb_buffer & buffer, const std::string &name,
1447+ const PyType &type, std::optional<size_t > alignment,
1448+ bool isMutable, DefaultingPyMlirContext contextWrapper) {
14481449 if (!mlirTypeIsAShaped (type)) {
14491450 throw std::invalid_argument (
14501451 " Constructing a DenseResourceElementsAttr requires a ShapedType." );
@@ -1533,7 +1534,7 @@ class PyDictAttribute : public PyConcreteAttribute<PyDictAttribute> {
15331534 c.def (" __len__" , &PyDictAttribute::dunderLen);
15341535 c.def_static (
15351536 " get" ,
1536- [](nb::dict attributes, DefaultingPyMlirContext context) {
1537+ [](const nb::dict & attributes, DefaultingPyMlirContext context) {
15371538 SmallVector<MlirNamedAttribute> mlirNamedAttributes;
15381539 mlirNamedAttributes.reserve (attributes.size ());
15391540 for (std::pair<nb::handle, nb::handle> it : attributes) {
@@ -1617,7 +1618,7 @@ class PyTypeAttribute : public PyConcreteAttribute<PyTypeAttribute> {
16171618 static void bindDerived (ClassTy &c) {
16181619 c.def_static (
16191620 " get" ,
1620- [](PyType value, DefaultingPyMlirContext context) {
1621+ [](const PyType & value, DefaultingPyMlirContext context) {
16211622 MlirAttribute attr = mlirTypeAttrGet (value.get ());
16221623 return PyTypeAttribute (context->getRef (), attr);
16231624 },
@@ -1662,7 +1663,7 @@ class PyStridedLayoutAttribute
16621663 static void bindDerived (ClassTy &c) {
16631664 c.def_static (
16641665 " get" ,
1665- [](int64_t offset, const std::vector<int64_t > strides,
1666+ [](int64_t offset, const std::vector<int64_t > & strides,
16661667 DefaultingPyMlirContext ctx) {
16671668 MlirAttribute attr = mlirStridedLayoutAttrGet (
16681669 ctx->get (), offset, strides.size (), strides.data ());
0 commit comments