[all-commits] [llvm/llvm-project] 8becc6: [MLIR][Python] Add method for getting the live ope...
John Demme via All-commits
all-commits at lists.llvm.org
Thu Jan 18 19:10:23 PST 2024
Branch: refs/heads/users/teqdruid/mlir/python-liveobjects
Home: https://github.com/llvm/llvm-project
Commit: 8becc6ac237972ba9e9f1ccebf97362d87034348
https://github.com/llvm/llvm-project/commit/8becc6ac237972ba9e9f1ccebf97362d87034348
Author: John Demme <john.demme at microsoft.com>
Date: 2024-01-19 (Fri, 19 Jan 2024)
Changed paths:
M mlir/lib/Bindings/Python/IRCore.cpp
M mlir/lib/Bindings/Python/IRModule.h
M mlir/python/mlir/_mlir_libs/_mlir/ir.pyi
M mlir/test/python/ir/module.py
Log Message:
-----------
[MLIR][Python] Add method for getting the live operation objects
Currently, a method exists to get the count of the operation objects
which are still alive. This helps for sanity checking, but isn't
terribly useful for debugging. This new method returns the actual
operation objects which are still alive.
This allows Python code like the following:
```
gc.collect()
live_ops = ir.Context.current._get_live_operation_objects()
for op in live_ops:
print(f"Warning: {op} is still live. Referrers:")
for referrer in gc.get_referrers(op)[0]:
print(f" {referrer}")
```
More information about the All-commits
mailing list