Lines Matching full:affine
1 # 'affine' Dialect
3 This dialect provides a powerful abstraction for affine operations and analyses.
23 // A 2d to 3d affine mapping.
62 The affine dialect imposes certain restrictions on dimension and symbolic
84 [`affine.for`](#affinefor-mliraffineforop) and
85 [`affine.parallel`](#affineparallel-mliraffineparallelop) operations, and the result
86 of an [`affine.apply` operation](#affineapply-mliraffineapplyop) (which recursively
89 ### Affine Expressions
94 affine-expr ::= `(` affine-expr `)`
95 | affine-expr `+` affine-expr
96 | affine-expr `-` affine-expr
97 | `-`? integer-literal `*` affine-expr
98 | affine-expr `ceildiv` integer-literal
99 | affine-expr `floordiv` integer-literal
100 | affine-expr `mod` integer-literal
101 | `-`affine-expr
105 multi-dim-affine-expr ::= `(` `)`
106 | `(` affine-expr (`,` affine-expr)* `)`
117 [index](Builtin.md/#indextype). The precedence of operations in an affine
123 A *multidimensional affine expression* is a comma separated list of
124 one-dimensional affine expressions, with the entire list enclosed in
127 **Context:** An affine function, informally, is a linear function plus a
129 \mathbb{Z}^n$ is a multidimensional affine function of $\vec{v}$ if $f(\vec{v})$
132 $\mathbb{Z}$. $m$ is the dimensionality of such an affine function. MLIR further
133 extends the definition of an affine function to allow 'floordiv', 'ceildiv', and
134 'mod' with respect to positive integer constants. Such extensions to affine
135 functions have often been referred to as quasi-affine functions by the
136 polyhedral compiler community. MLIR uses the term 'affine map' to refer to these
137 multidimensional quasi-affine functions. As examples, $(i+j+1, j)$, $(i \mod 2,
138 j+i)$, $(j, i/4, i \mod 4)$, $(2i+1, j)$ are two-dimensional affine functions of
139 $(i, j)$, but $(i \cdot j, i^2)$, $(i \mod j, i/j)$ are not affine functions of
142 ### Affine Maps
147 affine-map-inline
148 ::= dim-and-symbol-value-lists `->` multi-dim-affine-expr
152 the only identifiers that may appear in 'multi-dim-affine-expr'. Affine maps
153 with one or more symbols in its specification are known as "symbolic affine
154 maps", and those with no symbols as "non-symbolic affine maps".
156 **Context:** Affine maps are mathematical functions that transform a list of
157 dimension indices and symbols into a list of results, with affine expressions
158 combining the indices and symbols. Affine maps distinguish between
160 affine map when the map is called (through an operation such as
161 [affine.apply](#affineapply-mliraffineapplyop)), whereas symbols are bound when the
165 Affine maps are used for various core structures in MLIR. The restrictions we
169 #### Named affine mappings
174 affine-map-id ::= `#` suffix-id
176 // Definitions of affine maps are at the top of the file.
177 affine-map-def ::= affine-map-id `=` affine-map-inline
178 module-header-def ::= affine-map-def
180 // Uses of affine maps may use the inline form or the named form.
181 affine-map ::= affine-map-id | affine-map-inline
184 Affine mappings may be defined inline at the point of use, or may be hoisted to
185 the top of the file and given a name with an affine map definition, and used by
191 // Affine map out-of-line definition and usage example.
194 // Use an affine mapping definition in an alloc operation, binding the
198 // Same thing with an inline affine mapping definition.
202 ### Semi-affine maps
204 Semi-affine maps are extensions of affine maps to allow multiplication,
206 Semi-affine maps are thus a strict superset of affine maps.
208 Syntax of semi-affine expressions:
211 semi-affine-expr ::= `(` semi-affine-expr `)`
212 | semi-affine-expr `+` semi-affine-expr
213 | semi-affine-expr `-` semi-affine-expr
214 | symbol-or-const `*` semi-affine-expr
215 | semi-affine-expr `ceildiv` symbol-or-const
216 | semi-affine-expr `floordiv` symbol-or-const
217 | semi-affine-expr `mod` symbol-or-const
223 multi-dim-semi-affine-expr ::= `(` semi-affine-expr (`,` semi-affine-expr)* `)`
227 as that for [affine expressions](#affine-expressions).
229 Syntax of semi-affine maps:
232 semi-affine-map-inline
233 ::= dim-and-symbol-value-lists `->` multi-dim-semi-affine-expr
236 Semi-affine maps may be defined inline at the point of use, or may be hoisted to
237 the top of the file and given a name with a semi-affine map definition, and used
241 semi-affine-map-id ::= `#` suffix-id
243 // Definitions of semi-affine maps are at the top of file.
244 semi-affine-map-def ::= semi-affine-map-id `=` semi-affine-map-inline
245 module-header-def ::= semi-affine-map-def
247 // Uses of semi-affine maps may use the inline form or the named form.
248 semi-affine-map ::= semi-affine-map-id | semi-affine-map-inline
253 An integer set is a conjunction of affine constraints on a list of identifiers.
260 Syntax of affine constraints:
263 affine-constraint ::= affine-expr `>=` `affine-expr`
264 | affine-expr `<=` `affine-expr`
265 | affine-expr `==` `affine-expr`
266 affine-constraint-conjunction ::= affine-constraint (`,` affine-constraint)*
277 ::= dim-and-symbol-value-lists `:` '(' affine-constraint-conjunction? ')'
287 dimension list of the set. The affine-constraint non-terminals appearing in the
300 affine.if #set42(%i, %j)[%M, %N] {
312 ### `affine.dma_start` (mlir::AffineDmaStartOp)
317 operation ::= `affine.dma_start` ssa-use `[` multi-dim-affine-map-of-ssa-ids `]`, `[` multi-dim-affine-map-of-ssa-ids `]`, `[` multi-dim-affine-map-of-ssa-ids `]`, ssa-use `:` memref-type
320 The `affine.dma_start` op starts a non-blocking DMA operation that transfers
329 memref have the same restrictions as any affine.load/store. In particular, index
330 for each memref dimension must be an affine expression of loop induction
349 affine.dma_start %src[%i + 3, %j], %dst[%k + 7, %l], %tag[%idx],
361 affine.dma_start %src[%i, %j], %dst[%k, %l], %tag[%idx], %num_elements,
365 ### `affine.dma_wait` (mlir::AffineDmaWaitOp)
370 operation ::= `affine.dma_wait` ssa-use `[` multi-dim-affine-map-of-ssa-ids `]`, ssa-use `:` memref-type
373 The `affine.dma_wait` op blocks until the completion of a DMA operation
376 particular, index for each memref dimension must be an affine expression of loop
383 affine.dma_start %src[%i, %j], %dst[%k, %l], %tag[%index], %num_elements :
387 affine.dma_wait %tag[%index], %num_elements : memref<1xi32, 2>