[Mlir-commits] [mlir] [MLIR] Auto generate source location for python bindings (PR #112923)
Maksim Levental
llvmlistbot at llvm.org
Fri Oct 18 10:41:47 PDT 2024
makslevental wrote:
I have a version of this in [mlir-python-extras](https://github.com/makslevental/mlir-python-extras/blob/main/mlir/extras/util.py#L50-L74).
It roughly looks the same so not many comments on impl but what I'll say is that I've found there's no way to make this robust because of how floppy both python control flow and the module system can be; did you know you can create objects that walk/talk like a real module out of [thin air](https://github.com/makslevental/mlir-python-extras/blob/main/mlir/extras/dialects/ext/transform.py#L25-L64)? Those "modules" will have no `filename` attribute. I suspect Jax people will hate this because their whole stacker interpreter thing...
In addition both the `frame_info` API is not stable and won't be so e.g., in this PR you'll at least need the same `sys.version_info.minor >= 11` check I have.
[Testing is also quite annoying](https://github.com/makslevental/mlir-python-extras/blob/de95702ebc2663d3674a5123f858eb75b4473a3f/tests/test_location_tracking.py) because of line numbers moving around due to imports.
Unforuntately, despite how nice it would be to have this feature, I would not recommend this get merged.
https://github.com/llvm/llvm-project/pull/112923
More information about the Mlir-commits
mailing list