# MLIR News, 4th edition (4/3/2020)

**URL:** <https://discourse.llvm.org/t/mlir-news-4th-edition-4-3-2020/755>\
**Category:** Newsletter\
**Created:** [March 21, 2020, 4:48am UTC](https://discourse.llvm.org/t/mlir-news-4th-edition-4-3-2020/755 "2020-03-21T04:48:20Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mehdi\_amini](https://sea1.discourse-cdn.com/flex021/user_avatar/discourse.llvm.org/mehdi_amini/32/25595_2.png) [@mehdi\_amini](https://discourse.llvm.org/u/mehdi_amini)\
**Post date:** [March 21, 2020, 4:48am UTC](https://discourse.llvm.org/t/mlir-news-4th-edition-4-3-2020/755/1 "2020-03-21T04:48:20Z")

</div>

Welcome to the fourth issue of the MLIR (bi)Weekly, a newsletter (published on Friday) covering developments in MLIR, and related projects in the ecosystem. MLIR (bi)Weekly is brought to you by a collective effort of contributors, we welcome your contributions!

See the [previous published edition](http://discourse.llvm.org/t/mlir-news-3rd-edition-3-20-2020/670).

# Highlights

- [PyMLIR](https://github.com/spcl/pymlir) is a “full Python interface to parse, process, and output MLIR files”. It does not provide any bindings to MLIR nor depends on MLIR: it is a complete reimplementation of the generic MLIR parser in Python/Lark.
- A new [declarative pass specification](https://mlir.llvm.org/docs/WritingAPass/#declarative-pass-specification) is added: we’re moving away for the static global pass registration (and in general aim to have `mlir/lib/...` entirely [free of static global initializers](https://bugs.llvm.org/show_bug.cgi?id=45437) soon)
- An [example of creating your own dialect](https://github.com/llvm/llvm-project/commit/160f5aa65fac) as an out-of-tree CMake project has been added.
- A new page on the website provides [Debugging Tips](https://mlir.llvm.org/getting_started/Debugging/)

# MLIR Core

### Infrastructure

- `mlir-print-op-on-diagnostic` [defaults to true](https://reviews.llvm.org/rG79afdfab9a57) now (fix [pr44830](https://llvm.org/pr44830): this addresses a common user trap to think that the location printed along with the diagnostic is the same as the current operation that caused the error.
- Pass Infrastructure Refactoring: CRTP is being removed from the Pass hierarchy, making the class interface much cleaner.
- Dominance gets a new [utility function](https://github.com/llvm/llvm-project/commit/86bbbb317bce06e4a8cd084c85663b10147eff65) to find the nearest common dominator of two given blocks.
- The dialect conversion infrastructure now supports [block creation in ConversionPatternRewriter](https://github.com/llvm/llvm-project/commit/f27f1e8c27b1).
- Documentation cleanup:
  - Dialect documentation now contains information on assembly format, successors, regions, and saw an overall cleanup.
  - Passes.md now includes all of the registered passes in MLIR (though many are unfortunately missing detailed descriptions)
  - The [documentation on canonicalization](https://mlir.llvm.org/docs/Canonicalization/) now discusses the different canonicalization mechanisms and how to use them.
  - The MLIR website now supports .md includes, which allows to mix static doc with generated one. For example the SPIR-V dialect [static .md source](https://github.com/llvm/llvm-project/blob/master/mlir/docs/Dialects/SPIR-V.md#operation-definitions) includes the generated documentation for the operations to produce a unified [online doc](https://mlir.llvm.org/docs/Dialects/SPIR-V/). Other dialects are entirely generated from the ODS definition.

### Table-driven Infrastructure

- A new [declarative pass specification](https://mlir.llvm.org/docs/WritingAPass/#declarative-pass-specification)(i.e. tablegen backend) is being added. Several revisions are still inflight and should land early next week. Having a declarative description for the passes provides multiple benefits:
  - We can generate the pass documentation for the command line and for website or any other medium from the same source.
  - We can generate the registration for the passes and we won’t have any static global constructor to manage pass registration anymore (porting MLIR pass options mechanism to LLVM would make [some users happy](https://twitter.com/thegreatbeanz/status/1243546488485097475) I think).
  - The pass options being declaratively defined allows to generate a base class for each pass, it reduces the boilerplate for the user.

- ODS now supports [variadic regions](https://reviews.llvm.org/rG0359b86d8bb24a7bcd37dc6126baee303bc6c939)

### Code Generation & Optimizations

- LoopToStandard now [supports if/else results](https://github.com/llvm/llvm-project/commit/340e1b20779ebeb93f681689a345217672a308e3).
- The emission of wrappers around C interface is now controlled by a [function attribute](https://github.com/llvm/llvm-project/commit/add9f1a5dc1963149dac4cb8b25bf2cb825a02c2).
- LLVMFuncOp can now [pass opaque attributes through to LLVM](https://github.com/llvm/llvm-project/commit/0a2131b7e2213fc8b45f7ff1e02f29fb4d544259). See the IREE section for an example of how the it is used to brings 50% improvements on a `skylake-avx512` benchmark!
- The bitwidth of the `index` type is [now configurable](https://github.com/llvm/llvm-project/commit/ac9d742bbe4f) when lowering to LLVM.
- LoopToStandard conversion supports now [“if/else” with results](https://github.com/llvm/llvm-project/commit/340e1b20779ebeb93f681689a345217672a308e3)
- Introduction of a utility to [separate full tiles from partial tiles](https://github.com/llvm/llvm-project/commit/43a95a543fbb1ed4b3903e88ce291444d4970f5a) when tiling affine loop nests where trip counts are unknown or where tile sizes don’t divide trip counts.
- Linalg
  - Linalg starts to get support for “named ops”:
    - The idea is to define ops using a “Tensor-Comprehension-like” specification (see [RFC](http://discourse.llvm.org/t/rfc-declarative-named-ops-in-the-linalg-dialect/745/7)
    - A first implementation for generating ODS for Linalg op from such representation is up [for review](https://reviews.llvm.org/D77067).

  - Fusion has been extended to support [WAW on buffers](https://reviews.llvm.org/D76897)
  - Pooling for [min/max/sum ops](https://reviews.llvm.org/D76414) has been added
  - Lowering to libraries now [takes advantage](https://github.com/llvm/llvm-project/commit/e33a636e26349bf42557908766911654d60cb6c0) of the function attribute to control C wrapper.

### SPIR-V

- Documentation for SPIR-V dialect is consolidated into one [page ([SPIR-V Dialect - MLIR](https://mlir.llvm.org/docs/Dialects/SPIR-V/)) now (see the `Infrastructure` section above).
- `mlir-vulkan-runner` now [supports 3D memref](https://github.com/llvm/llvm-project/commit/0718e3ae31b0).

# In the Ecosystem

### [IREE](https://github.com/google/iree) : An Experimental MLIR Execution Environment

- A new [website and roadmap](https://google.github.io/iree/DesignRoadmap) is getting started!
- Improved “[getting started](https://github.com/google/iree/blob/master/docs/getting_started.md)” documentation pages.
- Compiling with dynamic shapes:
  - First e2e compile and run of a [simple computation](https://github.com/google/iree/blob/98a14995b7041953938617ce53a70bca293f8201/bindings/python/pyiree/rt/vm_test.py#L38) with dynamic shapes (from Python/numpy).
  - [Implemented](https://github.com/google/iree/commit/98a14995b7041953938617ce53a70bca293f8201) dynamic dim and rank from custom ops, allowing a TF/Keras LSTM to compile for the first time (has some minor runtime bugs still in the list module)
  - Concluded a lot of misc work to get shape types plumbed through everything for the VMLA path. Next need to apply to LLVM/SPIR-V backends.
  - Working on model by model triage to source further gaps.

- IRModelBuilder llvm.matrix intrinsic based benchmark[makes proper use of LLVM function attribute](https://github.com/google/iree/commit/6c5a34ff29d405b0630a6ce1a5d4e07bde90abdf) `passthrough = [["prefer-vector-width", "512"]]`. Brings 50% improvements on the 16^3 case on `skylake-avx512`.

# Recent Talks

- The Tile Dialect used in [PlaidML](https://github.com/plaidml/plaidml/tree/plaidml-v1) was presented at the MLIR weekly ODM ([slides](https://drive.google.com/open?id=1uud3MGsC5Pc2VvqtsV57AjSrIoW5ZpVm) - [recording](https://drive.google.com/open?id=1Ely0XjuQ3HJo6Is9RY08Ef3QvVFryiPE))
