@@ -83,6 +83,9 @@ In the above example, `%indices:3` conceptually holds the following:
83
83
%indices_2 = affine.apply #map2()[%linear_index]
84
84
```
85
85
86
+ In other words, `%0:3 = affine.delinearize_index %x into (B, C)` produces
87
+ `%0 = {%x / (B * C), (%x mod (B * C)) / C, %x mod C}`.
88
+
86
89
The basis may either contain `N` or `N-1` elements, where `N` is the number of results.
87
90
If there are N basis elements, the first one will not be used during computations,
88
91
but may be used during analysis and canonicalization to eliminate terms from
@@ -98,7 +101,12 @@ That is, the example above could also have been written
98
101
%0:3 = affine.delinearize_index %linear_index into (244, 244) : index, index
99
102
```
100
103
101
- Note that, due to the constraints of affine maps, all the basis elements must
104
+ Note that, for symmetry with `getPaddedBasis()`, if `hasOuterBound` is `true`
105
+ when one of the `OpFoldResult` builders is called but the first element of the
106
+ basis is `nullptr`, that first element is ignored and the builder proceeds as if
107
+ there was no outer bound.
108
+
109
+ Due to the constraints of affine maps, all the basis elements must
102
110
be strictly positive. A dynamic basis element being 0 or negative causes
103
111
undefined behavior.
104
112
"""
@@ -382,6 +390,9 @@ That is, for indices `%idx_0` to `%idx_{N-1}` and basis elements `b_0`
382
390
sum(i = 0 to N-1) %idx_i * product(j = i + 1 to N-1) B_j
383
391
```
384
392
393
+ In other words, `%0 = affine.linearize_index [%z, %y, %x] by (Z, Y, X)`
394
+ gives `%0 = %x + %y * X + %z * X * Y`, or `%0 = %x + X * (%y + Y * (%z))`.
395
+
385
396
The basis may either have `N` or `N-1` elements, where `N` is the number of
386
397
inputs to linearize_index. If `N` inputs are provided, the first one is not used
387
398
in computation, but may be used during analysis or canonicalization as a bound
@@ -390,6 +401,10 @@ on `%idx_0`.
390
401
If all `N` basis elements are provided, the linearize_index operation is said to
391
402
\" have an outer bound\" .
392
403
404
+ As a convenience, and for symmetry with `getPaddedBasis()`, ifg the first
405
+ element of a set of `OpFoldResult`s passed to the builders of this operation is
406
+ `nullptr`, that element is ignored.
407
+
393
408
If the `disjoint` property is present, this is an optimization hint that,
394
409
for all `i`, `0 <= %idx_i < B_i` - that is, no index affects any other index,
395
410
except that `%idx_0` may be negative to make the index as a whole negative.
0 commit comments