aboutsummaryrefslogtreecommitdiff
path: root/mlir/lib/Bindings/Python/IRModule.h
diff options
context:
space:
mode:
authorPeter Hawkins <phawkins@google.com>2025-01-22 09:26:44 -0500
committerGitHub <noreply@github.com>2025-01-22 06:26:44 -0800
commite30b703060bb6741fb5e5e05e6b37802bc29b4ce (patch)
tree524503d611b95db8956057fc30b7edda3ff52bcf /mlir/lib/Bindings/Python/IRModule.h
parentd7fb4a275c98f4035d1083b5eb3edd2ffb2da00e (diff)
downloadllvm-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.h3
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);