[Mlir-commits] [mlir] [mlir] Add Python bindings for DenseResourceElementsAttr. (PR #66319)
Stella Laurenzo
llvmlistbot at llvm.org
Wed Sep 13 23:33:23 PDT 2023
================
@@ -997,6 +1022,56 @@ class PyDenseIntElementsAttribute
}
};
+class PyDenseResourceElementsAttribute
+ : public PyConcreteAttribute<PyDenseResourceElementsAttribute> {
+public:
+ static constexpr IsAFunctionTy isaFunction =
+ mlirAttributeIsADenseResourceElements;
+ static constexpr const char *pyClassName = "DenseResourceElementsAttr";
+ using PyConcreteAttribute::PyConcreteAttribute;
+
+ static PyDenseResourceElementsAttribute
+ getFromBuffer(py::buffer buffer, std::string name, PyType type,
+ DefaultingPyMlirContext contextWrapper) {
+ // Do not request any conversions as we must ensure to use caller
+ // managed memory.
+ int flags = 0;
+ Py_buffer view;
+ if (PyObject_GetBuffer(buffer.ptr(), &view, flags) != 0) {
+ throw py::error_already_set();
+ }
+ auto freeBuffer = llvm::make_scope_exit([&]() { PyBuffer_Release(&view); });
----------------
stellaraccident wrote:
(also fixed a datatype in this file that was causing numpy to log warnings about deprecated conversions)
https://github.com/llvm/llvm-project/pull/66319
More information about the Mlir-commits
mailing list