def matmul(A,B):
for row in range(rows):
for col in range(cols):
for elt in range(len(B)):
C[row, col] += A[row, elt] * B[elt, col]
return C
Is there any?
[PS: I am not searching for solutions like numba, or similar kind. I want to emit MLIR from plain simple python syntax. The example codes are explanation purpose]
@webmiche That’s an wonderful suggestion
This project uses python for MLIR dev. I wonder if there are more projects like this… Probably using C++/tablegen…
In particular, the xDSL Frontend project might be worth checking out by @george and @AlexanderViand (@AlexanderViand-Intel nowadays I guess). This project has a similar aim as Nelli, but it tries to be a bit more extendable with new dialects, AFAIU.
Also, one could probably connect this easily to the new xDSL Interpreter to make code executable through xDSL, if that is interesting to you
This is quite misleading IMO: while xDSL it is a convenient way to experiment in pure Python and is somehow a “Python clone of MLIR”. But it isn’t connect to MLIR (still?), does not use MLIR right now, and so isn’t a comparable answer to Nelli when it comes down “I want to emit MLIR from Python”.
I was talking about the xDSL Frontend project, a “sub-project” of xDSL. Sorry for being unclear on this. From the Frontend README:
The goal of the front-end framework is to allow users to:
1. Write non-SSA xDSL/MLIR programs in Python (or Pythonic DSL).
2. Mix-in real Python code (limited functionality is supported).
3. Compile programs to xDSL (and subsequently to MLIR).
I agree that xDSL itself is not actually an answer to the actual questions, that’s why I did not mention it in my first reply
The xDSL Frontend project is unfortunately not under active development at the moment, but you might want to have a look at MLL which was presented at the LLVM Developer Meeting a few weeks ago:
I wonder what’s the status of https://github.com/xdslproject/xdsl/blob/main/docs/mlir_interoperation.md?
There’s a mention of “the mirrored dialects found in xdsl/dialects (arith, builtin, cf, func, llvm, memref, and scf)” which suggests there’s a degree of interoperability, although from that document it’s not clear whether the “input.mlir” in the example was obtained directly from xDSL mapping to MLIR or not.
xDSL fundamentally interoperates in a textual way with MLIR, so essentially, you print the IR in xDSL and reparse it in MLIR (or vice-versa). The input.mlir file is just a hand-written example IR, but we have used this in actual compilation flows. Though, I think this is not the place to expand too far on xDSL. If you are curious, feel free to join the xDSL Zulip Chat.