Skip to content

GlobalOptimization

-iree-global-opt-cleanup-numeric-narrowinglink

Cleans up any numeric narrowing ops inserted by iree-global-opt-infer-numeric-narrowing.

-iree-global-opt-convert-batch-matmul-to-matmullink

Converts batch_matmul to reshape + matmul + reshape.

-iree-global-opt-convert-conv-to-im2collink

Rewrites convolutions as contractions over an im2col gather

Rewrites every linalg op that implements a convolution, named or generic, as an all-parallel linalg.generic that gathers the convolved input windows, followed by a contraction over the gathered tensor with the original payload. Contraction loops are collapsed wherever the operand layouts allow, so standard layouts become plain or batched matmuls. Convolutions without an output channel dimension, i.e. depthwise convolutions with a unit multiplier and pooling ops, are left unchanged: nothing reuses the gathered input, so the rewrite never pays off.

The pass expects quantization to be lowered already: quantized convolutions such as linalg.conv_2d_nhwc_hwcf_q are not matched, and dequantize producers are not looked through.

-iree-global-opt-convert-qdq-to-integer-mathlink

Rewrites contractions over dequantized operands into integer contractions.

Matches a contraction or convolution whose inputs are produced by iree_linalg_ext.dequantize_affine and rewrites it into an integer contraction plus a zero point correction epilogue:

C = sAsB(D - zBRA - zARB + NzAzB)

Matches a plain floating-point multiply-add body with a zero init. Integer reduction dimensions must have positive static extents whose products and zero point corrections fit in signed i32. Dimensions along which a quantization parameter varies remain floating-point reductions over partial integer contractions. Unsupported cases retain the original computation.

Scaling and partial-result accumulation use at least f32, preserving wider scale and output types, before conversion to the output type.

Numerical stability is best effort. Reassociation changes floating-point rounding; no fixed error bound or preservation of signed zero, NaNs, infinities, or overflow/underflow behavior is guaranteed. Disable this transformation when reference floating-point semantics are required with --iree-global-opt-enable-qdq-to-integer-math=false.

-iree-global-opt-convert-strided-contraction-to-contractionlink

Factors out an extract_slice from contraction-like ops with strided inputs.

-iree-global-opt-data-layout-propagationlink

Propagate pack/unpack ops across other ops to improve fusion

-iree-global-opt-decompose-concatlink

Decomposes concatenations into a destination and a sequence of slice inserts.

Optionslink

-enable-concat-transposition : Allows transposing concatenations such that they occur on the inner most dims.

-iree-global-opt-demote-contraction-inputslink

Demotes inputs (LHS, RHS) of linalg matmul-like ops from f32 to a narrower type.

Optionslink

-type      : Select the target type for demotion.
-operation : Select the type of contraction ops to demote.

-iree-global-opt-detach-elementwise-from-named-opslink

Detaches elementwise ops from named Linalg ops.

-iree-global-opt-erase-unused-linalg-operandslink

Erases unused linalg operand and remove dead code.

-iree-global-opt-expand-tensor-shapeslink

Expands tensor shape dimensions into SSA values across the program.

-iree-global-opt-fuse-dequantization-matmullink

Fuses dequantization and matmul linalg.generic ops.

-iree-global-opt-generalize-linalg-named-opslink

Convert some Linalg named ops into linalg.generics.

Optionslink

-enable-generalize-matmul : Convert linalg named matmul ops to generic ops.

-iree-global-opt-infer-numeric-narrowinglink

Infers and inserts util.numeric.optional_narrow ops at points that may be beneficial.

-iree-global-opt-loop-invariant-code-motionlink

Hoist loop invariants out of loops with zero-trip-check.

-iree-global-opt-materialize-homogeneous-encodingslink

Materializes logical encodings to physical encodings if there is a single device target.

-iree-global-opt-optimize-numericslink

Optimizes numerics given annotations added via iree-global-opt-infer-numeric-narrowing.

-iree-global-opt-propagate-affine-quantizationlink

Propagates affine quantization through adjacent tensor operations.

Moves iree_linalg_ext.quantize_affine before a producer-side tensor.collapse_shape, and moves a consumer-side tensor.expand_shape, or a zero tensor.pad whose padded dimensions do not index the scale and whose zero point is per-tensor, before iree_linalg_ext.dequantize_affine. These shape operations then run on quantized values. A consumer-side linalg.transpose is fused into the dequantize's output map instead. A tensor.collapse_shape of a dequantized value is absorbed by a consuming linalg.transpose, or by a contraction whose inputs are all dequantized, by expanding the consumer's iteration space; a blockwise matmul over collapsed [M, G, L] and [N, G, L] operands thus iterates over (m, n, g, l). When a contraction consumes the result, the dequantize becomes its direct producer so the integer contraction rewrite can match it.

-iree-global-opt-propagate-linalg-transposelink

Propagates linalg.transpose through a restricted set of ops.

Optionslink

-enable-aggressive-propagation              : Enable aggressive propagation to named ops.
-test-sinking-only                          : Flag used for lit-testing sinking patterns only. Not for general usage
-test-bubbling-only                         : Flag used for lit-testing bubbling patterns only. Not for general usage
-enable-attention-v-transpose               : Enable transposition of attention v operand
-enable-aggressive-propagation-through-conv : enable propagation through convolutions
-enable-edge-reshape-propagation            : Enable propagation of reshapes on the edges of the program
-enable-sink-transpose-through-pad          : Enable sinking transpose through pad operations

-iree-global-opt-quantized-conv-to-convlink

Lower quantized_conv to conv

-iree-global-opt-quantized-matmul-to-matmullink

Lower quantized_matmul to matmul

-iree-global-opt-raise-special-opslink

Raises special ops like softmax to the high level linalg.ext representation.

-iree-global-opt-remove-zero-extent-tensorslink

Removes tensors that have 0-extents.

-iree-global-opt-simplify-pack-unpacklink

Simplifies tensor pack and unpack ops.

-iree-global-opt-warn-on-uninitialized-valueslink

Catch some uses of uninitialized values