| 文件 | 最后提交记录 | 最后更新时间 |
|---|---|---|
[mlir python] Port in-tree dialects to nanobind. (#119924) This is a companion to #118583, although it can be landed independently because since #117922 dialects do not have to use the same Python binding framework as the Python core code. This PR ports all of the in-tree dialect and pass extensions to nanobind, with the exception of those that remain for testing pybind11 support. This PR also: * removes CollectDiagnosticsToStringScope from NanobindAdaptors.h. This was overlooked in a previous PR and it is duplicated in Diagnostics.h. --------- Co-authored-by: Jacques Pienaar <jpienaar@google.com> | 1 年前 | |
[MLIR][Python] remove unnecessary arg.none() = nb::none() pattern (#157519) We have arg.none() = nb::none() in a lot of places but this is no longer necessary (as of ~[2022](https://github.com/wjakob/nanobind/commit/62a23bb87b57d939e045f9c9da78a1d7235d2271)). | 11 个月前 | |
[MLIR][Python] Add python bindings for IRDL dialect (#158488) In this PR we add basic python bindings for IRDL dialect, so that python users can create and load IRDL dialects in python. This allows users, to some extent, to define dialects in Python without having to modify MLIR’s CMake/TableGen/C++ code and rebuild, making prototyping more convenient. A basic example is shown below (and also in the added test case): python # create a module with IRDL dialects module = Module.create() with InsertionPoint(module.body): dialect = irdl.DialectOp("irdl_test") with InsertionPoint(dialect.body): op = irdl.OperationOp("test_op") with InsertionPoint(op.body): f32 = irdl.is_(TypeAttr.get(F32Type.get())) irdl.operands_([f32], ["input"], [irdl.Variadicity.single]) # load the module irdl.load_dialects(module) # use the op defined in IRDL m = Module.parse(""" module { %a = arith.constant 1.0 : f32 "irdl_test.test_op"(%a) : (f32) -> () } """) | 11 个月前 | |
[MLIR][Python] add GetTypeID for llvm.struct_type and llvm.ptr and enable downcasting (#169383) | 9 个月前 | |
[mlir][linalg][python] Add Python Bindings for Inferring Contraction Dimensions from Affine Maps (#167587) This PR exposes linalg::inferContractionDims(ArrayRef<AffineMap>) to Python, allowing users to infer contraction dimensions (batch/m/n/k) directly from a list of affine maps without needing an operation. --------- Signed-off-by: Bangtian Liu <liubangtian@gmail.com> | 9 个月前 | |
[MLIR][Python] remove unnecessary arg.none() = nb::none() pattern (#157519) We have arg.none() = nb::none() in a lot of places but this is no longer necessary (as of ~[2022](https://github.com/wjakob/nanobind/commit/62a23bb87b57d939e045f9c9da78a1d7235d2271)). | 11 个月前 | |
[MLIR][Python] reland (narrower) type stub generation (#157930) This a reland of https://github.com/llvm/llvm-project/pull/155741 which was reverted at https://github.com/llvm/llvm-project/pull/157831. This version is narrower in scope - it only turns on automatic stub generation for MLIRPythonExtension.Core._mlir and **does not do anything automatically**. Specifically, the only CMake code added to AddMLIRPython.cmake is the mlir_generate_type_stubs function which is then used only in a manual way. The API for mlir_generate_type_stubs is: Arguments: MODULE_NAME: The fully-qualified name of the extension module (used for importing in python). DEPENDS_TARGETS: List of targets these type stubs depend on being built; usually corresponding to the specific extension module (e.g., something like StandalonePythonModules.extension._standaloneDialectsNanobind.dso) and the core bindings extension module (e.g., something like StandalonePythonModules.extension._mlir.dso). OUTPUT_DIR: The root output directory to emit the type stubs into. OUTPUTS: List of expected outputs. DEPENDS_TARGET_SRC_DEPS: List of cpp sources for extension library (for generating a DEPFILE). IMPORT_PATHS: List of paths to add to PYTHONPATH for stubgen. PATTERN_FILE: (Optional) Pattern file (see https://nanobind.readthedocs.io/en/latest/typing.html#pattern-files). Outputs: NB_STUBGEN_CUSTOM_TARGET: The target corresponding to generation which other targets can depend on. Downstream users should use mlir_generate_type_stubs in coordination with declare_mlir_python_sources to turn on stub generation for their own downstream dialect extensions and upstream dialect extensions if they so choose. Standalone example shows an example. Note, downstream will also need to set -DMLIR_PYTHON_PACKAGE_PREFIX=... correctly for their bindings. | 11 个月前 | |
[MLIR] Apply clang-tidy fixes for performance-unnecessary-value-param in DialectQuant.cpp (NFC) | 1 年前 | |
[MLIR][Transform][SMT] Introduce transform.smt.constrain_params (#159450) Introduces a Transform-dialect SMT-extension so that we can have an op to express constrains on Transform-dialect params, in particular when these params are knobs -- see transform.tune.knob -- and can hence be seen as symbolic variables. This op allows expressing joint constraints over multiple params/knobs together. While the op's semantics are clearly defined, per SMTLIB, the interpreted semantics -- i.e. the apply() method -- for now just defaults to failure. In the future we should support attaching an implementation so that users can Bring Your Own Solver and thereby control performance of interpreting the op. For now the main usage is to walk schedule IR and collect these constraints so that knobs can be rewritten to constants that satisfy the constraints. | 11 个月前 | |
[MLIR][Python] remove unnecessary arg.none() = nb::none() pattern (#157519) We have arg.none() = nb::none() in a lot of places but this is no longer necessary (as of ~[2022](https://github.com/wjakob/nanobind/commit/62a23bb87b57d939e045f9c9da78a1d7235d2271)). | 11 个月前 | |
[MLIR][Python] remove unnecessary arg.none() = nb::none() pattern (#157519) We have arg.none() = nb::none() in a lot of places but this is no longer necessary (as of ~[2022](https://github.com/wjakob/nanobind/commit/62a23bb87b57d939e045f9c9da78a1d7235d2271)). | 11 个月前 | |
[MLIR] Apply clang-tidy fixes for performance-unnecessary-value-param in ExecutionEngineModule.cpp (NFC) | 1 年前 | |
[mlir python] Port in-tree dialects to nanobind. (#119924) This is a companion to #118583, although it can be landed independently because since #117922 dialects do not have to use the same Python binding framework as the Python core code. This PR ports all of the in-tree dialect and pass extensions to nanobind, with the exception of those that remain for testing pybind11 support. This PR also: * removes CollectDiagnosticsToStringScope from NanobindAdaptors.h. This was overlooked in a previous PR and it is duplicated in Diagnostics.h. --------- Co-authored-by: Jacques Pienaar <jpienaar@google.com> | 1 年前 | |
[MLIR][Python] Make the TypeID allocator globally defined in PassManager.add (#162594) Previously, each time we called PassManager.add(python_pass_callable), a new TypeID allocator was created and never released afterward. This approach could potentially lead to some issues. In this PR, we introduce a global TypeIDAllocator that is shared across all add calls to allocate IDs. | 10 个月前 | |
[MLIR][Python] use nb::typed for return signatures (#160221) https://github.com/llvm/llvm-project/pull/160183 removed nb::typed annotation to fix bazel but it turned out to be simply a matter of not using the correct version of nanobind (see https://github.com/llvm/llvm-project/pull/160183#issuecomment-3321429155). This PR restores those annotations but (mostly) moves to the return positions of the actual methods. | 11 个月前 | |
[mlir:python] Prevent crash in DenseElementsAttr. (#163564) This PR fixes a crash in the bf_getbuffer implementation of PyDenseElementsAttribute that occurred when an element type was not supported, such as bf16. I believe that supportion bf16 is not possible with that protocol but that's out of the scope of this PR. Previsouly, the code raised an std::exception out of bf_getbuffer that nanobind does not catch (see also pybind/pybind11#3336). The PR makes the function catch all std::exceptions and manually raises a Python exception instead. Signed-off-by: Ingo Müller <ingomueller@google.com> | 10 个月前 | |
[mlir][py][c] Enable setting block arg locations. (#169033) This enables changing the location of a block argument. Follows the approach for updating type of block arg. | 9 个月前 | |
[MLIR][Python] use nb::typed for return signatures (#160221) https://github.com/llvm/llvm-project/pull/160183 removed nb::typed annotation to fix bazel but it turned out to be simply a matter of not using the correct version of nanobind (see https://github.com/llvm/llvm-project/pull/160183#issuecomment-3321429155). This PR restores those annotations but (mostly) moves to the return positions of the actual methods. | 11 个月前 | |
[mlir][python] automatic location inference (#151246) This PR implements "automatic" location inference in the bindings. The way it works is it walks the frame stack collecting source locations (Python captures these in the frame itself). It is inspired by JAX's [implementation](https://github.com/jax-ml/jax/blob/523ddcfbcad005deab5a7d542df4c706f5ee5e9c/jax/_src/interpreters/mlir.py#L462) but moves the frame stack traversal into the bindings for better performance. The system supports registering "included" and "excluded" filenames; frames originating from functions in included filenames **will not** be filtered and frames originating from functions in excluded filenames **will** be filtered (in that order). This allows excluding all the generated *_ops_gen.py files. The system is also "toggleable" and off by default to save people who have their own systems (such as JAX) from the added cost. Note, the system stores the entire stacktrace (subject to locTracebackFramesLimit) in the Location using specifically a CallSiteLoc. This can be useful for profiling tools (flamegraphs etc.). Shoutout to the folks at JAX for coming up with a good system. --------- Co-authored-by: Jacques Pienaar <jpienaar@google.com> | 1 年前 | |
[MLIR][Python] Expose the insertion point of pattern rewriter (#161001) In [#160520](https://github.com/llvm/llvm-project/pull/160520), we discussed the current limitations of PDL rewriting in Python (see [this comment](https://github.com/llvm/llvm-project/pull/160520#issuecomment-3332326184)). At the moment, we cannot create new operations in PDL native (python) rewrite functions because the PatternRewriter APIs are not exposed. This PR introduces bindings to retrieve the insertion point of the PatternRewriter, enabling users to create new operations within Python rewrite functions. With this capability, more complex rewrites e.g. with branching and loops that involve op creations become possible. --------- Co-authored-by: Maksim Levental <maksim.levental@gmail.com> | 10 个月前 | |
[MLIR][Python] fixup Context and Location stubs and NanobindAdaptors (#161433) add correct names for NB_TYPE_CASTER(..., name) so users of NanobindAdaptors.h can generate the correct hints. Also fix a few straggler stubs. | 10 个月前 | |
[mlir python] Port in-tree dialects to nanobind. (#119924) This is a companion to #118583, although it can be landed independently because since #117922 dialects do not have to use the same Python binding framework as the Python core code. This PR ports all of the in-tree dialect and pass extensions to nanobind, with the exception of those that remain for testing pybind11 support. This PR also: * removes CollectDiagnosticsToStringScope from NanobindAdaptors.h. This was overlooked in a previous PR and it is duplicated in Diagnostics.h. --------- Co-authored-by: Jacques Pienaar <jpienaar@google.com> | 1 年前 | |
[MLIR][Python] fixup Context and Location stubs and NanobindAdaptors (#161433) add correct names for NB_TYPE_CASTER(..., name) so users of NanobindAdaptors.h can generate the correct hints. Also fix a few straggler stubs. | 10 个月前 | |
[MLIR][Python] fix PyRegionList __iter__ (#167466) Fixes https://github.com/llvm/llvm-project/issues/167455 | 9 个月前 | |
[MLIR][Python] Expose PassManager::enableStatistics to CAPI and Python (#162591) PassManager::enableStatistics seems currently missing in both C API and Python bindings. So here we added them in this PR, which includes the PassDisplayMode enum type and the EnableStatistics method. | 10 个月前 | |
[mlir python] Port Python core code to nanobind. (#120473) Relands #118583, with a fix for Python 3.8 compatibility. It was not possible to set the buffer protocol accessers via slots in Python 3.8. Why? https://nanobind.readthedocs.io/en/latest/why.html says it better than I can, but my primary motivation for this change is to improve MLIR IR construction time from JAX. For a complicated Google-internal LLM model in JAX, this change improves the MLIR lowering time by around 5s (out of around 30s), which is a significant speedup for simply switching binding frameworks. To a large extent, this is a mechanical change, for instance changing pybind11:: to nanobind::. Notes: * this PR needs Nanobind 2.4.0, because it needs a bug fix (https://github.com/wjakob/nanobind/pull/806) that landed in that release. * this PR does not port the in-tree dialect extension modules. They can be ported in a future PR. * I removed the py::sibling() annotations from def_static and def_class in PybindAdapters.h. These ask pybind11 to try to form an overload with an existing method, but it's not possible to form mixed pybind11/nanobind overloads this ways and the parent class is now defined in nanobind. Better solutions may be possible here. * nanobind does not contain an exact equivalent of pybind11's buffer protocol support. It was not hard to add a nanobind implementation of a similar API. * nanobind is pickier about casting to std::vector<bool>, expecting that the input is a sequence of bool types, not truthy values. In a couple of places I added code to support truthy values during casting. * nanobind distinguishes bytes (nb::bytes) from strings (e.g., std::string). This required nb::bytes overloads in a few places. | 1 年前 | |
[MLIR] Apply clang-tidy fixes for llvm-include-order in RegisterEverything.cpp (NFC) | 1 年前 | |
[MLIR] Fix typo of the word "pattern" in CAPI and docs (#163780) This includes the rename from mlirOpRewritePattenCreate to mlirOpRewritePatternCreate in CAPI, and other typo fixes in docs and code comments. | 10 个月前 | |
[mlir python] Port Python core code to nanobind. (#120473) Relands #118583, with a fix for Python 3.8 compatibility. It was not possible to set the buffer protocol accessers via slots in Python 3.8. Why? https://nanobind.readthedocs.io/en/latest/why.html says it better than I can, but my primary motivation for this change is to improve MLIR IR construction time from JAX. For a complicated Google-internal LLM model in JAX, this change improves the MLIR lowering time by around 5s (out of around 30s), which is a significant speedup for simply switching binding frameworks. To a large extent, this is a mechanical change, for instance changing pybind11:: to nanobind::. Notes: * this PR needs Nanobind 2.4.0, because it needs a bug fix (https://github.com/wjakob/nanobind/pull/806) that landed in that release. * this PR does not port the in-tree dialect extension modules. They can be ported in a future PR. * I removed the py::sibling() annotations from def_static and def_class in PybindAdapters.h. These ask pybind11 to try to form an overload with an existing method, but it's not possible to form mixed pybind11/nanobind overloads this ways and the parent class is now defined in nanobind. Better solutions may be possible here. * nanobind does not contain an exact equivalent of pybind11's buffer protocol support. It was not hard to add a nanobind implementation of a similar API. * nanobind is pickier about casting to std::vector<bool>, expecting that the input is a sequence of bool types, not truthy values. In a couple of places I added code to support truthy values during casting. * nanobind distinguishes bytes (nb::bytes) from strings (e.g., std::string). This required nb::bytes overloads in a few places. | 1 年前 | |
[mlir python] Port in-tree dialects to nanobind. (#119924) This is a companion to #118583, although it can be landed independently because since #117922 dialects do not have to use the same Python binding framework as the Python core code. This PR ports all of the in-tree dialect and pass extensions to nanobind, with the exception of those that remain for testing pybind11 support. This PR also: * removes CollectDiagnosticsToStringScope from NanobindAdaptors.h. This was overlooked in a previous PR and it is duplicated in Diagnostics.h. --------- Co-authored-by: Jacques Pienaar <jpienaar@google.com> | 1 年前 | |
[MLIR][Python] remove liveOperations (#155114) Historical context: PyMlirContext::liveOperations was an optimization meant to cut down on the number of Python object allocations and (partially) a mechanism for updating validity of ops after transformation. E.g. during walking/transforming the AST. See original patch [here](https://reviews.llvm.org/D87958). Inspired by a [renewed](https://github.com/llvm/llvm-project/pull/139721#issuecomment-3217131918) interest in https://github.com/llvm/llvm-project/pull/139721 (which has become a little stale...) <p align="center"> <img width="504" height="375" alt="image" src="https://github.com/user-attachments/assets/0daad562-d3d1-4876-8d01-5dba382ab186" /> </p> In the previous go-around (https://github.com/llvm/llvm-project/pull/92631) there were two issues which have been resolved 1. ops that were "fetched" under a root op which has been transformed are no longer reported as invalid. We simply "[formally forbid](https://github.com/llvm/llvm-project/pull/92631#issuecomment-2119397018)" this; 2. Module._CAPICreate(module_capsule) must now be followed by a module._clear_mlir_module() to prevent double-freeing of the actual ModuleOp object (i.e. calling the dtor on the OwningOpRef<ModuleOp>): python module = ... module_dup = Module._CAPICreate(module._CAPIPtr) module._clear_mlir_module() - **the alternative choice** here is to remove the Module._CAPICreate API altogether and replace it with something like Module._move(module) which will do both Module._CAPICreate and module._clear_mlir_module. Note, the other approach I explored last year was a [weakref system](https://github.com/llvm/llvm-project/pull/97340) for mlir::Operation which would effectively hoist this liveOperations thing into MLIR core. Possibly doable but I now believe it's a bad idea. The other potentially breaking change is is, which checks object equality rather than value equality, will now report False because we are always allocating new Python objects (ie that's the whole point of this change). Users wanting to check equality for Operation and Module should use ==. | 11 个月前 |
| 文件 | 最后提交记录 | 最后更新时间 |
|---|---|---|
| 1 年前 | ||
| 11 个月前 | ||
| 11 个月前 | ||
| 9 个月前 | ||
| 9 个月前 | ||
| 11 个月前 | ||
| 11 个月前 | ||
| 1 年前 | ||
| 11 个月前 | ||
| 11 个月前 | ||
| 11 个月前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 10 个月前 | ||
| 11 个月前 | ||
| 10 个月前 | ||
| 9 个月前 | ||
| 11 个月前 | ||
| 1 年前 | ||
| 10 个月前 | ||
| 10 个月前 | ||
| 1 年前 | ||
| 10 个月前 | ||
| 9 个月前 | ||
| 10 个月前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 10 个月前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 11 个月前 |