Skip to content
This repository was archived by the owner on Oct 11, 2025. It is now read-only.

Commit 3650161

Browse files
authored
[mlir] Expose AffineExpr.shift_dims/shift_symbols through C and Python bindings (#131521)
1 parent 30e8968 commit 3650161

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

mlir/lib/Bindings/Python/IRAffine.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -580,6 +580,25 @@ void mlir::python::populateIRAffine(nb::module_ &m) {
580580
return PyAffineExpr(self.getContext(),
581581
mlirAffineExprCompose(self, other));
582582
})
583+
.def(
584+
"shift_dims",
585+
[](PyAffineExpr &self, uint32_t numDims, uint32_t shift,
586+
uint32_t offset) {
587+
return PyAffineExpr(
588+
self.getContext(),
589+
mlirAffineExprShiftDims(self, numDims, shift, offset));
590+
},
591+
nb::arg("num_dims"), nb::arg("shift"), nb::arg("offset").none() = 0)
592+
.def(
593+
"shift_symbols",
594+
[](PyAffineExpr &self, uint32_t numSymbols, uint32_t shift,
595+
uint32_t offset) {
596+
return PyAffineExpr(
597+
self.getContext(),
598+
mlirAffineExprShiftSymbols(self, numSymbols, shift, offset));
599+
},
600+
nb::arg("num_symbols"), nb::arg("shift"),
601+
nb::arg("offset").none() = 0)
583602
.def_static(
584603
"get_add", &PyAffineAddExpr::get,
585604
"Gets an affine expression containing a sum of two expressions.")

0 commit comments

Comments
 (0)