[llvm-dev] Google’s TensorFlow team would like to contribute MLIR to the LLVM Foundation

Mehdi AMINI via llvm-dev llvm-dev at lists.llvm.org
Sat Sep 14 12:01:57 PDT 2019


On Thu, Sep 12, 2019 at 9:50 AM David Greene <greened at obbligato.org> wrote:

> Mehdi Amini <aminim at google.com> writes:
>
> > The MLIR LangRef corresponds to the former part only, because this is
> what
> > is common to all dialects. On the other hand, each dialect will need to
> > provide its own LangRef equivalent (for example I linked to the Affine
> > dialect doc before).
> >
> > Does it make sense?
>
> Yeah, it makes perfect sense.  I think maybe reading the document I got
> caught up in the BNF grammar -- it's a bit distracting.  I've not seen a
> similar BNF specification for LLVM IR.  It may exist somewhere, but BNF
> isn't part of any LLVM document I've read.  :) Maybe the grammar bits
> could be factored out into a formal specification and LangRef could be a
> little more informal.
>
> Just suggestions, obviously.


That's a good one, we should look into outlining the grammar to make this
more friendly to read.

Another things that I just remember now about documentation is that we
don't expect dialects to write a "LangRef" that describe each operation.
Instead we use a table-driven approach for defining operation
<https://github.com/tensorflow/mlir/blob/master/g3doc/OpDefinitions.md#table-driven-operation-definition-specification-ods>
and
we generate both the C++ classes and the documentation from there (this
helps keeping documentation up-to-date as well!).

>From a local build directory of MLIR, you can try:

  {BUILD}/bin/mlir-tblgen -gen-op-doc {SRC}/Dialect/StandardOps/Ops.td -I
{SRC}/include/ > std.md

(try --gen-op-defs and --gen-op-decls for the C++ code)

I pushed these here for your convenience:
https://github.com/joker-eph/mlir-docs/

See for example the definition for alloc:
https://github.com/tensorflow/mlir/blob/master/include/mlir/Dialect/StandardOps/Ops.td#L124

>From there here is:
- the generated documentation:
https://github.com/joker-eph/mlir-docs/blob/master/std.md#stdalloc-allocop
- the C++ class declaration for this operation:
https://github.com/joker-eph/mlir-docs/blob/master/std.h#L130
- and the implementation:
https://github.com/joker-eph/mlir-docs/blob/master/std.cpp#L285

Of course we need to improve the content in general, but I expect the
incentive to do so to grow assuming we can get a space like
http://llvm.org/mlir ; at which point we could organize the MLIR overall
online doc structure to include these generated file continuously.

Best,

-- 
Mehdi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190914/b75ba3bb/attachment.html>


More information about the llvm-dev mailing list