diff options
author | Peter Hawkins <phawkins@google.com> | 2025-01-22 09:26:44 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-01-22 06:26:44 -0800 |
commit | e30b703060bb6741fb5e5e05e6b37802bc29b4ce (patch) | |
tree | 524503d611b95db8956057fc30b7edda3ff52bcf /mlir/lib/Bindings/Python/IRModule.h | |
parent | d7fb4a275c98f4035d1083b5eb3edd2ffb2da00e (diff) | |
download | llvm-e30b703060bb6741fb5e5e05e6b37802bc29b4ce.zip llvm-e30b703060bb6741fb5e5e05e6b37802bc29b4ce.tar.gz llvm-e30b703060bb6741fb5e5e05e6b37802bc29b4ce.tar.bz2 |
[mlir:python] Construct PyOperation objects in-place on the Python heap. (#123813)
Currently we make two memory allocations for each PyOperation: a Python
object, and the PyOperation class itself. With some care we can allocate
the PyOperation inline inside the Python object, saving us a malloc()
call per object and perhaps improving cache locality.
Diffstat (limited to 'mlir/lib/Bindings/Python/IRModule.h')
-rw-r--r-- | mlir/lib/Bindings/Python/IRModule.h | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/mlir/lib/Bindings/Python/IRModule.h b/mlir/lib/Bindings/Python/IRModule.h index 2228b55..fd70ac7 100644 --- a/mlir/lib/Bindings/Python/IRModule.h +++ b/mlir/lib/Bindings/Python/IRModule.h @@ -705,8 +705,9 @@ public: /// Clones this operation. nanobind::object clone(const nanobind::object &ip); -private: PyOperation(PyMlirContextRef contextRef, MlirOperation operation); + +private: static PyOperationRef createInstance(PyMlirContextRef contextRef, MlirOperation operation, nanobind::object parentKeepAlive); |