Parser in PYBIND and C++ library

Hello everyone, I am not very familiar with Pybind 11 about MLIR.
I often use ParseSourceFile function to parse my IR files. I have modified the ParseType file in QuantDialect and achieved success. However, the Parser function in Pybind (, self.ctx))does not recognize my modifications. whether Pybind is different from the C++ parsing library?
BUG Info:

self.module =, self.ctx)
mlir._mlir_libs.MLIRError: Unable to parse module assembly:
error: "-":6:152: illegal storage type prefix
error: "-":6:152: illegal storage type prefix

What is the code at this location? Maybe provide the IR that triggers this issue?
There is no magic in the bindings…

Hello, it’s nice to see your reply again. I talked to you a long time ago about the ParseSourceFile function, which was very helpful to me.

I am well aware of this error and the reason for its occurrence.

In fact, I modified the UniformQuantizedType storage type support in Quant Dialect. Due to the ParseSourceFile needing to parse the new StorageType, I synchronously modified the TypeParser in Quant Dialect. Yes, I successfully obtained the module object through the ParseSourceFile function.

My problem is that when I used the Pybind interface to call Parser to parse my IR, it couldn’t recognize my modifications to TypeParser in Quant Dialect. Therefore, I gained a understanding of Parser in Pybind and seemed to have also called the ParseSourceFile function to further call TypeParser in Quant Dialect, but failed to achieve the expected results. I became curious about the library in bind and was it independent?Currently, I only see one static link library, libMLIRQuantDialect. a

The most likely explanation is that you haven’t relinked the pybind extensions (which on my system is shared in libraries that I can find in build/tools/mlir/python_packages), how did you rebuild after your change?

There are some differences in my rebuild method. I chose to compile in LLVM and replace the successfully compiled static library with another project. Based on your suggestion, I replaced all the files under the package. I succeeded, thank you very much, but I am still a bit confused. It seems that pybind Parser did not directly call libMLIRQuantDialect.a?What is the relationship between pybind extensions and libMLIRQuantDialect.a?

A .a library is a static archive that contains object files. It is only ever used as an input to the linker to produce either an executable or a shared library (.so). (I’m simplifying and assuming a Linux platform here)

Python modules (when not pure python) are always shared library, this is no different here: our pybind will be linked into a shared library (.so) which either link to something like (which will be produced by linking the other .a MLIR libraries) or by linking the MLIR .a into the binding .so itself if monolithic (there are various way to setup the build)

You may use ldd <path>/<binding lib>.so to see what it is linked to.