百科.dev
全部条目AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
M

mlir-tutorial

> 编程语言
开源

适用于初学者的 MLIR 教程

1.3K stars0 点赞0 次浏览
访问官网GitHub

工具介绍

适用于初学者的 MLIR 教程

MLIR For Beginners

This is the code repository for a series of articles on the MLIR framework for building compilers.

Articles

  1. Build System (Getting Started)
  2. Running and Testing a Lowering
  3. Writing Our First Pass
  4. Using Tablegen for Passes
  5. Defining a New Dialect
  6. Using Traits
  7. Folders and Constant Propagation
  8. Verifiers
  9. Canonicalizers and Declarative Rewrite Patterns
  10. Dialect Conversion
  11. Lowering through LLVM
  12. A Global Optimization and Dataflow Analysis
  13. Defining Patterns with PDLL

Bazel build

Bazel is one of two supported build systems for this tutorial. The other is CMake. If you're unfamiliar with Bazel, you can read the tutorials at https://bazel.build/start. Familiarity with Bazel is not required to build or test, but it is required to follow the articles in the tutorial series and explained in the first article, Build System (Getting Started). The CMake build is maintained, but was added at article 10 (Dialect Conversion) and will not be explained in the articles.

Note: This project has been upgraded to Bazel 8.3.1 and migrated to use Bzlmod for dependency management, replacing the traditional WORKSPACE file approach. Dependencies are now managed through MODULE.bazel using the Bazel Central Registry (BCR) where possible.

Prerequisites

Install Bazelisk via instructions at https://github.com/bazelbuild/bazelisk#installation. This should create the bazel command on your system.

You should also have a modern C++ compiler on your system, either gcc or clang, which Bazel will detect.

Bazel Version: This project requires Bazel 8.3.1 or newer. The specific version is pinned in .bazelversion.

Build and test

Run

bazel build ...:all
bazel test ...:all

Dependency Management

The project uses Bzlmod (MODULE.bazel) for dependency management:

  • Core dependencies: Managed through Bazel Central Registry (BCR)
    • rules_python, rules_java, protobuf, abseil-cpp, or-tools, etc.
  • LLVM dependencies: Managed through custom module extension
    • LLVM/MLIR source code via git repository
  • Development tools: hedron_compile_commands via git_override

This approach provides better dependency resolution, versioning, and compatibility compared to the legacy WORKSPACE approach.

CMake build

CMake is one of two supported build systems for this tutorial. The other is Bazel. If you're unfamiliar with CMake, you can read the tutorials at https://cmake.org/getting-started/. The CMake build is maintained, but was added at article 10 (Dialect Conversion) and will not be explained in the articles.

Prerequisites

  • Make sure you have installed everything needed to build LLVM https://llvm.org/docs/GettingStarted.html#software
  • For this recipe Ninja is used so be sure to have it as well installed https://github.com/ninja-build/ninja/wiki/Pre-built-Ninja-packages

Checking out the code

Checkout the tutorial including the LLVM dependency (submodules):

git clone --recurse-submodules https://github.com/j2kun/mlir-tutorial.git
cd mlir-tutorial

Building dependencies

Note: The following steps are suitable for macOs and use ninja as building system, they should not be hard to adapt for your environment.

Build LLVM/MLIR

…

Build and test

…

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

C++compilersmlirtutorial

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言