M
Modular5mo ago
Ryulord

MLIR Docs

I've tried checking out the official MLIR website as well as the OurBool notebook but can't seem to find any info on certain bits of MLIR used in Mojo. e.g. lit and kgen are dialects used in the Mojo compiler if I understand correctly but they aren't documented anywhere I can find. Am I missing something or does Modular have some in house dialects that aren't publicly documented? Any plans to document them if so?
MLIR
Multi-Level IR Compiler Framework
9 Replies
Darkmatter
Darkmatter5mo ago
I haven’t found anything either and I’d like to second this request. Even just the autogenerated docs that show the ops and constants. I know it’s WIP, but if there are replacements for much of the public MLIR then we should be using those instead of writing our own worse version. As an example, the power of 2 constrain on SIMD doesn’t apply to ARM SVE, and I’ve wanted to look at removing that restriction and making SIMD do drain loops for the user for a while. Without knowing if there is a good way to encode SVE in Mojo MLIR or something the compiler can rewrite into Mojo MLIR, this is difficult to do.
Ehsan M. Kermani (Modular)
Those are part of Modular's internals. It's an ongoing effort to limit their mentions in docs.
Ryulord
RyulordOP5mo ago
Any reason this is the case? Inline MLIR is an interesting feature of Mojo but currently it's hard to really do anything with it due to lack of documentation.
Melody Daniel
Melody Daniel5mo ago
It's part of the compiler and the compiler is not open source When (or if) it's opened, I expect we'll see it opened with associated docs - assuming the entire compiler team are not gigachads that code with the entire MLIR architecture in their head.
Ryulord
RyulordOP5mo ago
There have been statements in the past like (paraphrasing) "things you'd normally need a compiler engineer for in Mojo you can just have an ordinary programmer do because you can just write inline MLIR". Statements like this seem odd if the MLIR you need to use is really part of the compiler
sora
sora5mo ago
The Mojo compiler "backend" consumes internal dialects such as pop, kgen, and lit, which can be considered part of the compiler, depending on your perspective. However, it does support standard dialects like index and llvm. For instance, consider the implementation of abort:
@no_inline
fn abort():
__mlir_op.`llvm.intr.trap`()
@no_inline
fn abort():
__mlir_op.`llvm.intr.trap`()
Rather than creating a built-in intrinsic (like in Rust), we implement it using inline MLIR. So I guess the claim is largely™️ true.
Ryulord
RyulordOP5mo ago
yeah I guess it being considered part of the compiler or not is just semantics and not irrelevant. It's just a case of if Modular wants to document it or not and why. You can kinda figure out bits of what's going on through error messages and things so I doubt they consider it a well guarded secret the way the would with other stuff they haven't opened up
Darkmatter
Darkmatter5mo ago
I've had the compiler lose its mind at me when I try to use llvm ops and then get Mojo types back out. Some documentation there would be appreciated.
Melody Daniel
Melody Daniel5mo ago
Er, maybe. Though I imagine you have it wrong. If the MLIR dialect already exist, and you have the documentation for internal compiler dialects, then it may be possible for an ordinary programmer to integrate these two together without writing all the associated compiler machinery
Want results from more Discord servers?
Add your server