Skip to content

Conversation

@adam-smnk
Copy link
Contributor

Adds a utility for manual memory management of memref buffers across Python and jitted MLIR modules.

Explicit memory management becomes required when an MLIR function returns a newly allocated buffer e.g., results of a computation. This can become a complex task due to difference in memory models between Python and the MLIR runtime allocators.
By default, returned MLIR buffers' lifetime cannot be automatically managed by the Python environment.

The Python memref manager aims to address the following challenges:

  • use of the same runtime allocators as a jitted MLIR module for consistent memory management
  • lean abstraction using memref descriptors directly
  • buffers usable both by Python and jitted MLIR modules

Current implementation assumes that memref allocation ops are lowered to standard C functions, like 'malloc' and 'free', which are preloaded together with the Python process.

@adam-smnk
Copy link
Contributor Author

The example could be refactored into a proper test once we settle down on a testing strategy.
For now, just added to CI to run.

Copy link
Contributor

@rolfmorel rolfmorel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks interesting! Here's a first pass.

Adds a utility for manual memory management of memref buffers across
Python and jitted MLIR modules.

Explicit memory management becomes required when an MLIR function
returns a newly allocated buffer e.g., results of a computation.
This can become a complex task due to difference in memory models
between Python and the MLIR runtime allocators.
By default, returned MLIR buffers' lifetime cannot be automatically
managed by the Python environment.

The Python memref manager aims to address the following challenges:
  - use of the same runtime allocators as a jitted MLIR module for
    consistent memory management
  - lean abstraction using memref descriptors directly
  - buffers usable both by Python and jitted MLIR modules

Current implementation assumes that memref allocation ops are lowered
to standard C functions, like 'malloc' and 'free', which are preloaded
together with the Python process.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants