﻿# MLIR partial conversion: success does not mean every operation reached the final dialect

Read MLIR conversion results against explicit legality rules and distinguish partial conversion, full conversion and analysis instead of treating all successful passes as complete lowering.

Author: Retrivium editorial team
Updated: 2026-11-04
Canonical URL: https://retrivium.ai/journal/fg2-mlir-partial-full-dialect-conversion-legality/
Language: en

## A successful pass leaves an operation the next stage rejects

A lowering pipeline reports success after converting familiar tensor operations. The next stage rejects an unfamiliar operation that remained in the graph. The first result may be correct under partial conversion rather than an error in the pass driver. Ask what the pass promised to legalize. A staged pipeline needs an explicit contract for the operations allowed at each boundary; success cannot be interpreted independently of that boundary and the legality policy selected for it.

## The conversion mode changes the success criterion

The [dialect conversion guide](https://mlir.llvm.org/docs/DialectConversion/) distinguishes partial, full and analysis conversion. Partial conversion can retain certain preexisting unknown operations, but explicitly illegal operations still require legalization. Full conversion requires the input to become legal under the target. Analysis conversion reports legalizability without applying the corresponding rewrites. These are different tools for staged compilation, not interchangeable ways to assert that a graph is ready for final machine-code generation.

## Patterns and target legality answer different questions

The [pattern rewriting guide](https://mlir.llvm.org/docs/PatternRewriter/) describes rewriting machinery. A rewrite pattern supplies a possible transformation; a conversion target defines whether an operation instance is acceptable. Dynamic legality can depend on types or attributes, so merely recognizing an operation name is insufficient. The [explicit schema guide](/journal/data-guide-jsonlines-explicit-schema/) provides a useful parallel: declared acceptance rules carry meaning beyond the presence of recognizable fields or names in an input.

## Nested structure belongs to the review

The [MLIR language reference](https://mlir.llvm.org/docs/LangRef/) describes regions, operations and type structure. When inspecting a conversion boundary, include nested operations and the applicable recursive legality decisions rather than checking only the outer function’s printed dialect names. Preserve a small failing program showing the remaining operation and its types. This makes it possible to distinguish a missing pattern, an intentionally legal operation and a gap between the first pass’s target and the next pass’s expectations.

## Declare what may remain after each stage

Record the mode, target rules and expected remaining dialects with the pipeline revision. Validate the final boundary under the criterion actually needed by its consumer. Use [artifact verification](/journal/artifact-signature-verification/) to connect a compiled result to that exact pipeline. A useful report explains why every surviving operation is permitted at its current stage, instead of presenting a successful partial conversion as evidence that all high-level computation has already disappeared.
