# canonicalization

Published articles for canonicalization.

This is one page of public article previews, not the complete archive. Follow Next page to continue. Summaries are not the original full articles.

## MLIR -- Canonicalizers and Declarative Rewrite Patterns

DevFeed: [MLIR -- Canonicalizers and Declarative Rewrite Patterns](<https://devfeed.tech/articles/mlir-canonicalizers-and-declarative-rewrite-patterns-40477.md>)

Original publisher: [Read original article](<https://www.jeremykun.com/2023/09/20/mlir-canonicalizers-and-declarative-rewrite-patterns/>)

Published: 2023-09-20T08:00:00Z

Content type: tutorial

Language: en

Sources: [Jeremy Kun](<https://devfeed.tech/sources/jeremy-kun.md>)

Topics: [Code](<https://devfeed.tech/topics/code.md>), [C++](<https://devfeed.tech/topics/c-plus-plus.md>), [Development](<https://devfeed.tech/topics/development.md>)

Tags: [c-plus-plus](<https://devfeed.tech/tags/c-plus-plus.md>), [canonicalization](<https://devfeed.tech/tags/canonicalization.md>), [compilers](<https://devfeed.tech/tags/compilers.md>), [complex-numbers](<https://devfeed.tech/tags/complex-numbers.md>), [declarative](<https://devfeed.tech/tags/declarative.md>), [deprecated](<https://devfeed.tech/tags/deprecated.md>), [maintenance](<https://devfeed.tech/tags/maintenance.md>), [mathematics](<https://devfeed.tech/tags/mathematics.md>), [mlir](<https://devfeed.tech/tags/mlir.md>), [polynomials](<https://devfeed.tech/tags/polynomials.md>), [primer](<https://devfeed.tech/tags/primer.md>), [programming](<https://devfeed.tech/tags/programming.md>), [rewrite](<https://devfeed.tech/tags/rewrite.md>), [tablegen](<https://devfeed.tech/tags/tablegen.md>), [test](<https://devfeed.tech/tags/test.md>)

### AI overview

This tutorial explains how to implement general canonicalization patterns in MLIR. It covers both C++ canonicalizers and declarative rewrite rules in TableGen, including an identity-based polynomial rewrite and its testing considerations.

### Source excerpt

Table of Contents In a previous article we defined folding functions, and used them to enable some canonicalization and the sccp constant propagation pass for the poly dialect. This time we'll see how to add more general canonicalization patterns. The code for this article is in this pull request, and as usual the commits are organized to be read in order. Why is Canonicalization Needed? MLIR provides folding as a mechanism to simplify an IR, which can result in simpler, more efficient ops (e.

## MLIR -- Verifiers

DevFeed: [MLIR -- Verifiers](<https://devfeed.tech/articles/mlir-verifiers-40475.md>)

Original publisher: [Read original article](<https://www.jeremykun.com/2023/09/13/mlir-verifiers/>)

Published: 2023-09-13T09:00:00Z

Content type: tutorial

Language: en

Sources: [Jeremy Kun](<https://devfeed.tech/sources/jeremy-kun.md>)

Topics: [mlir](<https://devfeed.tech/topics/mlir.md>), [Code](<https://devfeed.tech/topics/code.md>), [Pull Request](<https://devfeed.tech/topics/pull-request.md>)

Tags: [article](<https://devfeed.tech/tags/article.md>), [c-plus-plus](<https://devfeed.tech/tags/c-plus-plus.md>), [canonicalization](<https://devfeed.tech/tags/canonicalization.md>), [code](<https://devfeed.tech/tags/code.md>), [compilers](<https://devfeed.tech/tags/compilers.md>), [mathematics](<https://devfeed.tech/tags/mathematics.md>), [mlir](<https://devfeed.tech/tags/mlir.md>), [operations](<https://devfeed.tech/tags/operations.md>), [pass](<https://devfeed.tech/tags/pass.md>), [primer](<https://devfeed.tech/tags/primer.md>), [programming](<https://devfeed.tech/tags/programming.md>), [pull-request](<https://devfeed.tech/tags/pull-request.md>), [safety](<https://devfeed.tech/tags/safety.md>), [types](<https://devfeed.tech/tags/types.md>)

### AI overview

This tutorial explains how to add verifiers to an MLIR dialect. Verifiers check that types and operations are well-formed before and after passes, enforcing operation invariants and allowing passes to avoid repeated edge-case checks. It also describes trait-based verification, generated type-checking and inference support, assembly-format simplification, builders, and related test updates.

### Source excerpt

Table of Contents Last time we defined folders and used them to enable some canonicalization and the sccp constant propagation pass for the poly dialect. This time we'll add some additional safety checks to the dialect in the form of verifiers. The code for this article is in this pull request, and as usual the commits are organized to be read in order. Purpose of a verifier Verifiers ensure the types and operations in a concrete MLIR program are well-formed.

## MLIR -- Folders and Constant Propagation

DevFeed: [MLIR -- Folders and Constant Propagation](<https://devfeed.tech/articles/mlir-folders-and-constant-propagation-40474.md>)

Original publisher: [Read original article](<https://www.jeremykun.com/2023/09/11/mlir-folders/>)

Published: 2023-09-11T08:00:00Z

Content type: tutorial

Language: en

Sources: [Jeremy Kun](<https://devfeed.tech/sources/jeremy-kun.md>)

Topics: [Code](<https://devfeed.tech/topics/code.md>), [Computing](<https://devfeed.tech/topics/computing.md>), [Pull Request](<https://devfeed.tech/topics/pull-request.md>)

Tags: [article](<https://devfeed.tech/tags/article.md>), [c-plus-plus](<https://devfeed.tech/tags/c-plus-plus.md>), [canonicalization](<https://devfeed.tech/tags/canonicalization.md>), [code](<https://devfeed.tech/tags/code.md>), [compilers](<https://devfeed.tech/tags/compilers.md>), [folding](<https://devfeed.tech/tags/folding.md>), [heir](<https://devfeed.tech/tags/heir.md>), [invariant](<https://devfeed.tech/tags/invariant.md>), [mathematics](<https://devfeed.tech/tags/mathematics.md>), [mlir](<https://devfeed.tech/tags/mlir.md>), [process](<https://devfeed.tech/tags/process.md>), [programming](<https://devfeed.tech/tags/programming.md>)

### AI overview

This tutorial explains how MLIR folding supports sparse conditional constant propagation and canonicalization. It describes adding a constant operation, a materialization hook, and folders for each operation, while distinguishing local canonicalization from propagation through control flow.

### Source excerpt

Table of Contents Last time we saw how to use pre-defined MLIR traits to enable upstream MLIR passes like loop-invariant-code-motion to apply to poly programs. We left out -sccp (sparse conditional constant propagation), and so this time we'll add what is needed to make that pass work. It requires the concept of folding. The code for this article is in this pull request, and as usual the commits are organized to be read in order.

## MLIR -- Writing Our First Pass

DevFeed: [MLIR -- Writing Our First Pass](<https://devfeed.tech/articles/mlir-writing-our-first-pass-40470.md>)

Original publisher: [Read original article](<https://www.jeremykun.com/2023/08/10/mlir-writing-our-first-pass/>)

Published: 2023-08-10T14:39:42Z

Content type: tutorial

Language: en

Sources: [Jeremy Kun](<https://devfeed.tech/sources/jeremy-kun.md>)

Topics: [mlir](<https://devfeed.tech/topics/mlir.md>), [Tutorial](<https://devfeed.tech/topics/tutorial.md>), [API](<https://devfeed.tech/topics/api.md>), [Compiler](<https://devfeed.tech/topics/compiler.md>)

Tags: [api](<https://devfeed.tech/tags/api.md>), [canonicalization](<https://devfeed.tech/tags/canonicalization.md>), [code](<https://devfeed.tech/tags/code.md>), [compiler](<https://devfeed.tech/tags/compiler.md>), [compilers](<https://devfeed.tech/tags/compilers.md>), [implementation](<https://devfeed.tech/tags/implementation.md>), [llvm](<https://devfeed.tech/tags/llvm.md>), [mathematics](<https://devfeed.tech/tags/mathematics.md>), [mlir](<https://devfeed.tech/tags/mlir.md>), [optimize](<https://devfeed.tech/tags/optimize.md>), [programming](<https://devfeed.tech/tags/programming.md>), [tutorial](<https://devfeed.tech/tags/tutorial.md>)

### AI overview

This tutorial introduces MLIR pass development through the HEIR project. It explains how to create a custom tool for an out-of-tree MLIR project and implement simple passes, including loop unrolling and instruction replacement, using the MLIR API and pass infrastructure.

### Source excerpt

Table of Contents This series is an introduction to MLIR and an onboarding tutorial for the HEIR project. Last time we saw how to run and test a basic lowering. This time we will write some simple passes to illustrate the various parts of the MLIR API and the pass infrastructure. As mentioned previously, the main work in MLIR is defining passes that either optimize part of a program, lower from parts of one dialect to others, or perform various normalization and canonicalization operations.