Why are dimensions and symbols separated?

I’m pretty new to MLIR and polyhedral representation itself. Sorry for raising the trivial question which might not be directly related to MLIR itself. But I have a question about the theory or rationale behind the separation between dimensions and symbols of the affine map.

affine_map<(d0, d1)[s0] -> (d0, d1 + s0, d1 - s0)>

While dimensions are given with parenthesis, symbols are enclosed with square brackets. Both dimensions and symbols seem to be just an argument of the affine map. Hence, it seems to make more sense and straightforward to me.

affine_map<(d0, d1, s0) -> (d0, d1 + s0, d1 - s0)>

Why are they distinct? Is there any theory to treat them separately?

Just read on the paragraph you linked:

Dimensional identifiers correspond to the dimensions of the underlying structure being represented (a map, set, or more concretely a loop nest or a tensor); for example, a three-dimensional loop nest has three dimensional identifiers. Symbol identifiers represent an unknown quantity that can be treated as constant for a region of interest.

In other words (which is also mentioned in the documentation), dimensions are typically associated with varying quantities such as loop induction variables while symbols are associated with invariant, though unknown, quantities such as sizes. Algorithms in the polyhedral model often process dimensions and symbols (also called parameters in the literature) differently, for example, when composing maps dimensions are composed but symbols may be concatenated instead. This is a very basic idea in the polyhedral model. I can recommend the entry on the subject by Feautrier and Lengauer in the Encyclopedia of Parallel Programming, followed by Verdoolaege’s tutorial.

Note that, at this point, MLIR itself is no longer based on the polyhedral model (except for the affine and parts of linalg dialects. which have no incidence on the core IR) and understanding the model is not a requirement to use MLIR.

1 Like

dimensions are typically associated with varying quantities such as loop induction variables while symbols are associated with invariant,

That clarifies all my uncertainty about the distinction between dimensions and symbols.

I can recommend the entry on the subject by Feautrier and Lengauer in the Encyclopedia of Parallel Programming, followed by Verdoolaege’s tutorial

Thank you. That’s so helpful.