-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[MLIR][Python] reland (narrower) type stub generation #157930
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
7d90167 to
6747bf1
Compare
|
Here's a brief retrospective of the failures involved in the previous PR:
|
|
Note, this has been tested against IREE with @Hardcode84's help iree-org/iree#21916 where it pass PkgCI / Build Packages / Linux Release (x86_64) |
Your "gut feeling" is incorrect - 2.9 was specifically the first release that had this fix wjakob/nanobind#1124 which is what was needed for this PR. |
…8738) LLVM has also moved to generated stubfiles, so we need to generate these ourselves (we could omit them, but they're nice to have). See llvm/llvm-project#157930. Also pulls in the following followup fixes, these should be removed when bumping again. llvm/llvm-project#160183 llvm/llvm-project#160203 llvm/llvm-project#160221 This fixes some mypy lint errors, and causes a few more, I fixed a few but mostly just ignored them. MAX_PYTHON_ORIG_REV_ID: 524aaf2ab047e5185703c44ab3edd7754c67fa26
…8738) LLVM has also moved to generated stubfiles, so we need to generate these ourselves (we could omit them, but they're nice to have). See llvm/llvm-project#157930. Also pulls in the following followup fixes, these should be removed when bumping again. llvm/llvm-project#160183 llvm/llvm-project#160203 llvm/llvm-project#160221 This fixes some mypy lint errors, and causes a few more, I fixed a few but mostly just ignored them. MAX_PYTHON_ORIG_REV_ID: 524aaf2ab047e5185703c44ab3edd7754c67fa26
…8738) LLVM has also moved to generated stubfiles, so we need to generate these ourselves (we could omit them, but they're nice to have). See llvm/llvm-project#157930. Also pulls in the following followup fixes, these should be removed when bumping again. llvm/llvm-project#160183 llvm/llvm-project#160203 llvm/llvm-project#160221 This fixes some mypy lint errors, and causes a few more, I fixed a few but mostly just ignored them. MAX_PYTHON_ORIG_REV_ID: 524aaf2ab047e5185703c44ab3edd7754c67fa26
…8738) LLVM has also moved to generated stubfiles, so we need to generate these ourselves (we could omit them, but they're nice to have). See llvm/llvm-project#157930. Also pulls in the following followup fixes, these should be removed when bumping again. llvm/llvm-project#160183 llvm/llvm-project#160203 llvm/llvm-project#160221 This fixes some mypy lint errors, and causes a few more, I fixed a few but mostly just ignored them. MAX_PYTHON_ORIG_REV_ID: 524aaf2ab047e5185703c44ab3edd7754c67fa26
…8738) LLVM has also moved to generated stubfiles, so we need to generate these ourselves (we could omit them, but they're nice to have). See llvm/llvm-project#157930. Also pulls in the following followup fixes, these should be removed when bumping again. llvm/llvm-project#160183 llvm/llvm-project#160203 llvm/llvm-project#160221 This fixes some mypy lint errors, and causes a few more, I fixed a few but mostly just ignored them. MAX_PYTHON_ORIG_REV_ID: 524aaf2ab047e5185703c44ab3edd7754c67fa26
…8738) LLVM has also moved to generated stubfiles, so we need to generate these ourselves (we could omit them, but they're nice to have). See llvm/llvm-project#157930. Also pulls in the following followup fixes, these should be removed when bumping again. llvm/llvm-project#160183 llvm/llvm-project#160203 llvm/llvm-project#160221 This fixes some mypy lint errors, and causes a few more, I fixed a few but mostly just ignored them. MAX_PYTHON_ORIG_REV_ID: 524aaf2ab047e5185703c44ab3edd7754c67fa26
…nstead of abstract PyOpView (#165053) llvm/llvm-project#157930 changed `nb::object getOwner()` to `PyOpView getOwner()` which implicitly constructs the generic OpView against from a (possibly) concrete OpView. This PR fixes that.
…bstract PyOpView (llvm#165053) llvm#157930 changed `nb::object getOwner()` to `PyOpView getOwner()` which implicitly constructs the generic OpView against from a (possibly) concrete OpView. This PR fixes that.
…bstract PyOpView (llvm#165053) llvm#157930 changed `nb::object getOwner()` to `PyOpView getOwner()` which implicitly constructs the generic OpView against from a (possibly) concrete OpView. This PR fixes that.
…bstract PyOpView (llvm#165053) llvm#157930 changed `nb::object getOwner()` to `PyOpView getOwner()` which implicitly constructs the generic OpView against from a (possibly) concrete OpView. This PR fixes that.
…bstract PyOpView (llvm#165053) llvm#157930 changed `nb::object getOwner()` to `PyOpView getOwner()` which implicitly constructs the generic OpView against from a (possibly) concrete OpView. This PR fixes that.
This is necessary with llvm/llvm-project#157930. Signed-off-by: Ingo Müller <[email protected]>
|
A bunch of
@makslevental: What's your take? What's the best way to deal with this? |
|
Minimal progress: I found that the following manually-specified signature allows def register_operation(dialect_class: type[T], *, replace: bool = False) -> type[T]:I don't know how to handle the closely related |
suggests to me the signature for def register_operation(dialect_class: type[T], *, replace: bool = False) -> type[U]:? |
|
I think you are right in that def register_operation(dialect_class: type[T], *, replace: bool = False) -> Callable[[type[U]], type[U]]:However, neither your proposal nor my new one make the from ._substrait_ops_gen import * # type: ignoreIf the annotation with For the |
I believe this is because pyright expects some type to be generic - is it the builder classes - in which case a pattern file (or an explicit signature won't help) because they're not generic? |
I am not sure I understand this explanation. My understanding is that def __getitem__(self, index: int) -> Region: ...On a second though, I guess it would be cleaner to implement a solution for any class inhereting from |
Err sorry I lost track of the context. Yes your explanation makes sense. So then we should just add a generic type hint to sliceable? That CRTP already captures the name of the instantiating class. |
|
If a generic type hint is possible, that'd be great. Unfortunately, I haven't found a way, though I stopped investigating after Gemini told me it couldn't be done. I have looked into using pattern files. Unfortunately, I ran into problems with the CMake rule that MLIR uses: part of the rule expects the pattern file to be a target name (i.e., without slashes), while other parts expect it to be a path (which contains slashes). I experimented with some work-around and run into a limitation of nanobind, which doesn't allow to add type annotations; pattern files today only replace existing ones. I have created wjakob/nanobind#1235 to overcome this, though. TL;DR: If someone (not me 😞) manages to make the generic type hints for |
|
Does |
1 similar comment
|
Does |
by generic i just mean parameterized by the CRTP instantiator. I can do it later today. |
|
prototype here #170551 |
Unfortunately, that doesn't work because it can only be used for functions created by nanobind and the functions in question are not only not created by nanobind but not even |
--> #170627 |
This a reland of #155741 which was reverted at #157831. This version is narrower in scope - it only turns on automatic stub generation for
MLIRPythonExtension.Core._mlirand does not do anything automatically. Specifically, the only CMake code added toAddMLIRPython.cmakeis themlir_generate_type_stubsfunction which is then used only in a manual way. The API formlir_generate_type_stubsis:Downstream users should use
mlir_generate_type_stubsin coordination withdeclare_mlir_python_sourcesto 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.