- Interops with Python buffers/numpy arrays to create.
- Also cleans up 'get' factory methods on some types to be consistent.
- Adds mlirAttributeGetType() to C-API to facilitate error handling and other uses.
- Punts on a lot of features of the ElementsAttribute hierarchy for now.
- Does not yet support bool or string attributes.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
mlir/lib/Bindings/Python/IRModules.cpp | ||
---|---|---|
1052 | It's a fairly complicated API to use with all options exposed, and I wanted the default "import from array" case to just work without a lot of fiddling for a dominant case. I'll add a TODO to add optional args to control which shaped type gets used. I'll also extend the docs. | |
mlir/test/Bindings/Python/ir_array_attributes.py | ||
8 | Currently, yes. I'll address any issues here even we enable this by default in the build. |
mlir/lib/Bindings/Python/IRModules.cpp | ||
---|---|---|
930 | Now it seems that the view is freed correctly only when the calling PyObject_GetBuffer fails. But successful calls to PyObject_GetBuffer have no paired with calls to PyBuffer_Release when the attribute object ends its lifetime, I think it may cause resource leaks. |
mlir/lib/Bindings/Python/IRModules.cpp | ||
---|---|---|
930 | Nice to be looking for it, but in this case it is safe because the py::buffer_info constructor defaults to stealing the Py_buffer* and will free it upon going out of scope. Fwiw, I'm using a relatively unconventional way of getting the buffer_info here, resorting to the underlying C functions because I want to cast it to specific constraints so that I know it will line up with the memory format for constructing dense elements attributes. A lot of code that accesses a buffer doesn't do this and you won't see these extra coercions and error checking. |
Now it seems that the view is freed correctly only when the calling PyObject_GetBuffer fails. But successful calls to PyObject_GetBuffer have no paired with calls to PyBuffer_Release when the attribute object ends its lifetime, I think it may cause resource leaks.