Parse custom attribute in python bindings

Hi all,
I defined a custom attribute, and use default table-gened printer and parser. And I built the python bindings, and also expose the CAPI of the custom attribute. If I load the whole mlir file and parse it to python module, the custom attribute can be correctly printed.

However, if I build the custom attribute in python and use python print to print it. an error occurs say that

“dialect has no registered attribute printing hook”

why is this happening?

This looks quite surprising: have you built MLIR with assertions enabled?

This looks quite surprising: have you built MLIR with assertions enabled?

@mehdi_amini Thanks for the reply. yes, I built mlir with -DLLVM_ENABLE_ASSERTIONS=ON.

Is this for a custom attribute added to an upstream dialect or to your own dialect in a repo that builds outside of LLVM/MLIR?

@bondhugula Thank you for answering! It is in my own dialect.