Multi-Level Intermediate Representation (MLIR) is a novel compiler infrastructure that aims to provide modular and extensible components to facilitate building domain specific compilers. However, since MLIR models programs at an intermediate level of abstraction, and most extant frontends are at a very high level of abstraction, the semantics and mechanics of the fundamental transformations available in MLIR are difficult to investigate and employ in and of themselves. To address these challenges, we have developed \texttt{nelli}, a lightweight, Python-embedded, domain-specific, language for generating MLIR code. \texttt{nelli} leverages existing MLIR infrastructure to develop Pythonic syntax and semantics for various MLIR features. We describe \texttt{nelli}'s design goals, discuss key details of our implementation, and demonstrate how \texttt{nelli} enables easily defining and lowering compute kernels to diverse hardware platforms.
翻译:多级中间表示(MLIR)是一种新型编译器基础设施,旨在提供模块化且可扩展的组件,以促进领域特定编译器的构建。然而,由于MLIR在中间抽象层次上对程序进行建模,而大多数现有前端处于非常高的抽象层次,因此MLIR中可用基本变换的语义和机制本身难以研究和运用。为应对这些挑战,我们开发了\texttt{nelli},一种轻量级、嵌入Python的领域特定语言,用于生成MLIR代码。\texttt{nelli}利用现有MLIR基础设施,为各种MLIR特性开发了符合Python风格的语法和语义。我们阐述了\texttt{nelli}的设计目标,讨论了实现的关键细节,并演示了\texttt{nelli}如何使定义计算核并将其降级到不同硬件平台变得简单易行。