[llvm] [mlir] [MLIR][Python] reland (narrower) type stub generation (PR #157930)
Maksim Levental via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 19 04:25:43 PDT 2025
makslevental wrote:
> > I had to add a lot of signatures by hand using `MAKE_MLIR_PYTHON_QUALNAME` (the ones I mentioned above, where either the args or returns are the opaque structs).
>
> I was wondering the shortened names can't be handled with a [patterns file](https://nanobind.readthedocs.io/en/latest/typing.html#pattern-files). The doc describes a `\from` construct that can be used to import other types with aliases. My idea was to `import my_mlir_package.ir` such that `ir.Type` works but I never tried. Couldn't we import the most important types that way to save some of the manual handling with `MAKE_MLIR_PYTHON_QUALNAME`?
The patterns file doesn't work like how it looks like it works - the string that is matched is the name of the method/function instead of the type. So if we did it with a pattern file we'd have almost exactly the same number of patterns as `nb::sigs`. I realized what I should do is just actually change the signatures to be in terms of the `Py*` types instead of disguising the opaque structs as the corresponding `Py*` type.
https://github.com/llvm/llvm-project/pull/157930
More information about the llvm-commits
mailing list