[all-commits] [llvm/llvm-project] d1fdb4: [MLIR][Python] Add method for getting the live ope...
John Demme via All-commits
all-commits at lists.llvm.org
Thu Feb 8 11:39:18 PST 2024
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: d1fdb416299c0efa5979ed989f7c1f39973dcb73
https://github.com/llvm/llvm-project/commit/d1fdb416299c0efa5979ed989f7c1f39973dcb73
Author: John Demme <john.demme at microsoft.com>
Date: 2024-02-08 (Thu, 08 Feb 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 (#78663)
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