Yes, your evaluation goes in the right direction.
Op::build methods are different for all operations and, furthermore, they are called indirectly through
OpBuilder::create function template. Users are not expected to call
*Op::build APIs themselves. In C++, we rely on templates to forward arguments from
OpBuilder::create to the relevant
Op::build function, but it is unclear how this can be achieved in Python.
Also, many of the Ops are generated from ODS (https://mlir.llvm.org/docs/OpDefinitions/), which we could try and use for generating Python bindings as well.
And I can’t find MLIR python bindings examples in the llvm-project, could I have a demo to try out the python bindings?
We only explored it, there is no publicly available code for the bindings, hence the open project.
Please consider also looking at different ways of exposing the bindings as @joker-eph mentioned
LLVM is exposing a C API that is then wrapped in python using ctypes. But there are other possibilities, for example LLDB is using swig. More recent approaches include clif and pybind11.
we experimented with pybind11 because that was the one we knew best.