Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
mlir/lib/Bindings/Python/IRAttributes.cpp | ||
---|---|---|
332 | Please put DefaultingPyMlirContext as the last argument. | |
333 | We shouldn't expose this C-level API to Python. Consider Python buffer protocol, https://pybind11.readthedocs.io/en/stable/advanced/pycpp/numpy.html#buffer-protocol, which is already used in DenseElementsAttrs here, for example, https://github.com/llvm/llvm-project/blob/main/mlir/lib/Bindings/Python/IRAttributes.cpp#L367. Accepting a buffer of bytes and failing on the rest is likely enough. |
PTAL
mlir/lib/Bindings/Python/IRAttributes.cpp | ||
---|---|---|
333 | So your idea is to remove this get method? |
mlir/lib/Bindings/Python/IRAttributes.cpp | ||
---|---|---|
333 | No, what I am suggesting is to use proper APIs and types. using an integer and a pointer is not how one is supposed to pass around a string in Python. Take a string with data here or, better, take something like bytes or bytearray as it better reflects the purpose of opaque attributes. For the latter, you may need to use the buffer protocol. |
mlir/lib/Bindings/Python/IRAttributes.cpp | ||
---|---|---|
333 | Hi, I made changes accordingly, using py::buffer to pass string from python to C++ and also moving the PyMlirContext to the end. |
Please put DefaultingPyMlirContext as the last argument.