diff options
Diffstat (limited to 'mlir/test/Transforms')
29 files changed, 584 insertions, 583 deletions
diff --git a/mlir/test/Transforms/Vectorize/compose_maps.mlir b/mlir/test/Transforms/Vectorize/compose_maps.mlir index f1826f440f2..1e6a0436e4b 100644 --- a/mlir/test/Transforms/Vectorize/compose_maps.mlir +++ b/mlir/test/Transforms/Vectorize/compose_maps.mlir @@ -11,121 +11,121 @@ func @simple1() { // CHECK: Composed map: (d0) -> (d0) - "test_affine_map"() { affine_map = (d0) -> (d0 - 1) } : () -> () - "test_affine_map"() { affine_map = (d0) -> (d0 + 1) } : () -> () + "test_affine_map"() { affine_map = affine_map<(d0) -> (d0 - 1)> } : () -> () + "test_affine_map"() { affine_map = affine_map<(d0) -> (d0 + 1)> } : () -> () return } func @simple2() { // CHECK: Composed map: (d0)[s0, s1] -> (d0 - s0 + s1) - "test_affine_map"() { affine_map = (d0)[s0] -> (d0 + s0 - 1) } : () -> () - "test_affine_map"() { affine_map = (d0)[s0] -> (d0 - s0 + 1) } : () -> () + "test_affine_map"() { affine_map = affine_map<(d0)[s0] -> (d0 + s0 - 1)> } : () -> () + "test_affine_map"() { affine_map = affine_map<(d0)[s0] -> (d0 - s0 + 1)> } : () -> () return } func @simple3a() { // CHECK: Composed map: (d0, d1)[s0, s1, s2, s3] -> ((d0 ceildiv s2) * s0, (d1 ceildiv s3) * s1) - "test_affine_map"() { affine_map = (d0, d1)[s0, s1] -> (d0 ceildiv s0, d1 ceildiv s1) } : () -> () - "test_affine_map"() { affine_map = (d0, d1)[s0, s1] -> (d0 * s0, d1 * s1) } : () -> () + "test_affine_map"() { affine_map = affine_map<(d0, d1)[s0, s1] -> (d0 ceildiv s0, d1 ceildiv s1)> } : () -> () + "test_affine_map"() { affine_map = affine_map<(d0, d1)[s0, s1] -> (d0 * s0, d1 * s1)> } : () -> () return } func @simple3b() { // CHECK: Composed map: (d0, d1)[s0, s1] -> (d0 mod s0, d1 mod s1) - "test_affine_map"() { affine_map = (d0, d1)[s0, s1] -> (d0 mod s0, d1 mod s1) } : () -> () + "test_affine_map"() { affine_map = affine_map<(d0, d1)[s0, s1] -> (d0 mod s0, d1 mod s1)> } : () -> () return } func @simple3c() { // CHECK: Composed map: (d0, d1)[s0, s1, s2, s3, s4, s5] -> ((d0 ceildiv s4) * s4 + d0 mod s2, (d1 ceildiv s5) * s5 + d1 mod s3) - "test_affine_map"() { affine_map = (d0, d1)[s0, s1] -> ((d0 ceildiv s0) * s0, (d1 ceildiv s1) * s1, d0, d1) } : () -> () - "test_affine_map"() { affine_map = (d0, d1, d2, d3)[s0, s1, s2, s3] -> (d0 + d2 mod s2, d1 + d3 mod s3) } : () -> () + "test_affine_map"() { affine_map = affine_map<(d0, d1)[s0, s1] -> ((d0 ceildiv s0) * s0, (d1 ceildiv s1) * s1, d0, d1)> } : () -> () + "test_affine_map"() { affine_map = affine_map<(d0, d1, d2, d3)[s0, s1, s2, s3] -> (d0 + d2 mod s2, d1 + d3 mod s3)> } : () -> () return } func @simple4() { // CHECK: Composed map: (d0, d1)[s0, s1] -> (d1 * s1, d0 ceildiv s0) - "test_affine_map"() { affine_map = (d0, d1) -> (d1, d0) } : () -> () - "test_affine_map"() { affine_map = (d0, d1)[s0, s1] -> (d0 * s1, d1 ceildiv s0) } : () -> () + "test_affine_map"() { affine_map = affine_map<(d0, d1) -> (d1, d0)> } : () -> () + "test_affine_map"() { affine_map = affine_map<(d0, d1)[s0, s1] -> (d0 * s1, d1 ceildiv s0)> } : () -> () return } func @simple5a() { // CHECK: Composed map: (d0) -> (d0 * 3 + 18) - "test_affine_map"() { affine_map = (d0) -> (d0 - 1) } : () -> () - "test_affine_map"() { affine_map = (d0) -> (d0 + 7) } : () -> () - "test_affine_map"() { affine_map = (d0) -> (d0 * 24) } : () -> () - "test_affine_map"() { affine_map = (d0) -> (d0 ceildiv 8) } : () -> () + "test_affine_map"() { affine_map = affine_map<(d0) -> (d0 - 1)> } : () -> () + "test_affine_map"() { affine_map = affine_map<(d0) -> (d0 + 7)> } : () -> () + "test_affine_map"() { affine_map = affine_map<(d0) -> (d0 * 24)> } : () -> () + "test_affine_map"() { affine_map = affine_map<(d0) -> (d0 ceildiv 8)> } : () -> () return } func @simple5b() { // CHECK: Composed map: (d0) -> ((d0 + 6) ceildiv 2) - "test_affine_map"() { affine_map = (d0) -> (d0 - 1) } : () -> () - "test_affine_map"() { affine_map = (d0) -> (d0 + 7) } : () -> () - "test_affine_map"() { affine_map = (d0) -> (d0 * 4) } : () -> () - "test_affine_map"() { affine_map = (d0) -> (d0 ceildiv 8) } : () -> () + "test_affine_map"() { affine_map = affine_map<(d0) -> (d0 - 1)> } : () -> () + "test_affine_map"() { affine_map = affine_map<(d0) -> (d0 + 7)> } : () -> () + "test_affine_map"() { affine_map = affine_map<(d0) -> (d0 * 4)> } : () -> () + "test_affine_map"() { affine_map = affine_map<(d0) -> (d0 ceildiv 8)> } : () -> () return } func @simple5c() { // CHECK: Composed map: (d0) -> (d0 * 8 + 48) - "test_affine_map"() { affine_map = (d0) -> (d0 - 1) } : () -> () - "test_affine_map"() { affine_map = (d0) -> (d0 + 7) } : () -> () - "test_affine_map"() { affine_map = (d0) -> (d0 * 24) } : () -> () - "test_affine_map"() { affine_map = (d0) -> (d0 floordiv 3) } : () -> () + "test_affine_map"() { affine_map = affine_map<(d0) -> (d0 - 1)> } : () -> () + "test_affine_map"() { affine_map = affine_map<(d0) -> (d0 + 7)> } : () -> () + "test_affine_map"() { affine_map = affine_map<(d0) -> (d0 * 24)> } : () -> () + "test_affine_map"() { affine_map = affine_map<(d0) -> (d0 floordiv 3)> } : () -> () return } func @simple5d() { // CHECK: Composed map: (d0) -> ((d0 * 4) floordiv 3 + 8) - "test_affine_map"() { affine_map = (d0) -> (d0 - 1) } : () -> () - "test_affine_map"() { affine_map = (d0) -> (d0 + 7) } : () -> () - "test_affine_map"() { affine_map = (d0) -> (d0 * 4) } : () -> () - "test_affine_map"() { affine_map = (d0) -> (d0 floordiv 3) } : () -> () + "test_affine_map"() { affine_map = affine_map<(d0) -> (d0 - 1)> } : () -> () + "test_affine_map"() { affine_map = affine_map<(d0) -> (d0 + 7)> } : () -> () + "test_affine_map"() { affine_map = affine_map<(d0) -> (d0 * 4)> } : () -> () + "test_affine_map"() { affine_map = affine_map<(d0) -> (d0 floordiv 3)> } : () -> () return } func @simple5e() { // CHECK: Composed map: (d0) -> ((d0 + 6) ceildiv 8) - "test_affine_map"() { affine_map = (d0) -> (d0 - 1) } : () -> () - "test_affine_map"() { affine_map = (d0) -> (d0 + 7) } : () -> () - "test_affine_map"() { affine_map = (d0) -> (d0 ceildiv 8) } : () -> () + "test_affine_map"() { affine_map = affine_map<(d0) -> (d0 - 1)> } : () -> () + "test_affine_map"() { affine_map = affine_map<(d0) -> (d0 + 7)> } : () -> () + "test_affine_map"() { affine_map = affine_map<(d0) -> (d0 ceildiv 8)> } : () -> () return } func @simple5f() { // CHECK: Composed map: (d0) -> ((d0 * 4 - 4) floordiv 3) - "test_affine_map"() { affine_map = (d0) -> (d0 - 1) } : () -> () - "test_affine_map"() { affine_map = (d0) -> (d0 * 4) } : () -> () - "test_affine_map"() { affine_map = (d0) -> (d0 floordiv 3) } : () -> () + "test_affine_map"() { affine_map = affine_map<(d0) -> (d0 - 1)> } : () -> () + "test_affine_map"() { affine_map = affine_map<(d0) -> (d0 * 4)> } : () -> () + "test_affine_map"() { affine_map = affine_map<(d0) -> (d0 floordiv 3)> } : () -> () return } func @perm_and_proj() { // CHECK: Composed map: (d0, d1, d2, d3) -> (d1, d3, d0) - "test_affine_map"() { affine_map = (d0, d1, d2, d3) -> (d3, d1, d2, d0) } : () -> () - "test_affine_map"() { affine_map = (d0, d1, d2, d3) -> (d1, d0, d3) } : () -> () + "test_affine_map"() { affine_map = affine_map<(d0, d1, d2, d3) -> (d3, d1, d2, d0)> } : () -> () + "test_affine_map"() { affine_map = affine_map<(d0, d1, d2, d3) -> (d1, d0, d3)> } : () -> () return } func @symbols1() { // CHECK: Composed map: (d0)[s0] -> (d0 + s0 + 1, d0 - s0 - 1) - "test_affine_map"() { affine_map = (d0)[s0] -> (d0 + s0, d0 - s0) } : () -> () - "test_affine_map"() { affine_map = (d0, d1) -> (d0 + 1, d1 - 1) } : () -> () + "test_affine_map"() { affine_map = affine_map<(d0)[s0] -> (d0 + s0, d0 - s0)> } : () -> () + "test_affine_map"() { affine_map = affine_map<(d0, d1) -> (d0 + 1, d1 - 1)> } : () -> () return } func @drop() { // CHECK: Composed map: (d0, d1, d2)[s0, s1] -> (d0 * 2 + d1 + d2 + s1) - "test_affine_map"() { affine_map = (d0, d1, d2)[s0, s1] -> (d0 + s1, d1 + s0, d0 + d1 + d2) } : () -> () - "test_affine_map"() { affine_map = (d0, d1, d2) -> (d0 + d2) } : () -> () + "test_affine_map"() { affine_map = affine_map<(d0, d1, d2)[s0, s1] -> (d0 + s1, d1 + s0, d0 + d1 + d2)> } : () -> () + "test_affine_map"() { affine_map = affine_map<(d0, d1, d2) -> (d0 + d2)> } : () -> () return } func @multi_symbols() { // CHECK: Composed map: (d0)[s0, s1, s2] -> (d0 + s1 + s2 + 1, d0 - s0 - s2 - 1) - "test_affine_map"() { affine_map = (d0)[s0] -> (d0 + s0, d0 - s0) } : () -> () - "test_affine_map"() { affine_map = (d0, d1)[s0, s1] -> (d0 + 1 + s1, d1 - 1 - s0) } : () -> () + "test_affine_map"() { affine_map = affine_map<(d0)[s0] -> (d0 + s0, d0 - s0)> } : () -> () + "test_affine_map"() { affine_map = affine_map<(d0, d1)[s0, s1] -> (d0 + 1 + s1, d1 - 1 - s0)> } : () -> () return } diff --git a/mlir/test/Transforms/Vectorize/normalize_maps.mlir b/mlir/test/Transforms/Vectorize/normalize_maps.mlir index 4854a622642..0d778595742 100644 --- a/mlir/test/Transforms/Vectorize/normalize_maps.mlir +++ b/mlir/test/Transforms/Vectorize/normalize_maps.mlir @@ -1,19 +1,19 @@ // RUN: mlir-opt %s -affine-vectorizer-test -normalize-maps | FileCheck %s -// CHECK-DAG: #[[ZERO:[a-zA-Z0-9]+]] = () -> (0) -// CHECK-DAG: #[[ID1:[a-zA-Z0-9]+]] = (d0) -> (d0) -// CHECK-DAG: #[[D0TIMES2:[a-zA-Z0-9]+]] = (d0) -> (d0 * 2) -// CHECK-DAG: #[[D0PLUSD1:[a-zA-Z0-9]+]] = (d0, d1) -> (d0 + d1) -// CHECK-DAG: #[[MINSD0PLUSD1:[a-zA-Z0-9]+]] = (d0, d1) -> (-d0 + d1) -// CHECK-DAG: #[[D0MINUSD1:[a-zA-Z0-9]+]] = (d0, d1) -> (d0 - d1) +// CHECK-DAG: #[[ZERO:[a-zA-Z0-9]+]] = affine_map<() -> (0)> +// CHECK-DAG: #[[ID1:[a-zA-Z0-9]+]] = affine_map<(d0) -> (d0)> +// CHECK-DAG: #[[D0TIMES2:[a-zA-Z0-9]+]] = affine_map<(d0) -> (d0 * 2)> +// CHECK-DAG: #[[D0PLUSD1:[a-zA-Z0-9]+]] = affine_map<(d0, d1) -> (d0 + d1)> +// CHECK-DAG: #[[MINSD0PLUSD1:[a-zA-Z0-9]+]] = affine_map<(d0, d1) -> (-d0 + d1)> +// CHECK-DAG: #[[D0MINUSD1:[a-zA-Z0-9]+]] = affine_map<(d0, d1) -> (d0 - d1)> // CHECK-LABEL: func @simple() func @simple() { affine.for %i0 = 0 to 7 { - %0 = affine.apply (d0) -> (d0) (%i0) - %1 = affine.apply (d0) -> (d0) (%0) - %2 = affine.apply (d0, d1) -> (d0 + d1) (%0, %0) - %3 = affine.apply (d0, d1) -> (d0 - d1) (%0, %0) + %0 = affine.apply affine_map<(d0) -> (d0)> (%i0) + %1 = affine.apply affine_map<(d0) -> (d0)> (%0) + %2 = affine.apply affine_map<(d0, d1) -> (d0 + d1)> (%0, %0) + %3 = affine.apply affine_map<(d0, d1) -> (d0 - d1)> (%0, %0) } // CHECK-NEXT: affine.for %{{.*}} = 0 to 7 // CHECK-NEXT: {{.*}} affine.apply #[[ID1]](%{{.*}}) @@ -22,11 +22,11 @@ func @simple() { affine.for %i1 = 0 to 7 { affine.for %i2 = 0 to 42 { - %20 = affine.apply (d0, d1) -> (d1) (%i1, %i2) - %21 = affine.apply (d0, d1) -> (d0) (%i1, %i2) - %22 = affine.apply (d0, d1) -> (d0 + d1) (%20, %21) - %23 = affine.apply (d0, d1) -> (d0 - d1) (%20, %21) - %24 = affine.apply (d0, d1) -> (-d0 + d1) (%20, %21) + %20 = affine.apply affine_map<(d0, d1) -> (d1)> (%i1, %i2) + %21 = affine.apply affine_map<(d0, d1) -> (d0)> (%i1, %i2) + %22 = affine.apply affine_map<(d0, d1) -> (d0 + d1)> (%20, %21) + %23 = affine.apply affine_map<(d0, d1) -> (d0 - d1)> (%20, %21) + %24 = affine.apply affine_map<(d0, d1) -> (-d0 + d1)> (%20, %21) } } // CHECK: affine.for %{{.*}} = 0 to 7 @@ -38,12 +38,12 @@ func @simple() { affine.for %i3 = 0 to 16 { affine.for %i4 = 0 to 47 step 2 { affine.for %i5 = 0 to 78 step 16 { - %50 = affine.apply (d0) -> (d0) (%i3) - %51 = affine.apply (d0) -> (d0) (%i4) - %52 = affine.apply (d0) -> (d0) (%i5) - %53 = affine.apply (d0, d1, d2) -> (d0) (%50, %51, %52) - %54 = affine.apply (d0, d1, d2) -> (d1) (%50, %51, %52) - %55 = affine.apply (d0, d1, d2) -> (d2) (%50, %51, %52) + %50 = affine.apply affine_map<(d0) -> (d0)> (%i3) + %51 = affine.apply affine_map<(d0) -> (d0)> (%i4) + %52 = affine.apply affine_map<(d0) -> (d0)> (%i5) + %53 = affine.apply affine_map<(d0, d1, d2) -> (d0)> (%50, %51, %52) + %54 = affine.apply affine_map<(d0, d1, d2) -> (d1)> (%50, %51, %52) + %55 = affine.apply affine_map<(d0, d1, d2) -> (d2)> (%50, %51, %52) } } } diff --git a/mlir/test/Transforms/Vectorize/vectorize_1d.mlir b/mlir/test/Transforms/Vectorize/vectorize_1d.mlir index 83f783c3aef..7fbb6fe0b22 100644 --- a/mlir/test/Transforms/Vectorize/vectorize_1d.mlir +++ b/mlir/test/Transforms/Vectorize/vectorize_1d.mlir @@ -1,14 +1,14 @@ // RUN: mlir-opt %s -affine-vectorize -virtual-vector-size 128 --test-fastest-varying=0 | FileCheck %s // Permutation maps used in vectorization. -// CHECK: #[[map_proj_d0d1_0:map[0-9]+]] = (d0, d1) -> (0) -// CHECK: #[[map_proj_d0d1_d1:map[0-9]+]] = (d0, d1) -> (d1) +// CHECK: #[[map_proj_d0d1_0:map[0-9]+]] = affine_map<(d0, d1) -> (0)> +// CHECK: #[[map_proj_d0d1_d1:map[0-9]+]] = affine_map<(d0, d1) -> (d1)> -#map0 = (d0) -> (d0) -#mapadd1 = (d0) -> (d0 + 1) -#mapadd2 = (d0) -> (d0 + 2) -#mapadd3 = (d0) -> (d0 + 3) -#set0 = (i) : (i >= 0) +#map0 = affine_map<(d0) -> (d0)> +#mapadd1 = affine_map<(d0) -> (d0 + 1)> +#mapadd2 = affine_map<(d0) -> (d0 + 2)> +#mapadd3 = affine_map<(d0) -> (d0 + 3)> +#set0 = affine_set<(i) : (i >= 0)> // Maps introduced to vectorize fastest varying memory index. // CHECK-LABEL: func @vec1d_1 diff --git a/mlir/test/Transforms/Vectorize/vectorize_2d.mlir b/mlir/test/Transforms/Vectorize/vectorize_2d.mlir index a7553092505..8fa3842edea 100644 --- a/mlir/test/Transforms/Vectorize/vectorize_2d.mlir +++ b/mlir/test/Transforms/Vectorize/vectorize_2d.mlir @@ -2,14 +2,14 @@ // RUN: mlir-opt %s -affine-vectorize -virtual-vector-size 32 -virtual-vector-size 256 --test-fastest-varying=1 --test-fastest-varying=0 | FileCheck %s // Permutation maps used in vectorization. -// CHECK-DAG: #[[map_id1:map[0-9]+]] = (d0) -> (d0) -// CHECK-DAG: #[[map_id2:map[0-9]+]] = (d0, d1) -> (d0, d1) -// CHECK-DAG: #[[map_proj_d0d1_zerod1:map[0-9]+]] = (d0, d1) -> (0, d1) -// CHECK-DAG: #[[map_proj_d0d1_d0zero:map[0-9]+]] = (d0, d1) -> (d0, 0) -// VECT-DAG: #[[map_id1:map[0-9]+]] = (d0) -> (d0) -// VECT-DAG: #[[map_id2:map[0-9]+]] = (d0, d1) -> (d0, d1) -// VECT-DAG: #[[map_proj_d0d1_zerod1:map[0-9]+]] = (d0, d1) -> (0, d1) -// VECT-DAG: #[[map_proj_d0d1_d0zero:map[0-9]+]] = (d0, d1) -> (d0, 0) +// CHECK-DAG: #[[map_id1:map[0-9]+]] = affine_map<(d0) -> (d0)> +// CHECK-DAG: #[[map_id2:map[0-9]+]] = affine_map<(d0, d1) -> (d0, d1)> +// CHECK-DAG: #[[map_proj_d0d1_zerod1:map[0-9]+]] = affine_map<(d0, d1) -> (0, d1)> +// CHECK-DAG: #[[map_proj_d0d1_d0zero:map[0-9]+]] = affine_map<(d0, d1) -> (d0, 0)> +// VECT-DAG: #[[map_id1:map[0-9]+]] = affine_map<(d0) -> (d0)> +// VECT-DAG: #[[map_id2:map[0-9]+]] = affine_map<(d0, d1) -> (d0, d1)> +// VECT-DAG: #[[map_proj_d0d1_zerod1:map[0-9]+]] = affine_map<(d0, d1) -> (0, d1)> +// VECT-DAG: #[[map_proj_d0d1_d0zero:map[0-9]+]] = affine_map<(d0, d1) -> (d0, 0)> func @vec2d(%A : memref<?x?x?xf32>) { %M = dim %A, 0 : memref<?x?x?xf32> @@ -111,8 +111,8 @@ func @vectorize_matmul(%arg0: memref<?x?xf32>, %arg1: memref<?x?xf32>, %arg2: me // VECT-NEXT: {{.*}} #[[map_id1]](%[[N]]) step 8 { // VECT: %[[VC0:.*]] = constant dense<0.000000e+00> : vector<4x8xf32> // VECT-NEXT: vector.transfer_write %[[VC0]], %{{.*}}[%{{.*}}, %{{.*}}] {permutation_map = #[[map_id2]]} : vector<4x8xf32>, memref<?x?xf32> - affine.for %i0 = (d0) -> (d0)(%c0) to (d0) -> (d0)(%M) { - affine.for %i1 = (d0) -> (d0)(%c0) to (d0) -> (d0)(%N) { + affine.for %i0 = affine_map<(d0) -> (d0)>(%c0) to affine_map<(d0) -> (d0)>(%M) { + affine.for %i1 = affine_map<(d0) -> (d0)>(%c0) to affine_map<(d0) -> (d0)>(%N) { %cst = constant 0.000000e+00 : f32 affine.store %cst, %arg2[%i0, %i1] : memref<?x?xf32> } @@ -126,9 +126,9 @@ func @vectorize_matmul(%arg0: memref<?x?xf32>, %arg1: memref<?x?xf32>, %arg2: me // VECT-NEXT: %[[D:.*]] = vector.transfer_read %{{.*}}[%[[I2]], %[[I3]]], %{{.*}} {permutation_map = #[[map_id2]]} : memref<?x?xf32>, vector<4x8xf32> // VECT-NEXT: %[[E:.*]] = addf %[[D]], %[[C]] : vector<4x8xf32> // VECT-NEXT: vector.transfer_write %[[E]], %{{.*}}[%[[I2]], %[[I3]]] {permutation_map = #[[map_id2]]} : vector<4x8xf32>, memref<?x?xf32> - affine.for %i2 = (d0) -> (d0)(%c0) to (d0) -> (d0)(%M) { - affine.for %i3 = (d0) -> (d0)(%c0) to (d0) -> (d0)(%N) { - affine.for %i4 = (d0) -> (d0)(%c0) to (d0) -> (d0)(%K) { + affine.for %i2 = affine_map<(d0) -> (d0)>(%c0) to affine_map<(d0) -> (d0)>(%M) { + affine.for %i3 = affine_map<(d0) -> (d0)>(%c0) to affine_map<(d0) -> (d0)>(%N) { + affine.for %i4 = affine_map<(d0) -> (d0)>(%c0) to affine_map<(d0) -> (d0)>(%K) { %6 = affine.load %arg1[%i4, %i3] : memref<?x?xf32> %7 = affine.load %arg0[%i2, %i4] : memref<?x?xf32> %8 = mulf %7, %6 : f32 diff --git a/mlir/test/Transforms/Vectorize/vectorize_3d.mlir b/mlir/test/Transforms/Vectorize/vectorize_3d.mlir index df60806155a..b7355c6e3cf 100644 --- a/mlir/test/Transforms/Vectorize/vectorize_3d.mlir +++ b/mlir/test/Transforms/Vectorize/vectorize_3d.mlir @@ -1,7 +1,7 @@ // RUN: mlir-opt %s -affine-vectorize -virtual-vector-size 32 -virtual-vector-size 64 -virtual-vector-size 256 --test-fastest-varying=2 --test-fastest-varying=1 --test-fastest-varying=0 | FileCheck %s // Permutation maps used in vectorization. -// CHECK: #[[map_proj_d0d1d2_d0d1d2:map[0-9]+]] = (d0, d1, d2) -> (d0, d1, d2) +// CHECK: #[[map_proj_d0d1d2_d0d1d2:map[0-9]+]] = affine_map<(d0, d1, d2) -> (d0, d1, d2)> func @vec3d(%A : memref<?x?x?xf32>) { %0 = dim %A, 0 : memref<?x?x?xf32> diff --git a/mlir/test/Transforms/Vectorize/vectorize_outer_loop_2d.mlir b/mlir/test/Transforms/Vectorize/vectorize_outer_loop_2d.mlir index e398144a222..39350c88610 100644 --- a/mlir/test/Transforms/Vectorize/vectorize_outer_loop_2d.mlir +++ b/mlir/test/Transforms/Vectorize/vectorize_outer_loop_2d.mlir @@ -1,7 +1,7 @@ // RUN: mlir-opt %s -affine-vectorize -virtual-vector-size 32 -virtual-vector-size 256 --test-fastest-varying=2 --test-fastest-varying=0 | FileCheck %s // Permutation maps used in vectorization. -// CHECK: #[[map_proj_d0d1d2_d0d2:map[0-9]+]] = (d0, d1, d2) -> (d0, d2) +// CHECK: #[[map_proj_d0d1d2_d0d2:map[0-9]+]] = affine_map<(d0, d1, d2) -> (d0, d2)> func @vec2d(%A : memref<?x?x?xf32>) { %M = dim %A, 0 : memref<?x?x?xf32> diff --git a/mlir/test/Transforms/Vectorize/vectorize_outer_loop_transpose_2d.mlir b/mlir/test/Transforms/Vectorize/vectorize_outer_loop_transpose_2d.mlir index d2de5f8d159..bac0c0cdb58 100644 --- a/mlir/test/Transforms/Vectorize/vectorize_outer_loop_transpose_2d.mlir +++ b/mlir/test/Transforms/Vectorize/vectorize_outer_loop_transpose_2d.mlir @@ -1,7 +1,7 @@ // RUN: mlir-opt %s -affine-vectorize -virtual-vector-size 32 -virtual-vector-size 256 --test-fastest-varying=0 --test-fastest-varying=2 | FileCheck %s // Permutation maps used in vectorization. -// CHECK: #[[map_proj_d0d1d2_d2d0:map[0-9]+]] = (d0, d1, d2) -> (d2, d0) +// CHECK: #[[map_proj_d0d1d2_d2d0:map[0-9]+]] = affine_map<(d0, d1, d2) -> (d2, d0)> func @vec2d(%A : memref<?x?x?xf32>) { %M = dim %A, 0 : memref<?x?x?xf32> diff --git a/mlir/test/Transforms/Vectorize/vectorize_transpose_2d.mlir b/mlir/test/Transforms/Vectorize/vectorize_transpose_2d.mlir index 765cd07ce7d..d86ad1ccbde 100644 --- a/mlir/test/Transforms/Vectorize/vectorize_transpose_2d.mlir +++ b/mlir/test/Transforms/Vectorize/vectorize_transpose_2d.mlir @@ -1,7 +1,7 @@ // RUN: mlir-opt %s -affine-vectorize -virtual-vector-size 32 -virtual-vector-size 256 --test-fastest-varying=0 --test-fastest-varying=1 | FileCheck %s // Permutation maps used in vectorization. -// CHECK-DAG: #[[map_proj_d0d1d2_d2d1:map[0-9]+]] = (d0, d1, d2) -> (d2, d1) +// CHECK-DAG: #[[map_proj_d0d1d2_d2d1:map[0-9]+]] = affine_map<(d0, d1, d2) -> (d2, d1)> func @vec2d(%A : memref<?x?x?xf32>) { %M = dim %A, 0 : memref<?x?x?xf32> diff --git a/mlir/test/Transforms/affine-data-copy.mlir b/mlir/test/Transforms/affine-data-copy.mlir index 5a0b2eb058c..c83beb18302 100644 --- a/mlir/test/Transforms/affine-data-copy.mlir +++ b/mlir/test/Transforms/affine-data-copy.mlir @@ -7,13 +7,13 @@ // footprint -- so that one could write a definite test case and not have to // update it each time something related to the cost functions change. -#map0 = (d0) -> (d0) -#map1 = (d0) -> (d0 + 128) +#map0 = affine_map<(d0) -> (d0)> +#map1 = affine_map<(d0) -> (d0 + 128)> // Map used to index the original memref while copying. -// CHECK-DAG: [[MEM_IDX_MAP:map[0-9]+]] = (d0, d1) -> (d0 + d1) +// CHECK-DAG: [[MEM_IDX_MAP:map[0-9]+]] = affine_map<(d0, d1) -> (d0 + d1)> // Map used to index the buffer while computing. -// CHECK-DAG: [[BUF_IDX_MAP:map[0-9]+]] = (d0, d1, d2, d3) -> (-d0 + d2, -d1 + d3) +// CHECK-DAG: [[BUF_IDX_MAP:map[0-9]+]] = affine_map<(d0, d1, d2, d3) -> (-d0 + d2, -d1 + d3)> // CHECK-LABEL: func @matmul func @matmul(%A: memref<4096x4096xf32>, %B: memref<4096x4096xf32>, %C: memref<4096x4096xf32>) -> memref<4096x4096xf32> { diff --git a/mlir/test/Transforms/affine-loop-invariant-code-motion.mlir b/mlir/test/Transforms/affine-loop-invariant-code-motion.mlir index f7143b7ad7d..4c9c0dbbf77 100644 --- a/mlir/test/Transforms/affine-loop-invariant-code-motion.mlir +++ b/mlir/test/Transforms/affine-loop-invariant-code-motion.mlir @@ -29,7 +29,7 @@ func @store_affine_apply() -> memref<10xf32> { %cf7 = constant 7.0 : f32 %m = alloc() : memref<10xf32> affine.for %arg0 = 0 to 10 { - %t0 = affine.apply (d1) -> (d1 + 1)(%arg0) + %t0 = affine.apply affine_map<(d1) -> (d1 + 1)>(%arg0) affine.store %cf7, %m[%t0] : memref<10xf32> } return %m : memref<10xf32> @@ -87,8 +87,8 @@ func @invariant_code_inside_affine_if() { %cf8 = constant 8.0 : f32 affine.for %arg0 = 0 to 10 { - %t0 = affine.apply (d1) -> (d1 + 1)(%arg0) - affine.if (d0, d1) : (d1 - d0 >= 0) (%arg0, %t0) { + %t0 = affine.apply affine_map<(d1) -> (d1 + 1)>(%arg0) + affine.if affine_set<(d0, d1) : (d1 - d0 >= 0)> (%arg0, %t0) { %cf9 = addf %cf8, %cf8 : f32 affine.store %cf9, %m[%arg0] : memref<10xf32> @@ -224,7 +224,7 @@ func @invariant_affine_if() { %cf8 = constant 8.0 : f32 affine.for %arg0 = 0 to 10 { affine.for %arg1 = 0 to 10 { - affine.if (d0, d1) : (d1 - d0 >= 0) (%arg0, %arg0) { + affine.if affine_set<(d0, d1) : (d1 - d0 >= 0)> (%arg0, %arg0) { %cf9 = addf %cf8, %cf8 : f32 affine.store %cf9, %m[%arg0] : memref<10xf32> @@ -249,7 +249,7 @@ func @invariant_affine_if2() { %cf8 = constant 8.0 : f32 affine.for %arg0 = 0 to 10 { affine.for %arg1 = 0 to 10 { - affine.if (d0, d1) : (d1 - d0 >= 0) (%arg0, %arg0) { + affine.if affine_set<(d0, d1) : (d1 - d0 >= 0)> (%arg0, %arg0) { %cf9 = addf %cf8, %cf8 : f32 affine.store %cf9, %m[%arg1] : memref<10xf32> @@ -276,10 +276,10 @@ func @invariant_affine_nested_if() { %cf8 = constant 8.0 : f32 affine.for %arg0 = 0 to 10 { affine.for %arg1 = 0 to 10 { - affine.if (d0, d1) : (d1 - d0 >= 0) (%arg0, %arg0) { + affine.if affine_set<(d0, d1) : (d1 - d0 >= 0)> (%arg0, %arg0) { %cf9 = addf %cf8, %cf8 : f32 affine.store %cf9, %m[%arg0] : memref<10xf32> - affine.if (d0, d1) : (d1 - d0 >= 0) (%arg0, %arg0) { + affine.if affine_set<(d0, d1) : (d1 - d0 >= 0)> (%arg0, %arg0) { affine.store %cf9, %m[%arg1] : memref<10xf32> } } @@ -308,10 +308,10 @@ func @invariant_affine_nested_if_else() { %cf8 = constant 8.0 : f32 affine.for %arg0 = 0 to 10 { affine.for %arg1 = 0 to 10 { - affine.if (d0, d1) : (d1 - d0 >= 0) (%arg0, %arg0) { + affine.if affine_set<(d0, d1) : (d1 - d0 >= 0)> (%arg0, %arg0) { %cf9 = addf %cf8, %cf8 : f32 affine.store %cf9, %m[%arg0] : memref<10xf32> - affine.if (d0, d1) : (d1 - d0 >= 0) (%arg0, %arg0) { + affine.if affine_set<(d0, d1) : (d1 - d0 >= 0)> (%arg0, %arg0) { affine.store %cf9, %m[%arg0] : memref<10xf32> } else { affine.store %cf9, %m[%arg1] : memref<10xf32> @@ -345,10 +345,10 @@ func @invariant_affine_nested_if_else2() { %cf8 = constant 8.0 : f32 affine.for %arg0 = 0 to 10 { affine.for %arg1 = 0 to 10 { - affine.if (d0, d1) : (d1 - d0 >= 0) (%arg0, %arg0) { + affine.if affine_set<(d0, d1) : (d1 - d0 >= 0)> (%arg0, %arg0) { %cf9 = addf %cf8, %cf8 : f32 %tload1 = affine.load %m[%arg0] : memref<10xf32> - affine.if (d0, d1) : (d1 - d0 >= 0) (%arg0, %arg0) { + affine.if affine_set<(d0, d1) : (d1 - d0 >= 0)> (%arg0, %arg0) { affine.store %cf9, %m2[%arg0] : memref<10xf32> } else { %tload2 = affine.load %m[%arg0] : memref<10xf32> @@ -381,10 +381,10 @@ func @invariant_affine_nested_if2() { %cf8 = constant 8.0 : f32 affine.for %arg0 = 0 to 10 { affine.for %arg1 = 0 to 10 { - affine.if (d0, d1) : (d1 - d0 >= 0) (%arg0, %arg0) { + affine.if affine_set<(d0, d1) : (d1 - d0 >= 0)> (%arg0, %arg0) { %cf9 = addf %cf8, %cf8 : f32 %v1 = affine.load %m[%arg0] : memref<10xf32> - affine.if (d0, d1) : (d1 - d0 >= 0) (%arg0, %arg0) { + affine.if affine_set<(d0, d1) : (d1 - d0 >= 0)> (%arg0, %arg0) { %v2 = affine.load %m[%arg0] : memref<10xf32> } } @@ -411,7 +411,7 @@ func @invariant_affine_for_inside_affine_if() { %cf8 = constant 8.0 : f32 affine.for %arg0 = 0 to 10 { affine.for %arg1 = 0 to 10 { - affine.if (d0, d1) : (d1 - d0 >= 0) (%arg0, %arg0) { + affine.if affine_set<(d0, d1) : (d1 - d0 >= 0)> (%arg0, %arg0) { %cf9 = addf %cf8, %cf8 : f32 affine.store %cf9, %m[%arg0] : memref<10xf32> affine.for %arg2 = 0 to 10 { diff --git a/mlir/test/Transforms/canonicalize.mlir b/mlir/test/Transforms/canonicalize.mlir index 16ee00923d2..e7be915159b 100644 --- a/mlir/test/Transforms/canonicalize.mlir +++ b/mlir/test/Transforms/canonicalize.mlir @@ -418,8 +418,8 @@ func @dyn_shape_fold(%L : index, %M : index) -> (memref<? x ? x i32>, memref<? x return %c, %d : memref<? x ? x i32>, memref<? x ? x f32> } -#map1 = (d0, d1)[s0, s1, s2] -> (d0 * s1 + d1 * s2 + s0) -#map2 = (d0, d1, d2)[s0, s1, s2] -> (d0 * s2 + d1 * s1 + d2 + s0) +#map1 = affine_map<(d0, d1)[s0, s1, s2] -> (d0 * s1 + d1 * s2 + s0)> +#map2 = affine_map<(d0, d1, d2)[s0, s1, s2] -> (d0 * s2 + d1 * s1 + d2 + s0)> // CHECK-LABEL: func @dim_op_fold(%arg0: index, %arg1: index, %arg2: index, func @dim_op_fold(%arg0: index, %arg1: index, %arg2: index, %BUF: memref<?xi8>, %M : index, %N : index, %K : index) { @@ -499,8 +499,8 @@ func @hoist_constant(%arg0: memref<8xi32>) { func @const_fold_propagate() -> memref<?x?xf32> { %VT_i = constant 512 : index - %VT_i_s = affine.apply (d0) -> (d0 floordiv 8) (%VT_i) - %VT_k_l = affine.apply (d0) -> (d0 floordiv 16) (%VT_i) + %VT_i_s = affine.apply affine_map<(d0) -> (d0 floordiv 8)> (%VT_i) + %VT_k_l = affine.apply affine_map<(d0) -> (d0 floordiv 16)> (%VT_i) // CHECK: = alloc() : memref<64x32xf32> %Av = alloc(%VT_i_s, %VT_k_l) : memref<?x?xf32> @@ -568,7 +568,7 @@ func @indirect_call_folding() { // // IMPORTANT NOTE: the operations in this test are exactly those produced by -// lowering affine.apply (i) -> (i mod 42) to standard operations. Please only +// lowering affine.apply affine_map<(i) -> (i mod 42)> to standard operations. Please only // change these operations together with the affine lowering pass tests. // // CHECK-LABEL: @lowered_affine_mod @@ -594,7 +594,7 @@ func @lowered_affine_mod() -> (index, index) { // // IMPORTANT NOTE: the operations in this test are exactly those produced by -// lowering affine.apply (i) -> (i mod 42) to standard operations. Please only +// lowering affine.apply affine_map<(i) -> (i mod 42)> to standard operations. Please only // change these operations together with the affine lowering pass tests. // // CHECK-LABEL: func @lowered_affine_floordiv @@ -626,7 +626,7 @@ func @lowered_affine_floordiv() -> (index, index) { // // IMPORTANT NOTE: the operations in this test are exactly those produced by -// lowering affine.apply (i) -> (i mod 42) to standard operations. Please only +// lowering affine.apply affine_map<(i) -> (i mod 42)> to standard operations. Please only // change these operations together with the affine lowering pass tests. // // CHECK-LABEL: func @lowered_affine_ceildiv @@ -683,15 +683,15 @@ func @cast_values(%arg0: tensor<*xi32>, %arg1: memref<?xi32>) -> (tensor<2xi32>, // ----- -#TEST_VIEW_MAP0 = (d0, d1)[s0, s1] -> (d0 * s1 + d1 + s0) -#TEST_VIEW_MAP1 = (d0, d1, d2)[s0, s1] -> (d0 * s1 + d1 * s0 + d2) -#TEST_VIEW_MAP2 = (d0, d1)[s0] -> (d0 * 4 + d1 + s0) +#TEST_VIEW_MAP0 = affine_map<(d0, d1)[s0, s1] -> (d0 * s1 + d1 + s0)> +#TEST_VIEW_MAP1 = affine_map<(d0, d1, d2)[s0, s1] -> (d0 * s1 + d1 * s0 + d2)> +#TEST_VIEW_MAP2 = affine_map<(d0, d1)[s0] -> (d0 * 4 + d1 + s0)> -// CHECK-DAG: #[[VIEW_MAP0:map[0-9]+]] = (d0, d1) -> (d0 * 11 + d1 + 15) -// CHECK-DAG: #[[VIEW_MAP1:map[0-9]+]] = (d0, d1)[s0] -> (d0 * 11 + s0 + d1) -// CHECK-DAG: #[[VIEW_MAP2:map[0-9]+]] = (d0, d1)[s0] -> (d0 * s0 + d1 + 15) -// CHECK-DAG: #[[VIEW_MAP3:map[0-9]+]] = (d0, d1, d2)[s0] -> (d0 * s0 + d1 * 7 + d2) -// CHECK-DAG: #[[VIEW_MAP4:map[0-9]+]] = (d0, d1) -> (d0 * 4 + d1 + 15) +// CHECK-DAG: #[[VIEW_MAP0:map[0-9]+]] = affine_map<(d0, d1) -> (d0 * 11 + d1 + 15)> +// CHECK-DAG: #[[VIEW_MAP1:map[0-9]+]] = affine_map<(d0, d1)[s0] -> (d0 * 11 + s0 + d1)> +// CHECK-DAG: #[[VIEW_MAP2:map[0-9]+]] = affine_map<(d0, d1)[s0] -> (d0 * s0 + d1 + 15)> +// CHECK-DAG: #[[VIEW_MAP3:map[0-9]+]] = affine_map<(d0, d1, d2)[s0] -> (d0 * s0 + d1 * 7 + d2)> +// CHECK-DAG: #[[VIEW_MAP4:map[0-9]+]] = affine_map<(d0, d1) -> (d0 * 4 + d1 + 15)> // CHECK-LABEL: func @view func @view(%arg0 : index) { @@ -745,15 +745,15 @@ func @view(%arg0 : index) { // ----- -// CHECK-DAG: #[[BASE_MAP0:map[0-9]+]] = (d0, d1, d2) -> (d0 * 64 + d1 * 4 + d2) -// CHECK-DAG: #[[SUBVIEW_MAP0:map[0-9]+]] = (d0, d1, d2)[s0] -> (d0 * 64 + s0 + d1 * 4 + d2) -// CHECK-DAG: #[[SUBVIEW_MAP1:map[0-9]+]] = (d0, d1, d2) -> (d0 * 64 + d1 * 4 + d2 + 79) -// CHECK-DAG: #[[SUBVIEW_MAP2:map[0-9]+]] = (d0, d1, d2) -> (d0 * 128 + d1 * 28 + d2 * 11) -// CHECK-DAG: #[[SUBVIEW_MAP3:map[0-9]+]] = (d0, d1, d2)[s0, s1, s2, s3] -> (d0 * s1 + s0 + d1 * s2 + d2 * s3) -// CHECK-DAG: #[[SUBVIEW_MAP4:map[0-9]+]] = (d0, d1, d2)[s0] -> (d0 * 128 + s0 + d1 * 28 + d2 * 11) -// CHECK-DAG: #[[SUBVIEW_MAP5:map[0-9]+]] = (d0, d1, d2)[s0, s1, s2] -> (d0 * s0 + d1 * s1 + d2 * s2 + 79) -// CHECK-DAG: #[[SUBVIEW_MAP6:map[0-9]+]] = (d0, d1)[s0] -> (d0 * 4 + s0 + d1) -// CHECK-DAG: #[[SUBVIEW_MAP7:map[0-9]+]] = (d0, d1) -> (d0 * 4 + d1 + 12) +// CHECK-DAG: #[[BASE_MAP0:map[0-9]+]] = affine_map<(d0, d1, d2) -> (d0 * 64 + d1 * 4 + d2)> +// CHECK-DAG: #[[SUBVIEW_MAP0:map[0-9]+]] = affine_map<(d0, d1, d2)[s0] -> (d0 * 64 + s0 + d1 * 4 + d2)> +// CHECK-DAG: #[[SUBVIEW_MAP1:map[0-9]+]] = affine_map<(d0, d1, d2) -> (d0 * 64 + d1 * 4 + d2 + 79)> +// CHECK-DAG: #[[SUBVIEW_MAP2:map[0-9]+]] = affine_map<(d0, d1, d2) -> (d0 * 128 + d1 * 28 + d2 * 11)> +// CHECK-DAG: #[[SUBVIEW_MAP3:map[0-9]+]] = affine_map<(d0, d1, d2)[s0, s1, s2, s3] -> (d0 * s1 + s0 + d1 * s2 + d2 * s3)> +// CHECK-DAG: #[[SUBVIEW_MAP4:map[0-9]+]] = affine_map<(d0, d1, d2)[s0] -> (d0 * 128 + s0 + d1 * 28 + d2 * 11)> +// CHECK-DAG: #[[SUBVIEW_MAP5:map[0-9]+]] = affine_map<(d0, d1, d2)[s0, s1, s2] -> (d0 * s0 + d1 * s1 + d2 * s2 + 79)> +// CHECK-DAG: #[[SUBVIEW_MAP6:map[0-9]+]] = affine_map<(d0, d1)[s0] -> (d0 * 4 + s0 + d1)> +// CHECK-DAG: #[[SUBVIEW_MAP7:map[0-9]+]] = affine_map<(d0, d1) -> (d0 * 4 + d1 + 12)> // CHECK-LABEL: func @subview // CHECK-SAME: %[[ARG0:.*]]: index, %[[ARG1:.*]]: index @@ -771,56 +771,56 @@ func @subview(%arg0 : index, %arg1 : index) -> (index, index) { %c15 = constant 15 : index // CHECK: %[[ALLOC0:.*]] = alloc() - %0 = alloc() : memref<8x16x4xf32, (d0, d1, d2) -> (d0 * 64 + d1 * 4 + d2)> + %0 = alloc() : memref<8x16x4xf32, affine_map<(d0, d1, d2) -> (d0 * 64 + d1 * 4 + d2)>> // Test: subview with constant base memref and constant operands is folded. // Note that the subview uses the base memrefs layout map because it used // zero offset and unit stride arguments. // CHECK: std.subview %[[ALLOC0]][][][] : memref<8x16x4xf32, #[[BASE_MAP0]]> to memref<7x11x2xf32, #[[BASE_MAP0]]> %1 = subview %0[%c0, %c0, %c0][%c7, %c11, %c2][%c1, %c1, %c1] - : memref<8x16x4xf32, (d0, d1, d2) -> (d0 * 64 + d1 * 4 + d2)> to + : memref<8x16x4xf32, affine_map<(d0, d1, d2) -> (d0 * 64 + d1 * 4 + d2)>> to memref<?x?x?xf32, - (d0, d1, d2)[s0, s1, s2, s3] -> (d0 * s1 + d1 * s2 + d2 * s3 + s0)> + affine_map<(d0, d1, d2)[s0, s1, s2, s3] -> (d0 * s1 + d1 * s2 + d2 * s3 + s0)>> load %1[%c0, %c0, %c0] : memref<?x?x?xf32, - (d0, d1, d2)[s0, s1, s2, s3] -> (d0 * s1 + d1 * s2 + d2 * s3 + s0)> + affine_map<(d0, d1, d2)[s0, s1, s2, s3] -> (d0 * s1 + d1 * s2 + d2 * s3 + s0)>> // Test: subview with one dynamic operand should not be folded. // CHECK: std.subview %[[ALLOC0]][%[[C0]], %[[ARG0]], %[[C0]]][][] : memref<8x16x4xf32, #[[BASE_MAP0]]> to memref<7x11x15xf32, #[[SUBVIEW_MAP0]]> %2 = subview %0[%c0, %arg0, %c0][%c7, %c11, %c15][%c1, %c1, %c1] - : memref<8x16x4xf32, (d0, d1, d2) -> (d0 * 64 + d1 * 4 + d2)> to + : memref<8x16x4xf32, affine_map<(d0, d1, d2) -> (d0 * 64 + d1 * 4 + d2)>> to memref<?x?x?xf32, - (d0, d1, d2)[s0, s1, s2, s3] -> (d0 * s1 + d1 * s2 + d2 * s3 + s0)> + affine_map<(d0, d1, d2)[s0, s1, s2, s3] -> (d0 * s1 + d1 * s2 + d2 * s3 + s0)>> load %2[%c0, %c0, %c0] : memref<?x?x?xf32, - (d0, d1, d2)[s0, s1, s2, s3] -> (d0 * s1 + d1 * s2 + d2 * s3 + s0)> + affine_map<(d0, d1, d2)[s0, s1, s2, s3] -> (d0 * s1 + d1 * s2 + d2 * s3 + s0)>> // CHECK: %[[ALLOC1:.*]] = alloc(%[[ARG0]]) - %3 = alloc(%arg0) : memref<?x16x4xf32, (d0, d1, d2) -> (d0 * 64 + d1 * 4 + d2)> + %3 = alloc(%arg0) : memref<?x16x4xf32, affine_map<(d0, d1, d2) -> (d0 * 64 + d1 * 4 + d2)>> // Test: subview with constant operands but dynamic base memref is folded as long as the strides and offset of the base memref are static. // CHECK: std.subview %[[ALLOC1]][][][] : memref<?x16x4xf32, #[[BASE_MAP0]]> to memref<7x11x15xf32, #[[BASE_MAP0]]> %4 = subview %3[%c0, %c0, %c0][%c7, %c11, %c15][%c1, %c1, %c1] - : memref<?x16x4xf32, (d0, d1, d2) -> (d0 * 64 + d1 * 4 + d2)> to + : memref<?x16x4xf32, affine_map<(d0, d1, d2) -> (d0 * 64 + d1 * 4 + d2)>> to memref<?x?x?xf32, - (d0, d1, d2)[s0, s1, s2, s3] -> (d0 * s1 + d1 * s2 + d2 * s3 + s0)> + affine_map<(d0, d1, d2)[s0, s1, s2, s3] -> (d0 * s1 + d1 * s2 + d2 * s3 + s0)>> load %4[%c0, %c0, %c0] : memref<?x?x?xf32, - (d0, d1, d2)[s0, s1, s2, s3] -> (d0 * s1 + d1 * s2 + d2 * s3 + s0)> + affine_map<(d0, d1, d2)[s0, s1, s2, s3] -> (d0 * s1 + d1 * s2 + d2 * s3 + s0)>> // Test: subview offset operands are folded correctly w.r.t. base strides. // CHECK: std.subview %[[ALLOC0]][][][] : memref<8x16x4xf32, #[[BASE_MAP0]]> to memref<7x11x2xf32, #[[SUBVIEW_MAP1]]> %5 = subview %0[%c1, %c2, %c7][%c7, %c11, %c2][%c1, %c1, %c1] - : memref<8x16x4xf32, (d0, d1, d2) -> (d0 * 64 + d1 * 4 + d2)> to + : memref<8x16x4xf32, affine_map<(d0, d1, d2) -> (d0 * 64 + d1 * 4 + d2)>> to memref<?x?x?xf32, - (d0, d1, d2)[s0, s1, s2, s3] -> (d0 * s1 + d1 * s2 + d2 * s3 + s0)> + affine_map<(d0, d1, d2)[s0, s1, s2, s3] -> (d0 * s1 + d1 * s2 + d2 * s3 + s0)>> load %5[%c0, %c0, %c0] : memref<?x?x?xf32, - (d0, d1, d2)[s0, s1, s2, s3] -> (d0 * s1 + d1 * s2 + d2 * s3 + s0)> + affine_map<(d0, d1, d2)[s0, s1, s2, s3] -> (d0 * s1 + d1 * s2 + d2 * s3 + s0)>> // Test: subview stride operands are folded correctly w.r.t. base strides. // CHECK: std.subview %[[ALLOC0]][][][] : memref<8x16x4xf32, #[[BASE_MAP0]]> to memref<7x11x2xf32, #[[SUBVIEW_MAP2]]> %6 = subview %0[%c0, %c0, %c0][%c7, %c11, %c2][%c2, %c7, %c11] - : memref<8x16x4xf32, (d0, d1, d2) -> (d0 * 64 + d1 * 4 + d2)> to + : memref<8x16x4xf32, affine_map<(d0, d1, d2) -> (d0 * 64 + d1 * 4 + d2)>> to memref<?x?x?xf32, - (d0, d1, d2)[s0, s1, s2, s3] -> (d0 * s1 + d1 * s2 + d2 * s3 + s0)> + affine_map<(d0, d1, d2)[s0, s1, s2, s3] -> (d0 * s1 + d1 * s2 + d2 * s3 + s0)>> load %6[%c0, %c0, %c0] : memref<?x?x?xf32, - (d0, d1, d2)[s0, s1, s2, s3] -> (d0 * s1 + d1 * s2 + d2 * s3 + s0)> + affine_map<(d0, d1, d2)[s0, s1, s2, s3] -> (d0 * s1 + d1 * s2 + d2 * s3 + s0)>> // Test: subview shape are folded, but offsets and strides are not even if base memref is static // CHECK: std.subview %[[ALLOC0]][%[[ARG0]], %[[ARG0]], %[[ARG0]]][][%[[ARG1]], %[[ARG1]], %[[ARG1]]] : memref<8x16x4xf32, #[[BASE_MAP0]]> to memref<7x11x2xf32, #[[SUBVIEW_MAP3]]> @@ -870,9 +870,9 @@ func @subview(%arg0 : index, %arg1 : index) -> (index, index) { // Test: dim on subview is rewritten to size operand. %7 = dim %4, 0 : memref<?x?x?xf32, - (d0, d1, d2)[s0, s1, s2, s3] -> (d0 * s1 + d1 * s2 + d2 * s3 + s0)> + affine_map<(d0, d1, d2)[s0, s1, s2, s3] -> (d0 * s1 + d1 * s2 + d2 * s3 + s0)>> %8 = dim %4, 1 : memref<?x?x?xf32, - (d0, d1, d2)[s0, s1, s2, s3] -> (d0 * s1 + d1 * s2 + d2 * s3 + s0)> + affine_map<(d0, d1, d2)[s0, s1, s2, s3] -> (d0 * s1 + d1 * s2 + d2 * s3 + s0)>> // CHECK: return %[[C7]], %[[C11]] return %7, %8 : index, index diff --git a/mlir/test/Transforms/constant-fold.mlir b/mlir/test/Transforms/constant-fold.mlir index a24aad2847a..b156ca91875 100644 --- a/mlir/test/Transforms/constant-fold.mlir +++ b/mlir/test/Transforms/constant-fold.mlir @@ -170,13 +170,13 @@ func @affine_apply(%variable : index) -> (index, index, index) { // CHECK:[[C1159:%.+]] = constant 1159 : index // CHECK:[[C1152:%.+]] = constant 1152 : index - %x0 = affine.apply (d0, d1)[S0] -> ( (d0 + 128 * S0) floordiv 128 + d1 mod 128) + %x0 = affine.apply affine_map<(d0, d1)[S0] -> ( (d0 + 128 * S0) floordiv 128 + d1 mod 128)> (%c177, %c211)[%N] - %x1 = affine.apply (d0, d1)[S0] -> (128 * (S0 ceildiv 128)) + %x1 = affine.apply affine_map<(d0, d1)[S0] -> (128 * (S0 ceildiv 128))> (%c177, %c211)[%N] // CHECK:[[C42:%.+]] = constant 42 : index - %y = affine.apply (d0) -> (42) (%variable) + %y = affine.apply affine_map<(d0) -> (42)> (%variable) // CHECK: return [[C1159]], [[C1152]], [[C42]] return %x0, %x1, %y : index, index, index diff --git a/mlir/test/Transforms/cse.mlir b/mlir/test/Transforms/cse.mlir index 8cc41e6a1a0..8e526176a02 100644 --- a/mlir/test/Transforms/cse.mlir +++ b/mlir/test/Transforms/cse.mlir @@ -1,7 +1,7 @@ // RUN: mlir-opt %s -pass-pipeline='func(cse)' | FileCheck %s -// CHECK-DAG: #map0 = (d0) -> (d0 mod 2) -#map0 = (d0) -> (d0 mod 2) +// CHECK-DAG: #map0 = affine_map<(d0) -> (d0 mod 2)> +#map0 = affine_map<(d0) -> (d0 mod 2)> // CHECK-LABEL: @simple_constant func @simple_constant() -> (i32, i32) { diff --git a/mlir/test/Transforms/dma-generate.mlir b/mlir/test/Transforms/dma-generate.mlir index 0ca34554287..9724f990f97 100644 --- a/mlir/test/Transforms/dma-generate.mlir +++ b/mlir/test/Transforms/dma-generate.mlir @@ -13,8 +13,8 @@ // ----- // Index of the buffer for the second DMA is remapped. -// CHECK-DAG: [[MAP_PLUS_256:#map[0-9]+]] = (d0) -> (d0 + 256) -// CHECK-DAG: [[MAP0:#map[0-9]+]] = (d0) -> (d0) +// CHECK-DAG: [[MAP_PLUS_256:#map[0-9]+]] = affine_map<(d0) -> (d0 + 256)> +// CHECK-DAG: [[MAP0:#map[0-9]+]] = affine_map<(d0) -> (d0)> // CHECK-LABEL: func @loop_nest_1d() { func @loop_nest_1d() { @@ -52,7 +52,7 @@ func @loop_nest_1d() { // CHECK-NEXT: return affine.for %i = 0 to 256 { affine.load %A[%i] : memref<256 x f32> - %idx = affine.apply (d0) -> (d0 + 256)(%i) + %idx = affine.apply affine_map<(d0) -> (d0 + 256)>(%i) affine.load %B[%idx] : memref<512 x f32> affine.load %F[%i] : memref<256 x f32, 2> } @@ -124,18 +124,18 @@ func @loop_nest_high_d(%A: memref<512 x 32 x f32>, affine.for %kT = 0 to 32 { affine.for %iT = 0 to 32 { affine.for %kk = 0 to 16 { // k intratile - %k = affine.apply (d0, d1) -> (16*d0 + d1) (%kT, %kk) + %k = affine.apply affine_map<(d0, d1) -> (16*d0 + d1)> (%kT, %kk) %v0 = affine.load %B[%k, %jT] : memref<512 x 32 x f32> "foo"(%v0) : (f32) -> () } affine.for %ii = 0 to 16 { // i intratile. - %i = affine.apply (d0, d1) -> (16*d0 + d1)(%iT, %ii) + %i = affine.apply affine_map<(d0, d1) -> (16*d0 + d1)>(%iT, %ii) %v1 = affine.load %A[%i, %kT] : memref<512 x 32 x f32> "bar"(%v1) : (f32) -> () } affine.for %ii_ = 0 to 16 { // i intratile. %v2 = "abc_compute"() : () -> f32 - %i_ = affine.apply (d0, d1) -> (16*d0 + d1)(%iT, %ii_) + %i_ = affine.apply affine_map<(d0, d1) -> (16*d0 + d1)>(%iT, %ii_) %v3 = affine.load %C[%i_, %jT] : memref<512 x 32 x f32> %v4 = "addf32"(%v2, %v3) : (f32, f32) -> (f32) affine.store %v4, %C[%i_, %jT] : memref<512 x 32 x f32> @@ -174,7 +174,7 @@ func @loop_nest_modulo() { affine.for %i = 0 to 32 step 4 { // DMAs will be performed at this level (%j is the first unit stride loop) affine.for %j = 0 to 8 { - %idx = affine.apply (d0) -> (d0 mod 2) (%j) + %idx = affine.apply affine_map<(d0) -> (d0 mod 2)> (%j) // A buffer of size 32 x 2 will be allocated (original buffer was 256 x 8). %v = affine.load %A[%i, %idx] : memref<256 x 8 x f32> } @@ -198,8 +198,8 @@ func @loop_nest_tiled() -> memref<256x1024xf32> { // CHECK-NEXT: affine.dma_wait // CHECK-NEXT: affine.for %{{.*}} = #map // CHECK-NEXT: affine.for %{{.*}} = #map - affine.for %i2 = (d0) -> (d0)(%i0) to (d0) -> (d0 + 32)(%i0) { - affine.for %i3 = (d0) -> (d0)(%i1) to (d0) -> (d0 + 32)(%i1) { + affine.for %i2 = affine_map<(d0) -> (d0)>(%i0) to affine_map<(d0) -> (d0 + 32)>(%i0) { + affine.for %i3 = affine_map<(d0) -> (d0)>(%i1) to affine_map<(d0) -> (d0 + 32)>(%i1) { // CHECK: %{{.*}} = affine.load %{{.*}}[-%{{.*}} + %{{.*}}, -%{{.*}} + %{{.*}}] : memref<32x32xf32, 2> %1 = affine.load %0[%i2, %i3] : memref<256x1024xf32> } // CHECK-NEXT: } @@ -221,7 +221,7 @@ func @dma_constant_dim_access(%A : memref<100x100xf32>) { // CHECK: affine.dma_start %{{.*}}[%{{.*}}, %{{.*}}], %{{.*}}[%{{.*}}, %{{.*}}], %{{.*}}[%{{.*}}], %{{.*}} : memref<100x100xf32>, memref<1x100xf32, 2>, // CHECK-NEXT: affine.dma_wait %{{.*}}[%{{.*}}], %{{.*}} : memref<1xi32> affine.for %i = 0 to 100 { - affine.for %j = 0 to ()[s0] -> (s0) ()[%N] { + affine.for %j = 0 to affine_map<()[s0] -> (s0)> ()[%N] { // CHECK: %{{.*}} = affine.load %{{.*}}[0, %{{.*}}] : memref<1x100xf32, 2> affine.load %A[%one, %j] : memref<100 x 100 x f32> } @@ -231,14 +231,14 @@ func @dma_constant_dim_access(%A : memref<100x100xf32>) { // ----- -// CHECK-DAG: [[MAP_SYM_SHIFT:#map[0-9]+]] = (d0, d1)[s0, s1] -> (d1 + s0 + s1) +// CHECK-DAG: [[MAP_SYM_SHIFT:#map[0-9]+]] = affine_map<(d0, d1)[s0, s1] -> (d1 + s0 + s1)> // CHECK-LABEL: func @dma_with_symbolic_accesses func @dma_with_symbolic_accesses(%A : memref<100x100xf32>, %M : index) { %N = constant 9 : index affine.for %i = 0 to 100 { affine.for %j = 0 to 100 { - %idy = affine.apply (d0, d1) [s0, s1] -> (d1 + s0 + s1)(%i, %j)[%M, %N] + %idy = affine.apply affine_map<(d0, d1) [s0, s1] -> (d1 + s0 + s1)>(%i, %j)[%M, %N] affine.load %A[%i, %idy] : memref<100 x 100 x f32> } } @@ -269,7 +269,7 @@ func @dma_with_symbolic_loop_bounds(%A : memref<100x100xf32>, %M : index, %N: in // CHECK-NEXT: affine.dma_wait %{{.*}}[%{{.*}}], %{{.*}} : memref<1xi32> affine.for %i = 0 to 100 { affine.for %j = %M to %N { - %idy = affine.apply (d1) [s0] -> (d1 + s0)(%j)[%K] + %idy = affine.apply affine_map<(d1) [s0] -> (d1 + s0)>(%j)[%K] affine.load %A[%i, %idy] : memref<100 x 100 x f32> } } @@ -301,9 +301,9 @@ func @dma_memref_3d(%arg0: memref<1024x1024x1024xf32>) { affine.for %i = 0 to 1024 { affine.for %j = 0 to 1024 { affine.for %k = 0 to 1024 { - %idx = affine.apply (d0) -> (d0 mod 128)(%i) - %idy = affine.apply (d0) -> (d0 mod 128)(%j) - %idz = affine.apply (d0) -> (d0 mod 128)(%k) + %idx = affine.apply affine_map<(d0) -> (d0 mod 128)>(%i) + %idy = affine.apply affine_map<(d0) -> (d0 mod 128)>(%j) + %idz = affine.apply affine_map<(d0) -> (d0 mod 128)>(%k) // DMA with nested striding (or emulating with loop around strided DMA) // not yet implemented. // CHECK: %{{.*}} = affine.load %{{.*}}[%{{.*}}, %{{.*}}, %{{.*}}] : memref<1024x1024x1024xf32> @@ -317,10 +317,10 @@ func @dma_memref_3d(%arg0: memref<1024x1024x1024xf32>) { // ----- -// CHECK-DAG: [[MAP_PLUS_64:#map[0-9]+]] = (d0) -> (d0 + 64) -// CHECK-DAG: [[MAP_PLUS_128:#map[0-9]+]] = (d0) -> (d0 + 128) -// CHECK-DAG: [[MAP_PLUS_2:#map[0-9]+]] = (d0) -> (d0 + 2) -// CHECK-DAG: [[MAP_PLUS_192:#map[0-9]+]] = (d0) -> (d0 + 192) +// CHECK-DAG: [[MAP_PLUS_64:#map[0-9]+]] = affine_map<(d0) -> (d0 + 64)> +// CHECK-DAG: [[MAP_PLUS_128:#map[0-9]+]] = affine_map<(d0) -> (d0 + 128)> +// CHECK-DAG: [[MAP_PLUS_2:#map[0-9]+]] = affine_map<(d0) -> (d0 + 2)> +// CHECK-DAG: [[MAP_PLUS_192:#map[0-9]+]] = affine_map<(d0) -> (d0 + 192)> // The first load accesses ([2,258), [128,384)) // The second load accesses ([64,320), [2,258)) @@ -334,16 +334,16 @@ func @multi_load_store_union() { %A = alloc() : memref<512 x 512 x f32> affine.for %i = 0 to 256 { affine.for %j = 0 to 256 { - %idx = affine.apply (d0) -> (d0 + 64)(%i) - %idy = affine.apply (d0) -> (d0 + 128)(%j) - %ishift = affine.apply (d0) -> (d0 + 2)(%i) - %jshift = affine.apply (d0) -> (d0 + 2)(%j) + %idx = affine.apply affine_map<(d0) -> (d0 + 64)>(%i) + %idy = affine.apply affine_map<(d0) -> (d0 + 128)>(%j) + %ishift = affine.apply affine_map<(d0) -> (d0 + 2)>(%i) + %jshift = affine.apply affine_map<(d0) -> (d0 + 2)>(%j) %u = affine.load %A[%ishift, %idy] : memref<512 x 512 x f32> %v = affine.load %A[%idx, %jshift] : memref<512 x 512 x f32> - %sidx = affine.apply (d0) -> (d0 + 128)(%i) - %sidy = affine.apply (d0) -> (d0 + 192)(%j) + %sidx = affine.apply affine_map<(d0) -> (d0 + 128)>(%i) + %sidy = affine.apply affine_map<(d0) -> (d0 + 192)>(%j) affine.store %u, %A[%ishift, %sidy] : memref<512 x 512 x f32> affine.store %v, %A[%sidx, %jshift] : memref<512 x 512 x f32> @@ -458,7 +458,7 @@ func @dma_mixed_loop_blocks() { // CHECK-LABEL: func @relative_loop_bounds func @relative_loop_bounds(%arg0: memref<1027xf32>) { affine.for %i0 = 0 to 1024 { - affine.for %i2 = (d0) -> (d0)(%i0) to (d0) -> (d0 + 4)(%i0) { + affine.for %i2 = affine_map<(d0) -> (d0)>(%i0) to affine_map<(d0) -> (d0 + 4)>(%i0) { %0 = constant 0.0 : f32 affine.store %0, %arg0[%i2] : memref<1027xf32> } @@ -478,8 +478,8 @@ func @relative_loop_bounds(%arg0: memref<1027xf32>) { // ----- -// CHECK-DAG: [[MAP_READ_OFFSET:#map[0-9]+]] = (d0) -> (d0 + 100) -// CHECK-DAG: [[MAP_WRITE_OFFSET:#map[0-9]+]] = (d0) -> (d0 + 25) +// CHECK-DAG: [[MAP_READ_OFFSET:#map[0-9]+]] = affine_map<(d0) -> (d0 + 100)> +// CHECK-DAG: [[MAP_WRITE_OFFSET:#map[0-9]+]] = affine_map<(d0) -> (d0 + 25)> func @test_read_write_region_union() { %0 = alloc() : memref<256xf32> @@ -488,8 +488,8 @@ func @test_read_write_region_union() { // read region: [100, 110) // write region: [25, 35) // union region: [25, 110) - %a0 = affine.apply (d0) -> (d0 + 100)(%i0) - %a1 = affine.apply (d0) -> (d0 + 25)(%i0) + %a0 = affine.apply affine_map<(d0) -> (d0 + 100)>(%i0) + %a1 = affine.apply affine_map<(d0) -> (d0 + 25)>(%i0) %1 = affine.load %0[%a0] : memref<256xf32> affine.store %1, %0[%a1] : memref<256xf32> } @@ -515,9 +515,9 @@ func @test_read_write_region_union() { // This should create a buffer of size 2 affine.for %arg2. -#map_lb = (d0) -> (d0) -#map_ub = (d0) -> (d0 + 3) -#map_acc = (d0) -> (d0 floordiv 8) +#map_lb = affine_map<(d0) -> (d0)> +#map_ub = affine_map<(d0) -> (d0 + 3)> +#map_acc = affine_map<(d0) -> (d0 floordiv 8)> // CHECK-LABEL: func @test_analysis_util func @test_analysis_util(%arg0: memref<4x4x16x1xf32>, %arg1: memref<144x9xf32>, %arg2: memref<2xf32>) -> (memref<144x9xf32>, memref<2xf32>) { %c0 = constant 0 : index @@ -545,11 +545,11 @@ func @test_analysis_util(%arg0: memref<4x4x16x1xf32>, %arg1: memref<144x9xf32>, // ---- -#map3 = (d0) -> (d0) -#map12 = (d0) -> (d0 + 3) -#map14 = (d0, d1) -> ((d0 + d1 * 72) floordiv 2304 + ((((d0 + d1 * 72) mod 2304) mod 1152) mod 9) floordiv 3) -#map15 = (d0, d1) -> ((d0 + d1 * 72) mod 2304 - (((d0 + d1 * 72) mod 2304) floordiv 1152) * 1151 - ((((d0 + d1 * 72) mod 2304) mod 1152) floordiv 9) * 9 - (((((d0 + d1 * 72) mod 2304) mod 1152) mod 9) floordiv 3) * 3) -#map16 = (d0, d1) -> (((((d0 + d1 * 72) mod 2304) mod 1152) floordiv 9) floordiv 8) +#map3 = affine_map<(d0) -> (d0)> +#map12 = affine_map<(d0) -> (d0 + 3)> +#map14 = affine_map<(d0, d1) -> ((d0 + d1 * 72) floordiv 2304 + ((((d0 + d1 * 72) mod 2304) mod 1152) mod 9) floordiv 3)> +#map15 = affine_map<(d0, d1) -> ((d0 + d1 * 72) mod 2304 - (((d0 + d1 * 72) mod 2304) floordiv 1152) * 1151 - ((((d0 + d1 * 72) mod 2304) mod 1152) floordiv 9) * 9 - (((((d0 + d1 * 72) mod 2304) mod 1152) mod 9) floordiv 3) * 3)> +#map16 = affine_map<(d0, d1) -> (((((d0 + d1 * 72) mod 2304) mod 1152) floordiv 9) floordiv 8)> // Test for test case in b/128303048 #4. func @test_memref_bounds(%arg0: memref<4x4x16x1xvector<8x128xf32>>, %arg1: memref<144x9xvector<8x128xf32>>, %arg2: memref<2xvector<8x128xf32>>) -> (memref<144x9xvector<8x128xf32>>, memref<2xvector<8x128xf32>>) { %c0 = constant 0 : index @@ -586,9 +586,9 @@ func @load_store_same_memref(%arg0: memref<256x1024xf32>) { // FAST-MEM-16KB: affine.for %{{.*}} affine.for %i1 = 0 to 1024 step 4 { // FAST-MEM-16KB: affine.for %{{.*}} - affine.for %i2 = (d0) -> (d0)(%i0) to (d0) -> (d0 + 4)(%i0) { + affine.for %i2 = affine_map<(d0) -> (d0)>(%i0) to affine_map<(d0) -> (d0 + 4)>(%i0) { // FAST-MEM-16KB: affine.for %{{.*}} - affine.for %i3 = (d0) -> (d0)(%i1) to (d0) -> (d0 + 4)(%i1) { + affine.for %i3 = affine_map<(d0) -> (d0)>(%i1) to affine_map<(d0) -> (d0 + 4)>(%i1) { %3 = affine.load %arg0[%i2, %i3] : memref<256x1024xf32> %4 = mulf %3, %3 : f32 affine.store %4, %arg0[%i2, %i3] : memref<256x1024xf32> @@ -610,8 +610,8 @@ func @load_store_same_memref(%arg0: memref<256x1024xf32>) { // %arg0 and %arg1. So, its DMA can be hoisted one level up and placed under // %j, while the DMAs for arg0 and arg1 appear right under the %k loop. -#map0 = (d0) -> (d0) -#map1 = (d0) -> (d0 + 4) +#map0 = affine_map<(d0) -> (d0)> +#map1 = affine_map<(d0) -> (d0 + 4)> // FAST-MEM-16KB-LABEL: func @simple_matmul func @simple_matmul(%arg0: memref<8x8xvector<64xf32>>, %arg1: memref<8x8xvector<64xf32>>, %arg2: memref<8x8xvector<64xf32>>) -> memref<8x8xvector<64xf32>> { affine.for %i = 0 to 8 step 4 { diff --git a/mlir/test/Transforms/loop-fusion-slice-computation.mlir b/mlir/test/Transforms/loop-fusion-slice-computation.mlir index f6872c20131..dd1a8a339ca 100644 --- a/mlir/test/Transforms/loop-fusion-slice-computation.mlir +++ b/mlir/test/Transforms/loop-fusion-slice-computation.mlir @@ -28,12 +28,12 @@ func @slice_depth1_loop_nest_with_offsets() { %cst = constant 7.000000e+00 : f32 affine.for %i0 = 0 to 16 { // expected-remark@-1 {{slice ( src loop: 1, dst loop: 0, depth: 1 : insert point: (1, 2) loop bounds: [(d0) -> (d0 + 3), (d0) -> (d0 + 4)] )}} - %a0 = affine.apply (d0) -> (d0 + 2)(%i0) + %a0 = affine.apply affine_map<(d0) -> (d0 + 2)>(%i0) affine.store %cst, %0[%a0] : memref<100xf32> } affine.for %i1 = 4 to 8 { // expected-remark@-1 {{slice ( src loop: 0, dst loop: 1, depth: 1 : insert point: (1, 0) loop bounds: [(d0) -> (d0 - 3), (d0) -> (d0 - 2)] )}} - %a1 = affine.apply (d0) -> (d0 - 1)(%i1) + %a1 = affine.apply affine_map<(d0) -> (d0 - 1)>(%i1) %1 = affine.load %0[%a1] : memref<100xf32> } return diff --git a/mlir/test/Transforms/loop-fusion.mlir b/mlir/test/Transforms/loop-fusion.mlir index 339cc31f549..78b45d6a485 100644 --- a/mlir/test/Transforms/loop-fusion.mlir +++ b/mlir/test/Transforms/loop-fusion.mlir @@ -70,8 +70,8 @@ func @should_fuse_reduction_to_pointwise() { // ----- -// CHECK-DAG: [[MAP_SHIFT_MINUS_ONE_R1:#map[0-9]+]] = (d0) -> (d0 - 1) -// CHECK-DAG: [[MAP_SHIFT_BY_ONE:#map[0-9]+]] = (d0) -> (d0 + 1) +// CHECK-DAG: [[MAP_SHIFT_MINUS_ONE_R1:#map[0-9]+]] = affine_map<(d0) -> (d0 - 1)> +// CHECK-DAG: [[MAP_SHIFT_BY_ONE:#map[0-9]+]] = affine_map<(d0) -> (d0 + 1)> // CHECK-LABEL: func @should_fuse_loop_nests_with_shifts() { func @should_fuse_loop_nests_with_shifts() { @@ -80,8 +80,8 @@ func @should_fuse_loop_nests_with_shifts() { affine.for %i0 = 0 to 9 { affine.for %i1 = 0 to 9 { - %idx = affine.apply (d0) -> (d0 + 1) (%i0) - %idy = affine.apply (d0) -> (d0 + 1) (%i1) + %idx = affine.apply affine_map<(d0) -> (d0 + 1)> (%i0) + %idy = affine.apply affine_map<(d0) -> (d0 + 1)> (%i1) affine.store %cf7, %a[%idx, %idy] : memref<10x10xf32> } } @@ -413,7 +413,7 @@ func @should_fuse_no_top_level_access() { // ----- -#set0 = (d0) : (1 == 0) +#set0 = affine_set<(d0) : (1 == 0)> // CHECK-LABEL: func @should_not_fuse_if_inst_at_top_level() { func @should_not_fuse_if_inst_at_top_level() { @@ -441,7 +441,7 @@ func @should_not_fuse_if_inst_at_top_level() { // ----- -#set0 = (d0) : (1 == 0) +#set0 = affine_set<(d0) : (1 == 0)> // CHECK-LABEL: func @should_not_fuse_if_inst_in_loop_nest() { func @should_not_fuse_if_inst_in_loop_nest() { @@ -508,9 +508,9 @@ func @permute_and_fuse() { // ----- -// CHECK-DAG: [[MAP0:#map[0-9]+]] = (d0, d1) -> (d0 * 4 + d1) -// CHECK-DAG: [[MAP1:#map[0-9]+]] = (d0) -> (d0 floordiv 4) -// CHECK-DAG: [[MAP2:#map[0-9]+]] = (d0) -> (d0 mod 4) +// CHECK-DAG: [[MAP0:#map[0-9]+]] = affine_map<(d0, d1) -> (d0 * 4 + d1)> +// CHECK-DAG: [[MAP1:#map[0-9]+]] = affine_map<(d0) -> (d0 floordiv 4)> +// CHECK-DAG: [[MAP2:#map[0-9]+]] = affine_map<(d0) -> (d0 mod 4)> // Reshape from a 64 x f32 to 16 x 4 x f32. // CHECK-LABEL: func @fuse_reshape_64_16_4 @@ -519,8 +519,8 @@ func @fuse_reshape_64_16_4(%in : memref<64xf32>) { affine.for %i0 = 0 to 64 { %v = affine.load %in[%i0] : memref<64xf32> - %idx = affine.apply (d0) -> (d0 floordiv 4) (%i0) - %idy = affine.apply (d0) -> (d0 mod 4) (%i0) + %idx = affine.apply affine_map<(d0) -> (d0 floordiv 4)> (%i0) + %idy = affine.apply affine_map<(d0) -> (d0 mod 4)> (%i0) affine.store %v, %out[%idx, %idy] : memref<16x4xf32> } @@ -540,9 +540,9 @@ func @fuse_reshape_64_16_4(%in : memref<64xf32>) { } // ----- -// CHECK-DAG: [[MAP0:#map[0-9]+]] = (d0) -> (d0 floordiv 4) -// CHECK-DAG: [[MAP1:#map[0-9]+]] = (d0) -> (d0 mod 4) -// CHECK-DAG: [[MAP2:#map[0-9]+]] = (d0, d1) -> (d0 * 4 + d1) +// CHECK-DAG: [[MAP0:#map[0-9]+]] = affine_map<(d0) -> (d0 floordiv 4)> +// CHECK-DAG: [[MAP1:#map[0-9]+]] = affine_map<(d0) -> (d0 mod 4)> +// CHECK-DAG: [[MAP2:#map[0-9]+]] = affine_map<(d0, d1) -> (d0 * 4 + d1)> // Reshape a 16x4xf32 to 64xf32. // CHECK-LABEL: func @fuse_reshape_16_4_64 @@ -553,7 +553,7 @@ func @fuse_reshape_16_4_64() { affine.for %i0 = 0 to 16 { affine.for %i1 = 0 to 4 { %v = affine.load %in[%i0, %i1] : memref<16x4xf32> - %idx = affine.apply (d0, d1) -> (4*d0 + d1) (%i0, %i1) + %idx = affine.apply affine_map<(d0, d1) -> (4*d0 + d1)> (%i0, %i1) affine.store %v, %out[%idx] : memref<64xf32> } } @@ -604,13 +604,13 @@ func @R6_to_R2_reshape_square() -> memref<64x9xi32> { affine.for %ii = 0 to 64 { affine.for %jj = 0 to 9 { // Convert output coordinates to linear index. - %a0 = affine.apply (d0, d1) -> (d0 * 9 + d1) (%ii, %jj) - %0 = affine.apply (d0) -> (d0 floordiv (2 * 3 * 3 * 16 * 1))(%a0) - %1 = affine.apply (d0) -> ((d0 mod 288) floordiv (3 * 3 * 16 * 1))(%a0) - %2 = affine.apply (d0) -> (((d0 mod 288) mod 144) floordiv (3 * 16 * 1))(%a0) - %3 = affine.apply (d0) -> ((((d0 mod 288) mod 144) mod 48) floordiv (16 * 1))(%a0) - %4 = affine.apply (d0) -> ((((d0 mod 288) mod 144) mod 48) mod 16)(%a0) - %5 = affine.apply (d0) -> (((((d0 mod 144) mod 144) mod 48) mod 16) mod 1)(%a0) + %a0 = affine.apply affine_map<(d0, d1) -> (d0 * 9 + d1)> (%ii, %jj) + %0 = affine.apply affine_map<(d0) -> (d0 floordiv (2 * 3 * 3 * 16 * 1))>(%a0) + %1 = affine.apply affine_map<(d0) -> ((d0 mod 288) floordiv (3 * 3 * 16 * 1))>(%a0) + %2 = affine.apply affine_map<(d0) -> (((d0 mod 288) mod 144) floordiv (3 * 16 * 1))>(%a0) + %3 = affine.apply affine_map<(d0) -> ((((d0 mod 288) mod 144) mod 48) floordiv (16 * 1))>(%a0) + %4 = affine.apply affine_map<(d0) -> ((((d0 mod 288) mod 144) mod 48) mod 16)>(%a0) + %5 = affine.apply affine_map<(d0) -> (((((d0 mod 144) mod 144) mod 48) mod 16) mod 1)>(%a0) %v = affine.load %in[%0, %1, %2, %3, %4, %5] : memref<2x2x3x3x16x1xi32> affine.store %v, %out[%ii, %jj] : memref<64x9xi32> } @@ -628,18 +628,18 @@ func @R6_to_R2_reshape_square() -> memref<64x9xi32> { // Everything above is fused to a single 2-d loop nest, and the 6-d tensor %in // is eliminated if -memref-dataflow-opt is also supplied. // -// CHECK-DAG: [[MAP0:#map[0-9]+]] = (d0, d1) -> ((d0 * 9 + d1) floordiv 288) -// CHECK-DAG: [[MAP1:#map[0-9]+]] = (d0, d1) -> (((d0 * 9 + d1) mod 288) floordiv 144) -// CHECK-DAG: [[MAP2:#map[0-9]+]] = (d0, d1) -> ((((d0 * 9 + d1) mod 288) mod 144) floordiv 48) -// CHECK-DAG: [[MAP3:#map[0-9]+]] = (d0, d1) -> (((((d0 * 9 + d1) mod 288) mod 144) mod 48) floordiv 16) -// CHECK-DAG: [[MAP4:#map[0-9]+]] = (d0, d1) -> (((((d0 * 9 + d1) mod 288) mod 144) mod 48) mod 16) -// CHECK-DAG: [[MAP11:#map[0-9]+]] = (d0, d1) -> (d0 * 9 + d1) -// CHECK-DAG: [[MAP12:#map[0-9]+]] = (d0) -> (d0 floordiv 288) -// CHECK-DAG: [[MAP13:#map[0-9]+]] = (d0) -> ((d0 mod 288) floordiv 144) -// CHECK-DAG: [[MAP14:#map[0-9]+]] = (d0) -> (((d0 mod 288) mod 144) floordiv 48) -// CHECK-DAG: [[MAP15:#map[0-9]+]] = (d0) -> ((((d0 mod 288) mod 144) mod 48) floordiv 16) -// CHECK-DAG: [[MAP16:#map[0-9]+]] = (d0) -> ((((d0 mod 288) mod 144) mod 48) mod 16) -// CHECK-DAG: [[MAP17:#map[0-9]+]] = (d0) -> (0) +// CHECK-DAG: [[MAP0:#map[0-9]+]] = affine_map<(d0, d1) -> ((d0 * 9 + d1) floordiv 288)> +// CHECK-DAG: [[MAP1:#map[0-9]+]] = affine_map<(d0, d1) -> (((d0 * 9 + d1) mod 288) floordiv 144)> +// CHECK-DAG: [[MAP2:#map[0-9]+]] = affine_map<(d0, d1) -> ((((d0 * 9 + d1) mod 288) mod 144) floordiv 48)> +// CHECK-DAG: [[MAP3:#map[0-9]+]] = affine_map<(d0, d1) -> (((((d0 * 9 + d1) mod 288) mod 144) mod 48) floordiv 16)> +// CHECK-DAG: [[MAP4:#map[0-9]+]] = affine_map<(d0, d1) -> (((((d0 * 9 + d1) mod 288) mod 144) mod 48) mod 16)> +// CHECK-DAG: [[MAP11:#map[0-9]+]] = affine_map<(d0, d1) -> (d0 * 9 + d1)> +// CHECK-DAG: [[MAP12:#map[0-9]+]] = affine_map<(d0) -> (d0 floordiv 288)> +// CHECK-DAG: [[MAP13:#map[0-9]+]] = affine_map<(d0) -> ((d0 mod 288) floordiv 144)> +// CHECK-DAG: [[MAP14:#map[0-9]+]] = affine_map<(d0) -> (((d0 mod 288) mod 144) floordiv 48)> +// CHECK-DAG: [[MAP15:#map[0-9]+]] = affine_map<(d0) -> ((((d0 mod 288) mod 144) mod 48) floordiv 16)> +// CHECK-DAG: [[MAP16:#map[0-9]+]] = affine_map<(d0) -> ((((d0 mod 288) mod 144) mod 48) mod 16)> +// CHECK-DAG: [[MAP17:#map[0-9]+]] = affine_map<(d0) -> (0)> // // CHECK-LABEL: func @R6_to_R2_reshape @@ -675,21 +675,21 @@ func @R6_to_R2_reshape_square() -> memref<64x9xi32> { // CHECK-LABEL: func @fuse_symbolic_bounds func @fuse_symbolic_bounds(%M : index, %N : index) { - %N_plus_5 = affine.apply (d0) -> (d0 + 5)(%N) + %N_plus_5 = affine.apply affine_map<(d0) -> (d0 + 5)>(%N) %m = alloc(%M, %N_plus_5) : memref<? x ? x f32> %c0 = constant 0.0 : f32 %s = constant 5 : index affine.for %i0 = 0 to %M { - affine.for %i1 = 0 to (d0) -> (d0 + 5) (%N) { + affine.for %i1 = 0 to affine_map<(d0) -> (d0 + 5)> (%N) { affine.store %c0, %m[%i0, %i1] : memref<? x ? x f32> } } affine.for %i2 = 0 to %M { affine.for %i3 = 0 to %N { - %idy = affine.apply (d0)[s0] -> (d0 + s0) (%i3)[%s] + %idy = affine.apply affine_map<(d0)[s0] -> (d0 + s0)> (%i3)[%s] %v = affine.load %m[%i2, %idy] : memref<? x ? x f32> } } @@ -790,7 +790,7 @@ func @should_fuse_at_src_depth1_and_dst_depth1() { } // ----- -// CHECK: [[MAP0:#map[0-9]+]] = (d0, d1) -> (d0 * 10 + d1) +// CHECK: [[MAP0:#map[0-9]+]] = affine_map<(d0, d1) -> (d0 * 10 + d1)> // CHECK-LABEL: func @should_fuse_src_depth1_at_dst_depth2 func @should_fuse_src_depth1_at_dst_depth2() { @@ -803,7 +803,7 @@ func @should_fuse_src_depth1_at_dst_depth2() { affine.for %i1 = 0 to 10 { affine.for %i2 = 0 to 10 { - %a0 = affine.apply (d0, d1) -> (d0 * 10 + d1) (%i1, %i2) + %a0 = affine.apply affine_map<(d0, d1) -> (d0 * 10 + d1)> (%i1, %i2) %v0 = affine.load %a[%a0] : memref<100xf32> } } @@ -1207,17 +1207,17 @@ func @R3_to_R2_reshape() { affine.for %ii = 0 to 32 { affine.for %jj = 0 to 3 { - %a0 = affine.apply (d0, d1) -> (d0 * 3 + d1) (%ii, %jj) - %idx = affine.apply (d0) -> (d0 floordiv (3 * 16)) (%a0) + %a0 = affine.apply affine_map<(d0, d1) -> (d0 * 3 + d1)> (%ii, %jj) + %idx = affine.apply affine_map<(d0) -> (d0 floordiv (3 * 16))> (%a0) %v = affine.load %in[%idx, %jj, %c0] : memref<2x3x16xi32> } } return } -// CHECK-DAG: [[MAP0:#map[0-9]+]] = (d0, d1) -> ((d0 * 3 + d1) floordiv 48) -// CHECK-DAG: [[MAP1:#map[0-9]+]] = (d0, d1) -> (d0 * 3 + d1) -// CHECK-DAG: [[MAP2:#map[0-9]+]] = (d0) -> (d0 floordiv 48) +// CHECK-DAG: [[MAP0:#map[0-9]+]] = affine_map<(d0, d1) -> ((d0 * 3 + d1) floordiv 48)> +// CHECK-DAG: [[MAP1:#map[0-9]+]] = affine_map<(d0, d1) -> (d0 * 3 + d1)> +// CHECK-DAG: [[MAP2:#map[0-9]+]] = affine_map<(d0) -> (d0 floordiv 48)> // CHECK-LABEL: func @R3_to_R2_reshape() // CHECK-DAG: %{{.*}} = alloc() : memref<1x1x1xi32> @@ -1441,8 +1441,8 @@ func @should_fuse_and_preserve_dep_on_constant() { // ----- -// CHECK: [[MAP2:#map[0-9]+]] = (d0, d1) -> (d0 * 16 - d1 + 15) -// CHECK: [[MAP3:#map[0-9]+]] = (d0, d1) -> (d0 * 16 + d1) +// CHECK: [[MAP2:#map[0-9]+]] = affine_map<(d0, d1) -> (d0 * 16 - d1 + 15)> +// CHECK: [[MAP3:#map[0-9]+]] = affine_map<(d0, d1) -> (d0 * 16 + d1)> // CHECK-LABEL: func @should_fuse_at_depth_above_loop_carried_dependence(%{{.*}}: memref<64x4xf32>, %{{.*}}: memref<64x4xf32>) { func @should_fuse_at_depth_above_loop_carried_dependence(%arg0: memref<64x4xf32>, %arg1: memref<64x4xf32>) { @@ -1456,19 +1456,19 @@ func @should_fuse_at_depth_above_loop_carried_dependence(%arg0: memref<64x4xf32> affine.for %i2 = 0 to 4 { affine.for %i3 = 0 to 4 { affine.for %i4 = 0 to 16 { - %1 = affine.apply (d0, d1) -> (d0 * 16 - d1 + 15)(%i3, %i4) + %1 = affine.apply affine_map<(d0, d1) -> (d0 * 16 - d1 + 15)>(%i3, %i4) %2 = affine.load %arg1[%1, %i2] : memref<64x4xf32> "op0"(%2) : (f32) -> () } affine.for %i5 = 0 to 4 { affine.for %i6 = 0 to 16 { - %3 = affine.apply (d0, d1) -> (d0 * 16 - d1 + 15)(%i5, %i6) + %3 = affine.apply affine_map<(d0, d1) -> (d0 * 16 - d1 + 15)>(%i5, %i6) %4 = affine.load %arg0[%3, %i3] : memref<64x4xf32> "op1"(%4) : (f32) -> () } affine.for %i7 = 0 to 16 { %5 = "op2"() : () -> (f32) - %6 = affine.apply (d0, d1) -> (d0 * 16 + d1)(%i5, %i7) + %6 = affine.apply affine_map<(d0, d1) -> (d0 * 16 + d1)>(%i5, %i7) %7 = affine.load %out[%6, %i2] : memref<64x4xf32> %8 = addf %7, %5 : f32 affine.store %8, %out[%6, %i2] : memref<64x4xf32> @@ -1666,10 +1666,10 @@ func @should_fuse_live_out_writer(%arg0 : memref<10xf32>) -> memref<10xf32> { // The fused slice has 16 iterations from along %i0. -// CHECK-DAG: [[MAP_LB:#map[0-9]+]] = (d0) -> (d0 * 16) -// CHECK-DAG: [[MAP_UB:#map[0-9]+]] = (d0) -> (d0 * 16 + 16) +// CHECK-DAG: [[MAP_LB:#map[0-9]+]] = affine_map<(d0) -> (d0 * 16)> +// CHECK-DAG: [[MAP_UB:#map[0-9]+]] = affine_map<(d0) -> (d0 * 16 + 16)> -#map = (d0, d1) -> (d0 * 16 + d1) +#map = affine_map<(d0, d1) -> (d0 * 16 + d1)> // CHECK-LABEL: slice_tile func @slice_tile(%arg0: memref<128x8xf32>, %arg1: memref<32x8xf32>, %0 : f32) -> memref<32x8xf32> { @@ -1732,9 +1732,9 @@ func @test_add_slice_bounds() { affine.for %i0 = 0 to 10 { affine.for %i1 = 0 to 10 { affine.for %i2 = 0 to 10 { - %a0 = affine.apply (d0) -> (d0) (%i0) - %a1 = affine.apply (d0) -> (d0) (%i0) - %a2 = affine.apply (d0, d1) -> (d0 - d1) (%a0, %a1) + %a0 = affine.apply affine_map<(d0) -> (d0)> (%i0) + %a1 = affine.apply affine_map<(d0) -> (d0)> (%i0) + %a2 = affine.apply affine_map<(d0, d1) -> (d0 - d1)> (%a0, %a1) affine.store %cf7, %a[%a2] : memref<10xf32> } } @@ -1931,7 +1931,7 @@ func @should_not_slice_past_slice_barrier() { // ----- -#map0 = (d0, d1) -> (d0 * 16 + d1) +#map0 = affine_map<(d0, d1) -> (d0 * 16 + d1)> func @fuse_across_dim_mismatch(%arg0: memref<4x4x16x1xf32>, %arg1: memref<144x9xf32>, %arg2: memref<9xf32>) { %1 = alloc() : memref<144x4xf32> %2 = constant 0.0 : f32 @@ -1955,7 +1955,7 @@ func @fuse_across_dim_mismatch(%arg0: memref<4x4x16x1xf32>, %arg1: memref<144x9x } return } -// MAXIMAL: #map0 = (d0, d1) -> (d0 * 16 + d1) +// MAXIMAL: #map0 = affine_map<(d0, d1) -> (d0 * 16 + d1)> // MAXIMAL-LABEL: func @fuse_across_dim_mismatch // MAXIMAL: %{{.*}} = alloc() : memref<1x1xf32> // MAXIMAL: affine.for %{{.*}} = 0 to 9 { @@ -1973,14 +1973,14 @@ func @fuse_across_dim_mismatch(%arg0: memref<4x4x16x1xf32>, %arg1: memref<144x9x // ----- -#map3 = (d0, d1) -> ((d0 * 72 + d1) floordiv 2304) -#map4 = (d0, d1) -> (((d0 * 72 + d1) mod 2304) floordiv 1152) -#map5 = (d0, d1) -> (((((d0 * 72 + d1) mod 2304) mod 1152) floordiv 9) floordiv 8) -#map6 = (d0, d1) -> (((((d0 * 72 + d1) mod 2304) mod 1152) mod 9) floordiv 3) -#map7 = (d0, d1) -> (((((d0 * 72 + d1) mod 2304) mod 1152) mod 9) mod 3) -#map10 = (d0, d1) -> (d0 * 16 + d1) -#map11 = (d0, d1) -> (d0 * 16 + d1) -#map12 = (d0, d1) -> (d0 * 16 - d1 + 15) +#map3 = affine_map<(d0, d1) -> ((d0 * 72 + d1) floordiv 2304)> +#map4 = affine_map<(d0, d1) -> (((d0 * 72 + d1) mod 2304) floordiv 1152)> +#map5 = affine_map<(d0, d1) -> (((((d0 * 72 + d1) mod 2304) mod 1152) floordiv 9) floordiv 8)> +#map6 = affine_map<(d0, d1) -> (((((d0 * 72 + d1) mod 2304) mod 1152) mod 9) floordiv 3)> +#map7 = affine_map<(d0, d1) -> (((((d0 * 72 + d1) mod 2304) mod 1152) mod 9) mod 3)> +#map10 = affine_map<(d0, d1) -> (d0 * 16 + d1)> +#map11 = affine_map<(d0, d1) -> (d0 * 16 + d1)> +#map12 = affine_map<(d0, d1) -> (d0 * 16 - d1 + 15)> func @fuse_across_varying_dims_complex(%arg0: f32) { %c0 = constant 0 : index %0 = alloc() : memref<2x2x3x3x16x1xf32> @@ -2021,13 +2021,13 @@ func @fuse_across_varying_dims_complex(%arg0: f32) { } return } -// MAXIMAL-DAG: [[MAP0:#map[0-9]+]] = (d0, d1) -> ((d0 * 72 + d1) floordiv 2304) -// MAXIMAL-DAG: [[MAP1:#map[0-9]+]] = (d0, d1) -> (((d0 * 72 + d1) mod 2304) floordiv 1152) -// MAXIMAL-DAG: [[MAP2:#map[0-9]+]] = (d0, d1) -> (((((d0 * 72 + d1) mod 2304) mod 1152) floordiv 9) floordiv 8) -// MAXIMAL-DAG: [[MAP3:#map[0-9]+]] = (d0, d1) -> (((((d0 * 72 + d1) mod 2304) mod 1152) mod 9) floordiv 3) -// MAXIMAL-DAG: [[MAP4:#map[0-9]+]] = (d0, d1) -> (((((d0 * 72 + d1) mod 2304) mod 1152) mod 9) mod 3) -// MAXIMAL-DAG: [[MAP7:#map[0-9]+]] = (d0, d1) -> (d0 * 16 + d1) -// MAXIMAL-DAG: [[MAP8:#map[0-9]+]] = (d0, d1) -> (d0 * 16 - d1 + 15) +// MAXIMAL-DAG: [[MAP0:#map[0-9]+]] = affine_map<(d0, d1) -> ((d0 * 72 + d1) floordiv 2304)> +// MAXIMAL-DAG: [[MAP1:#map[0-9]+]] = affine_map<(d0, d1) -> (((d0 * 72 + d1) mod 2304) floordiv 1152)> +// MAXIMAL-DAG: [[MAP2:#map[0-9]+]] = affine_map<(d0, d1) -> (((((d0 * 72 + d1) mod 2304) mod 1152) floordiv 9) floordiv 8)> +// MAXIMAL-DAG: [[MAP3:#map[0-9]+]] = affine_map<(d0, d1) -> (((((d0 * 72 + d1) mod 2304) mod 1152) mod 9) floordiv 3)> +// MAXIMAL-DAG: [[MAP4:#map[0-9]+]] = affine_map<(d0, d1) -> (((((d0 * 72 + d1) mod 2304) mod 1152) mod 9) mod 3)> +// MAXIMAL-DAG: [[MAP7:#map[0-9]+]] = affine_map<(d0, d1) -> (d0 * 16 + d1)> +// MAXIMAL-DAG: [[MAP8:#map[0-9]+]] = affine_map<(d0, d1) -> (d0 * 16 - d1 + 15)> // MAXIMAL-LABEL: func @fuse_across_varying_dims_complex // MAXIMAL-NEXT: %{{.*}} = alloc() : memref<64x1xf32> // MAXIMAL-NEXT: %{{.*}} = constant 0 : index diff --git a/mlir/test/Transforms/loop-invariant-code-motion.mlir b/mlir/test/Transforms/loop-invariant-code-motion.mlir index 4d742acf246..1c39d56a28e 100644 --- a/mlir/test/Transforms/loop-invariant-code-motion.mlir +++ b/mlir/test/Transforms/loop-invariant-code-motion.mlir @@ -70,8 +70,8 @@ func @invariant_code_inside_affine_if() { %cf8 = constant 8.0 : f32 affine.for %arg0 = 0 to 10 { - %t0 = affine.apply (d1) -> (d1 + 1)(%arg0) - affine.if (d0, d1) : (d1 - d0 >= 0) (%arg0, %t0) { + %t0 = affine.apply affine_map<(d1) -> (d1 + 1)>(%arg0) + affine.if affine_set<(d0, d1) : (d1 - d0 >= 0)> (%arg0, %t0) { %cf9 = addf %cf8, %cf8 : f32 affine.store %cf9, %m[%arg0] : memref<10xf32> @@ -96,7 +96,7 @@ func @invariant_affine_if() { %cf8 = constant 8.0 : f32 affine.for %arg0 = 0 to 10 { affine.for %arg1 = 0 to 10 { - affine.if (d0, d1) : (d1 - d0 >= 0) (%arg0, %arg0) { + affine.if affine_set<(d0, d1) : (d1 - d0 >= 0)> (%arg0, %arg0) { %cf9 = addf %cf8, %cf8 : f32 } } @@ -117,7 +117,7 @@ func @invariant_affine_if2() { %cf8 = constant 8.0 : f32 affine.for %arg0 = 0 to 10 { affine.for %arg1 = 0 to 10 { - affine.if (d0, d1) : (d1 - d0 >= 0) (%arg0, %arg0) { + affine.if affine_set<(d0, d1) : (d1 - d0 >= 0)> (%arg0, %arg0) { %cf9 = addf %cf8, %cf8 : f32 affine.store %cf9, %m[%arg1] : memref<10xf32> } @@ -142,9 +142,9 @@ func @invariant_affine_nested_if() { %cf8 = constant 8.0 : f32 affine.for %arg0 = 0 to 10 { affine.for %arg1 = 0 to 10 { - affine.if (d0, d1) : (d1 - d0 >= 0) (%arg0, %arg0) { + affine.if affine_set<(d0, d1) : (d1 - d0 >= 0)> (%arg0, %arg0) { %cf9 = addf %cf8, %cf8 : f32 - affine.if (d0, d1) : (d1 - d0 >= 0) (%arg0, %arg0) { + affine.if affine_set<(d0, d1) : (d1 - d0 >= 0)> (%arg0, %arg0) { %cf10 = addf %cf9, %cf9 : f32 } } @@ -172,10 +172,10 @@ func @invariant_affine_nested_if_else() { %cf8 = constant 8.0 : f32 affine.for %arg0 = 0 to 10 { affine.for %arg1 = 0 to 10 { - affine.if (d0, d1) : (d1 - d0 >= 0) (%arg0, %arg0) { + affine.if affine_set<(d0, d1) : (d1 - d0 >= 0)> (%arg0, %arg0) { %cf9 = addf %cf8, %cf8 : f32 affine.store %cf9, %m[%arg0] : memref<10xf32> - affine.if (d0, d1) : (d1 - d0 >= 0) (%arg0, %arg0) { + affine.if affine_set<(d0, d1) : (d1 - d0 >= 0)> (%arg0, %arg0) { %cf10 = addf %cf9, %cf9 : f32 } else { affine.store %cf9, %m[%arg1] : memref<10xf32> diff --git a/mlir/test/Transforms/loop-tiling.mlir b/mlir/test/Transforms/loop-tiling.mlir index cf0208faf4f..c0a583f52cf 100644 --- a/mlir/test/Transforms/loop-tiling.mlir +++ b/mlir/test/Transforms/loop-tiling.mlir @@ -3,9 +3,9 @@ // ----- -// CHECK-DAG: [[MAP0:#map[0-9]+]] = (d0) -> (d0 + 32) -// CHECK-DAG: [[MAP1:#map[0-9]+]] = (d0) -> (d0 + 32, 50) -// CHECK-DAG: [[IDENTITY:#map[0-9]+]] = (d0) -> (d0) +// CHECK-DAG: [[MAP0:#map[0-9]+]] = affine_map<(d0) -> (d0 + 32)> +// CHECK-DAG: [[MAP1:#map[0-9]+]] = affine_map<(d0) -> (d0 + 32, 50)> +// CHECK-DAG: [[IDENTITY:#map[0-9]+]] = affine_map<(d0) -> (d0)> // CHECK-LABEL: func @loop_tiling() // CHECK-NEXT: affine.for %{{.*}} = 0 to 256 step 32 { @@ -55,18 +55,18 @@ func @loop_tiling() { // ----- -// CHECK-DAG: [[IDENTITY:#map[0-9]+]] = (d0) -> (d0) -// CHECK-DAG: [[LB:#map[0-9]+]] = ()[s0] -> (0, s0) -// CHECK-DAG: [[UB:#map[0-9]+]] = ()[s0, s1] -> (s0, 4096 floordiv s1) -// CHECK-DAG: [[UB_INTRA_TILE:#map[0-9]+]] = (d0)[s0, s1] -> (d0 + 32, s0, 4096 floordiv s1) +// CHECK-DAG: [[IDENTITY:#map[0-9]+]] = affine_map<(d0) -> (d0)> +// CHECK-DAG: [[LB:#map[0-9]+]] = affine_map<()[s0] -> (0, s0)> +// CHECK-DAG: [[UB:#map[0-9]+]] = affine_map<()[s0, s1] -> (s0, 4096 floordiv s1)> +// CHECK-DAG: [[UB_INTRA_TILE:#map[0-9]+]] = affine_map<(d0)[s0, s1] -> (d0 + 32, s0, 4096 floordiv s1)> -#lb = ()[s0] -> (0, s0) -#ub = ()[s0, s1] -> (s0, 4096 floordiv s1) +#lb = affine_map<()[s0] -> (0, s0)> +#ub = affine_map<()[s0, s1] -> (s0, 4096 floordiv s1)> // CHECK-LABEL: func @loop_max_min_bound(%{{.*}}: memref<?xi32>, %{{.*}}: index, %{{.*}}: index) { func @loop_max_min_bound(%A : memref<? x i32>, %L : index, %U : index) { %M = dim %A, 0 : memref<? x i32> affine.for %iTT = max #lb()[%L] to min #ub()[%M, %U] { - %out = affine.apply (d0) -> (d0) (%iTT) + %out = affine.apply affine_map<(d0) -> (d0)> (%iTT) } return // CHECK: affine.for %{{.*}} = max [[LB]]()[%{{.*}}] to min [[UB]]()[%{{.*}}, %{{.*}}] step 32 { @@ -105,7 +105,7 @@ func @simple_matmul(%arg0: memref<256x256xvector<64xf32>>, %arg1: memref<256x256 // ----- -// CHECK-DAG: [[UBMAP:#map[0-9]+]] = (d0)[s0] -> (d0 + 32, s0) +// CHECK-DAG: [[UBMAP:#map[0-9]+]] = affine_map<(d0)[s0] -> (d0 + 32, s0)> func @tile_with_symbolic_loop_upper_bounds(%arg0: memref<?x?xf32>, %arg1: memref<?x?xf32>, %arg2: memref<?x?xf32>) { %cst = constant 0.000000e+00 : f32 @@ -148,13 +148,13 @@ func @tile_with_symbolic_loop_upper_bounds(%arg0: memref<?x?xf32>, %arg1: memref // ----- -// CHECK-DAG: [[MAP0:#map[0-9]+]] = (d0) -> (d0) -// CHECK-DAG: [[MAP1:#map[0-9]+]] = ()[s0, s1] -> (s0 + s1) -// CHECK-DAG: [[UBMAP:#map[0-9]+]] = (d0)[s0, s1] -> (d0 + 32, s0 + s1) +// CHECK-DAG: [[MAP0:#map[0-9]+]] = affine_map<(d0) -> (d0)> +// CHECK-DAG: [[MAP1:#map[0-9]+]] = affine_map<()[s0, s1] -> (s0 + s1)> +// CHECK-DAG: [[UBMAP:#map[0-9]+]] = affine_map<(d0)[s0, s1] -> (d0 + 32, s0 + s1)> func @tile_with_loop_upper_bounds_in_two_symbols(%arg0: memref<?xf32>, %limit: index) { %dim0 = dim %arg0, 0 : memref<?xf32> - affine.for %i0 = 0 to ()[s0, s1] -> (s0 + s1) ()[%dim0, %limit] { + affine.for %i0 = 0 to affine_map<()[s0, s1] -> (s0 + s1)> ()[%dim0, %limit] { %v0 = affine.load %arg0[%i0] : memref<?xf32> } return diff --git a/mlir/test/Transforms/lower-affine.mlir b/mlir/test/Transforms/lower-affine.mlir index 1c3de885adf..c422090194b 100644 --- a/mlir/test/Transforms/lower-affine.mlir +++ b/mlir/test/Transforms/lower-affine.mlir @@ -114,7 +114,7 @@ func @more_imperfectly_nested_loops() { // CHECK-NEXT: } func @affine_apply_loops_shorthand(%N : index) { affine.for %i = 0 to %N { - affine.for %j = (d0)[]->(d0)(%i)[] to 42 { + affine.for %j = affine_map<(d0)[]->(d0)>(%i)[] to 42 { call @body2(%i, %j) : (index, index) -> () } } @@ -125,8 +125,8 @@ func @affine_apply_loops_shorthand(%N : index) { func @get_idx() -> (index) -#set1 = (d0) : (20 - d0 >= 0) -#set2 = (d0) : (d0 - 10 >= 0) +#set1 = affine_set<(d0) : (20 - d0 >= 0)> +#set2 = affine_set<(d0) : (d0 - 10 >= 0)> // CHECK-LABEL: func @if_only // CHECK-NEXT: %[[v0:.*]] = call @get_idx() : () -> index @@ -215,7 +215,7 @@ func @nested_ifs() { return } -#setN = (d0)[N,M,K,L] : (N - d0 + 1 >= 0, N - 1 >= 0, M - 1 >= 0, K - 1 >= 0, L - 42 == 0) +#setN = affine_set<(d0)[N,M,K,L] : (N - d0 + 1 >= 0, N - 1 >= 0, M - 1 >= 0, K - 1 >= 0, L - 42 == 0)> // CHECK-LABEL: func @multi_cond // CHECK-NEXT: %[[v0:.*]] = call @get_idx() : () -> index @@ -311,8 +311,8 @@ func @if_for() { return } -#lbMultiMap = (d0)[s0] -> (d0, s0 - d0) -#ubMultiMap = (d0)[s0] -> (s0, d0 + 10) +#lbMultiMap = affine_map<(d0)[s0] -> (d0, s0 - d0)> +#ubMultiMap = affine_map<(d0)[s0] -> (s0, d0 + 10)> // CHECK-LABEL: func @loop_min_max // CHECK-NEXT: %[[c0:.*]] = constant 0 : index @@ -344,7 +344,7 @@ func @loop_min_max(%N : index) { return } -#map_7_values = (i) -> (i, i, i, i, i, i, i) +#map_7_values = affine_map<(i) -> (i, i, i, i, i, i, i)> // Check that the "min" (cmpi "slt" + select) reduction sequence is emitted // correctly for a an affine map with 7 results. @@ -378,13 +378,13 @@ func @min_reduction_tree(%v : index) { ///////////////////////////////////////////////////////////////////// -#map0 = () -> (0) -#map1 = ()[s0] -> (s0) -#map2 = (d0) -> (d0) -#map3 = (d0)[s0] -> (d0 + s0 + 1) -#map4 = (d0,d1,d2,d3)[s0,s1,s2] -> (d0 + 2*d1 + 3*d2 + 4*d3 + 5*s0 + 6*s1 + 7*s2) -#map5 = (d0,d1,d2) -> (d0,d1,d2) -#map6 = (d0,d1,d2) -> (d0 + d1 + d2) +#map0 = affine_map<() -> (0)> +#map1 = affine_map<()[s0] -> (s0)> +#map2 = affine_map<(d0) -> (d0)> +#map3 = affine_map<(d0)[s0] -> (d0 + s0 + 1)> +#map4 = affine_map<(d0,d1,d2,d3)[s0,s1,s2] -> (d0 + 2*d1 + 3*d2 + 4*d3 + 5*s0 + 6*s1 + 7*s2)> +#map5 = affine_map<(d0,d1,d2) -> (d0,d1,d2)> +#map6 = affine_map<(d0,d1,d2) -> (d0 + d1 + d2)> // CHECK-LABEL: func @affine_applies( func @affine_applies(%arg0 : index) { @@ -442,7 +442,7 @@ func @args_ret_affine_apply(index, index) -> (index, index) { // applying constant folding transformation after affine lowering. //===---------------------------------------------------------------------===// -#mapmod = (i) -> (i mod 42) +#mapmod = affine_map<(i) -> (i mod 42)> // --------------------------------------------------------------------------// // IMPORTANT NOTE: if you change this test, also change the @lowered_affine_mod @@ -461,7 +461,7 @@ func @affine_apply_mod(%arg0 : index) -> (index) { return %0 : index } -#mapfloordiv = (i) -> (i floordiv 42) +#mapfloordiv = affine_map<(i) -> (i floordiv 42)> // --------------------------------------------------------------------------// // IMPORTANT NOTE: if you change this test, also change the @lowered_affine_mod @@ -483,7 +483,7 @@ func @affine_apply_floordiv(%arg0 : index) -> (index) { return %0 : index } -#mapceildiv = (i) -> (i ceildiv 42) +#mapceildiv = affine_map<(i) -> (i ceildiv 42)> // --------------------------------------------------------------------------// // IMPORTANT NOTE: if you change this test, also change the @lowered_affine_mod diff --git a/mlir/test/Transforms/memref-bound-check.mlir b/mlir/test/Transforms/memref-bound-check.mlir index c81e44d1bfd..25ec800465e 100644 --- a/mlir/test/Transforms/memref-bound-check.mlir +++ b/mlir/test/Transforms/memref-bound-check.mlir @@ -13,8 +13,8 @@ func @test() { affine.for %i = -1 to 10 { affine.for %j = -1 to 10 { - %idx0 = affine.apply (d0, d1) -> (d0)(%i, %j) - %idx1 = affine.apply (d0, d1) -> (d1)(%i, %j) + %idx0 = affine.apply affine_map<(d0, d1) -> (d0)>(%i, %j) + %idx1 = affine.apply affine_map<(d0, d1) -> (d1)>(%i, %j) // Out of bound access. %x = affine.load %A[%idx0, %idx1] : memref<9 x 9 x i32> // expected-error@-1 {{'affine.load' op memref out of upper bound access along dimension #1}} @@ -22,7 +22,7 @@ func @test() { // expected-error@-3 {{'affine.load' op memref out of upper bound access along dimension #2}} // expected-error@-4 {{'affine.load' op memref out of lower bound access along dimension #2}} // This will access 0 to 110 - hence an overflow. - %idy = affine.apply (d0, d1) -> (10*d0 - d1 + 19)(%i, %j) + %idy = affine.apply affine_map<(d0, d1) -> (10*d0 - d1 + 19)>(%i, %j) %y = affine.load %B[%idy] : memref<111 x i32> } } @@ -45,16 +45,16 @@ func @test_mod_floordiv_ceildiv() { affine.for %i = 0 to 256 { affine.for %j = 0 to 256 { - %idx0 = affine.apply (d0, d1, d2) -> (d0 mod 128 + 1)(%i, %j, %j) - %idx1 = affine.apply (d0, d1, d2) -> (d1 floordiv 4 + 1)(%i, %j, %j) - %idx2 = affine.apply (d0, d1, d2) -> (d2 ceildiv 4)(%i, %j, %j) + %idx0 = affine.apply affine_map<(d0, d1, d2) -> (d0 mod 128 + 1)>(%i, %j, %j) + %idx1 = affine.apply affine_map<(d0, d1, d2) -> (d1 floordiv 4 + 1)>(%i, %j, %j) + %idx2 = affine.apply affine_map<(d0, d1, d2) -> (d2 ceildiv 4)>(%i, %j, %j) %x = affine.load %A[%idx0, %idx1, %idx2] : memref<128 x 64 x 64 x i32> // expected-error@-1 {{'affine.load' op memref out of upper bound access along dimension #1}} // expected-error@-2 {{'affine.load' op memref out of upper bound access along dimension #2}} // expected-error@-3 {{'affine.load' op memref out of upper bound access along dimension #3}} - %idy0 = affine.apply (d0, d1, d2) -> (d0 mod 128)(%i, %j, %j) - %idy1 = affine.apply (d0, d1, d2) -> (d1 floordiv 4)(%i, %j, %j) - %idy2 = affine.apply (d0, d1, d2) -> (d2 ceildiv 4 - 1)(%i, %j, %j) + %idy0 = affine.apply affine_map<(d0, d1, d2) -> (d0 mod 128)>(%i, %j, %j) + %idy1 = affine.apply affine_map<(d0, d1, d2) -> (d1 floordiv 4)>(%i, %j, %j) + %idy2 = affine.apply affine_map<(d0, d1, d2) -> (d2 ceildiv 4 - 1)>(%i, %j, %j) affine.store %x, %A[%idy0, %idy1, %idy2] : memref<128 x 64 x 64 x i32> // expected-error {{'affine.store' op memref out of lower bound access along dimension #3}} } // CHECK } } // CHECK } @@ -75,12 +75,12 @@ func @test_no_out_of_bounds() { // CHECK-NEXT: %{{.*}} = affine.load %{{.*}}[%{{.*}}, %{{.*}}] : memref<257x256xi32> // CHECK-NEXT: %{{.*}} = affine.apply {{#map.*}}(%{{.*}}, %{{.*}}) // CHECK-NEXT: %{{.*}} = affine.load %{{.*}}[%{{.*}}] : memref<1xi32> - %idx0 = affine.apply (d0, d1) -> ( 64 * (d0 ceildiv 64))(%i, %j) + %idx0 = affine.apply affine_map<(d0, d1) -> ( 64 * (d0 ceildiv 64))>(%i, %j) // Without GCDTightenInequalities(), the upper bound on the region // accessed along first memref dimension would have come out as d0 <= 318 // (instead of d0 <= 256), and led to a false positive out of bounds. %x = affine.load %A[%idx0, %zero] : memref<257 x 256 x i32> - %idy = affine.apply (d0, d1) -> (d0 floordiv 256)(%i, %i) + %idy = affine.apply affine_map<(d0, d1) -> (d0 floordiv 256)>(%i, %i) %y = affine.load %B[%idy] : memref<1 x i32> } // CHECK-NEXT } } @@ -94,16 +94,16 @@ func @mod_div() { affine.for %i = 0 to 256 { affine.for %j = 0 to 256 { - %idx0 = affine.apply (d0, d1, d2) -> (d0 mod 128 + 1)(%i, %j, %j) - %idx1 = affine.apply (d0, d1, d2) -> (d1 floordiv 4 + 1)(%i, %j, %j) - %idx2 = affine.apply (d0, d1, d2) -> (d2 ceildiv 4)(%i, %j, %j) + %idx0 = affine.apply affine_map<(d0, d1, d2) -> (d0 mod 128 + 1)>(%i, %j, %j) + %idx1 = affine.apply affine_map<(d0, d1, d2) -> (d1 floordiv 4 + 1)>(%i, %j, %j) + %idx2 = affine.apply affine_map<(d0, d1, d2) -> (d2 ceildiv 4)>(%i, %j, %j) %x = affine.load %A[%idx0, %idx1, %idx2] : memref<128 x 64 x 64 x i32> // expected-error@-1 {{'affine.load' op memref out of upper bound access along dimension #1}} // expected-error@-2 {{'affine.load' op memref out of upper bound access along dimension #2}} // expected-error@-3 {{'affine.load' op memref out of upper bound access along dimension #3}} - %idy0 = affine.apply (d0, d1, d2) -> (d0 mod 128)(%i, %j, %j) - %idy1 = affine.apply (d0, d1, d2) -> (d1 floordiv 4)(%i, %j, %j) - %idy2 = affine.apply (d0, d1, d2) -> (d2 ceildiv 4 - 1)(%i, %j, %j) + %idy0 = affine.apply affine_map<(d0, d1, d2) -> (d0 mod 128)>(%i, %j, %j) + %idy1 = affine.apply affine_map<(d0, d1, d2) -> (d1 floordiv 4)>(%i, %j, %j) + %idy2 = affine.apply affine_map<(d0, d1, d2) -> (d2 ceildiv 4 - 1)>(%i, %j, %j) affine.store %x, %A[%idy0, %idy1, %idy2] : memref<128 x 64 x 64 x i32> // expected-error {{'affine.store' op memref out of lower bound access along dimension #3}} } } @@ -116,8 +116,8 @@ func @mod_floordiv_nested() { %A = alloc() : memref<256 x 256 x i32> affine.for %i = 0 to 256 { affine.for %j = 0 to 256 { - %idx0 = affine.apply (d0, d1) -> ((d0 mod 1024) floordiv 4)(%i, %j) - %idx1 = affine.apply (d0, d1) -> ((((d1 mod 128) mod 32) ceildiv 4) * 32)(%i, %j) + %idx0 = affine.apply affine_map<(d0, d1) -> ((d0 mod 1024) floordiv 4)>(%i, %j) + %idx1 = affine.apply affine_map<(d0, d1) -> ((((d1 mod 128) mod 32) ceildiv 4) * 32)>(%i, %j) affine.load %A[%idx0, %idx1] : memref<256 x 256 x i32> // expected-error {{'affine.load' op memref out of upper bound access along dimension #2}} } } @@ -128,7 +128,7 @@ func @mod_floordiv_nested() { func @test_semi_affine_bailout(%N : index) { %B = alloc() : memref<10 x i32> affine.for %i = 0 to 10 { - %idx = affine.apply (d0)[s0] -> (d0 * s0)(%i)[%N] + %idx = affine.apply affine_map<(d0)[s0] -> (d0 * s0)>(%i)[%N] %y = affine.load %B[%idx] : memref<10 x i32> // expected-error@-1 {{getMemRefRegion: compose affine map failed}} } @@ -139,8 +139,8 @@ func @test_semi_affine_bailout(%N : index) { func @multi_mod_floordiv() { %A = alloc() : memref<2x2xi32> affine.for %ii = 0 to 64 { - %idx0 = affine.apply (d0) -> ((d0 mod 147456) floordiv 1152) (%ii) - %idx1 = affine.apply (d0) -> (((d0 mod 147456) mod 1152) floordiv 384) (%ii) + %idx0 = affine.apply affine_map<(d0) -> ((d0 mod 147456) floordiv 1152)> (%ii) + %idx1 = affine.apply affine_map<(d0) -> (((d0 mod 147456) mod 1152) floordiv 384)> (%ii) %v = affine.load %A[%idx0, %idx1] : memref<2x2xi32> } return @@ -155,20 +155,20 @@ func @delinearize_mod_floordiv() { // Reshape '%in' into '%out'. affine.for %ii = 0 to 64 { affine.for %jj = 0 to 9 { - %a0 = affine.apply (d0, d1) -> (d0 * (9 * 1024) + d1 * 128) (%ii, %jj) - %a10 = affine.apply (d0) -> - (d0 floordiv (2 * 3 * 3 * 128 * 128)) (%a0) - %a11 = affine.apply (d0) -> - ((d0 mod 294912) floordiv (3 * 3 * 128 * 128)) (%a0) - %a12 = affine.apply (d0) -> - ((((d0 mod 294912) mod 147456) floordiv 1152) floordiv 8) (%a0) - %a13 = affine.apply (d0) -> - ((((d0 mod 294912) mod 147456) mod 1152) floordiv 384) (%a0) - %a14 = affine.apply (d0) -> - (((((d0 mod 294912) mod 147456) mod 1152) mod 384) floordiv 128) (%a0) - %a15 = affine.apply (d0) -> + %a0 = affine.apply affine_map<(d0, d1) -> (d0 * (9 * 1024) + d1 * 128)> (%ii, %jj) + %a10 = affine.apply affine_map<(d0) -> + (d0 floordiv (2 * 3 * 3 * 128 * 128))> (%a0) + %a11 = affine.apply affine_map<(d0) -> + ((d0 mod 294912) floordiv (3 * 3 * 128 * 128))> (%a0) + %a12 = affine.apply affine_map<(d0) -> + ((((d0 mod 294912) mod 147456) floordiv 1152) floordiv 8)> (%a0) + %a13 = affine.apply affine_map<(d0) -> + ((((d0 mod 294912) mod 147456) mod 1152) floordiv 384)> (%a0) + %a14 = affine.apply affine_map<(d0) -> + (((((d0 mod 294912) mod 147456) mod 1152) mod 384) floordiv 128)> (%a0) + %a15 = affine.apply affine_map<(d0) -> ((((((d0 mod 294912) mod 147456) mod 1152) mod 384) mod 128) - floordiv 128) (%a0) + floordiv 128)> (%a0) %v0 = affine.load %in[%a10, %a11, %a13, %a14, %a12, %a15] : memref<2x2x3x3x16x1xi32> } @@ -190,7 +190,7 @@ func @out_of_bounds() { %c9 = constant 9 : i32 affine.for %i0 = 10 to 11 { - %idy = affine.apply (d0) -> (100 * d0 floordiv 1000) (%i0) + %idy = affine.apply affine_map<(d0) -> (100 * d0 floordiv 1000)> (%i0) affine.store %c9, %in[%idy] : memref<1xi32> // expected-error {{'affine.store' op memref out of upper bound access along dimension #1}} } return @@ -202,9 +202,9 @@ func @out_of_bounds() { // trivially redundant constraints (those differing only in their constant // term), the number of constraints here explodes, and this would return out of // bounds errors conservatively due to FlatAffineConstraints::kExplosionFactor. -#map3 = (d0, d1) -> ((d0 * 72 + d1) floordiv 2304 + ((((d0 * 72 + d1) mod 2304) mod 1152) mod 9) floordiv 3) -#map4 = (d0, d1) -> ((d0 * 72 + d1) mod 2304 - (((d0 * 72 + d1) mod 2304) floordiv 1152) * 1151 - ((((d0 * 72 + d1) mod 2304) mod 1152) floordiv 9) * 9 - (((((d0 * 72 + d1) mod 2304) mod 1152) mod 9) floordiv 3) * 3) -#map5 = (d0, d1) -> (((((d0 * 72 + d1) mod 2304) mod 1152) floordiv 9) floordiv 8) +#map3 = affine_map<(d0, d1) -> ((d0 * 72 + d1) floordiv 2304 + ((((d0 * 72 + d1) mod 2304) mod 1152) mod 9) floordiv 3)> +#map4 = affine_map<(d0, d1) -> ((d0 * 72 + d1) mod 2304 - (((d0 * 72 + d1) mod 2304) floordiv 1152) * 1151 - ((((d0 * 72 + d1) mod 2304) mod 1152) floordiv 9) * 9 - (((((d0 * 72 + d1) mod 2304) mod 1152) mod 9) floordiv 3) * 3)> +#map5 = affine_map<(d0, d1) -> (((((d0 * 72 + d1) mod 2304) mod 1152) floordiv 9) floordiv 8)> // CHECK-LABEL: func @test_complex_mod_floordiv func @test_complex_mod_floordiv(%arg0: memref<4x4x16x1xf32>) { %c0 = constant 0 : index @@ -223,8 +223,8 @@ func @test_complex_mod_floordiv(%arg0: memref<4x4x16x1xf32>) { // ----- // The first load is within bounds, but not the second one. -#map0 = (d0) -> (d0 mod 4) -#map1 = (d0) -> (d0 mod 4 + 4) +#map0 = affine_map<(d0) -> (d0 mod 4)> +#map1 = affine_map<(d0) -> (d0 mod 4 + 4)> // CHECK-LABEL: func @test_mod_bound func @test_mod_bound() { @@ -242,9 +242,9 @@ func @test_mod_bound() { // ----- -#map0 = (d0) -> (d0 floordiv 4) -#map1 = (d0) -> (d0 floordiv 4 + 4) -#map2 = (d0) -> (4 * (d0 floordiv 4) + d0 mod 4) +#map0 = affine_map<(d0) -> (d0 floordiv 4)> +#map1 = affine_map<(d0) -> (d0 floordiv 4 + 4)> +#map2 = affine_map<(d0) -> (4 * (d0 floordiv 4) + d0 mod 4)> // CHECK-LABEL: func @test_floordiv_bound func @test_floordiv_bound() { @@ -271,13 +271,13 @@ func @test_floordiv_bound() { // This should not give an out of bounds error. The result of the affine.apply // is composed into the bound map during analysis. -#map_lb = (d0) -> (d0) -#map_ub = (d0) -> (d0 + 4) +#map_lb = affine_map<(d0) -> (d0)> +#map_ub = affine_map<(d0) -> (d0 + 4)> // CHECK-LABEL: func @non_composed_bound_operand func @non_composed_bound_operand(%arg0: memref<1024xf32>) { affine.for %i0 = 4 to 1028 step 4 { - %i1 = affine.apply (d0) -> (d0 - 4) (%i0) + %i1 = affine.apply affine_map<(d0) -> (d0 - 4)> (%i0) affine.for %i2 = #map_lb(%i1) to #map_ub(%i1) { %0 = affine.load %arg0[%i2] : memref<1024xf32> } diff --git a/mlir/test/Transforms/memref-dataflow-opt.mlir b/mlir/test/Transforms/memref-dataflow-opt.mlir index a7f6f25b816..0fe8f715c0e 100644 --- a/mlir/test/Transforms/memref-dataflow-opt.mlir +++ b/mlir/test/Transforms/memref-dataflow-opt.mlir @@ -1,10 +1,10 @@ // RUN: mlir-opt %s -memref-dataflow-opt | FileCheck %s -// CHECK-DAG: [[MAP0:#map[0-9]+]] = (d0, d1) -> (d1 + 1) -// CHECK-DAG: [[MAP1:#map[0-9]+]] = (d0, d1) -> (d0) -// CHECK-DAG: [[MAP2:#map[0-9]+]] = (d0, d1) -> (d1) -// CHECK-DAG: [[MAP3:#map[0-9]+]] = (d0, d1) -> (d0 - 1) -// CHECK-DAG: [[MAP4:#map[0-9]+]] = (d0) -> (d0 + 1) +// CHECK-DAG: [[MAP0:#map[0-9]+]] = affine_map<(d0, d1) -> (d1 + 1)> +// CHECK-DAG: [[MAP1:#map[0-9]+]] = affine_map<(d0, d1) -> (d0)> +// CHECK-DAG: [[MAP2:#map[0-9]+]] = affine_map<(d0, d1) -> (d1)> +// CHECK-DAG: [[MAP3:#map[0-9]+]] = affine_map<(d0, d1) -> (d0 - 1)> +// CHECK-DAG: [[MAP4:#map[0-9]+]] = affine_map<(d0) -> (d0 + 1)> // CHECK-LABEL: func @simple_store_load() { func @simple_store_load() { @@ -61,10 +61,10 @@ func @store_load_affine_apply() -> memref<10x10xf32> { %m = alloc() : memref<10x10xf32> affine.for %i0 = 0 to 10 { affine.for %i1 = 0 to 10 { - %t0 = affine.apply (d0, d1) -> (d1 + 1)(%i0, %i1) - %t1 = affine.apply (d0, d1) -> (d0)(%i0, %i1) - %idx0 = affine.apply (d0, d1) -> (d1) (%t0, %t1) - %idx1 = affine.apply (d0, d1) -> (d0 - 1) (%t0, %t1) + %t0 = affine.apply affine_map<(d0, d1) -> (d1 + 1)>(%i0, %i1) + %t1 = affine.apply affine_map<(d0, d1) -> (d0)>(%i0, %i1) + %idx0 = affine.apply affine_map<(d0, d1) -> (d1)> (%t0, %t1) + %idx1 = affine.apply affine_map<(d0, d1) -> (d0 - 1)> (%t0, %t1) affine.store %cf7, %m[%idx0, %idx1] : memref<10x10xf32> // CHECK-NOT: affine.load %{{[0-9]+}} %v0 = affine.load %m[%i0, %i1] : memref<10x10xf32> @@ -228,7 +228,7 @@ func @store_load_store_nested_fwd(%N : index) -> f32 { affine.for %i1 = 0 to %N { %v0 = affine.load %m[%i0] : memref<10xf32> %v1 = addf %v0, %v0 : f32 - %idx = affine.apply (d0) -> (d0 + 1) (%i0) + %idx = affine.apply affine_map<(d0) -> (d0 + 1)> (%i0) affine.store %cf9, %m[%idx] : memref<10xf32> } } @@ -260,7 +260,7 @@ func @should_not_fwd(%A: memref<100xf32>, %M : index, %N : index) -> f32 { // Can store forward to A[%j, %i], but no forwarding to load on %A[%i, %j] // CHECK-LABEL: func @refs_not_known_to_be_equal func @refs_not_known_to_be_equal(%A : memref<100 x 100 x f32>, %M : index) { - %N = affine.apply (d0) -> (d0 + 1) (%M) + %N = affine.apply affine_map<(d0) -> (d0 + 1)> (%M) %cf1 = constant 1.0 : f32 affine.for %i = 0 to 100 { // CHECK: affine.for %[[I:.*]] = diff --git a/mlir/test/Transforms/memref-dependence-check.mlir b/mlir/test/Transforms/memref-dependence-check.mlir index 03b6c74654d..f48a63ef984 100644 --- a/mlir/test/Transforms/memref-dependence-check.mlir +++ b/mlir/test/Transforms/memref-dependence-check.mlir @@ -2,7 +2,7 @@ // ----- -#set0 = (d0) : (1 == 0) +#set0 = affine_set<(d0) : (1 == 0)> // CHECK-LABEL: func @store_may_execute_before_load() { func @store_may_execute_before_load() { @@ -164,11 +164,11 @@ func @store_load_diff_element_affine_apply_const() { %m = alloc() : memref<100xf32> %c1 = constant 1 : index %c8 = constant 8.0 : f32 - %a0 = affine.apply (d0) -> (d0) (%c1) + %a0 = affine.apply affine_map<(d0) -> (d0)> (%c1) affine.store %c8, %m[%a0] : memref<100xf32> // expected-remark@above {{dependence from 0 to 0 at depth 1 = false}} // expected-remark@above {{dependence from 0 to 1 at depth 1 = false}} - %a1 = affine.apply (d0) -> (d0 + 1) (%c1) + %a1 = affine.apply affine_map<(d0) -> (d0 + 1)> (%c1) %v0 = affine.load %m[%a1] : memref<100xf32> // expected-remark@above {{dependence from 1 to 0 at depth 1 = false}} // expected-remark@above {{dependence from 1 to 1 at depth 1 = false}} @@ -182,11 +182,11 @@ func @store_load_same_element_affine_apply_const() { %c7 = constant 7.0 : f32 %c9 = constant 9 : index %c11 = constant 11 : index - %a0 = affine.apply (d0) -> (d0 + 1) (%c9) + %a0 = affine.apply affine_map<(d0) -> (d0 + 1)> (%c9) affine.store %c7, %m[%a0] : memref<100xf32> // expected-remark@above {{dependence from 0 to 0 at depth 1 = false}} // expected-remark@above {{dependence from 0 to 1 at depth 1 = true}} - %a1 = affine.apply (d0) -> (d0 - 1) (%c11) + %a1 = affine.apply affine_map<(d0) -> (d0 - 1)> (%c11) %v0 = affine.load %m[%a1] : memref<100xf32> // expected-remark@above {{dependence from 1 to 0 at depth 1 = false}} // expected-remark@above {{dependence from 1 to 1 at depth 1 = false}} @@ -198,11 +198,11 @@ func @store_load_same_element_affine_apply_const() { func @store_load_affine_apply_symbol(%arg0: index) { %m = alloc() : memref<100xf32> %c7 = constant 7.0 : f32 - %a0 = affine.apply (d0) -> (d0) (%arg0) + %a0 = affine.apply affine_map<(d0) -> (d0)> (%arg0) affine.store %c7, %m[%a0] : memref<100xf32> // expected-remark@above {{dependence from 0 to 0 at depth 1 = false}} // expected-remark@above {{dependence from 0 to 1 at depth 1 = true}} - %a1 = affine.apply (d0) -> (d0) (%arg0) + %a1 = affine.apply affine_map<(d0) -> (d0)> (%arg0) %v0 = affine.load %m[%a1] : memref<100xf32> // expected-remark@above {{dependence from 1 to 0 at depth 1 = false}} // expected-remark@above {{dependence from 1 to 1 at depth 1 = false}} @@ -214,11 +214,11 @@ func @store_load_affine_apply_symbol(%arg0: index) { func @store_load_affine_apply_symbol_offset(%arg0: index) { %m = alloc() : memref<100xf32> %c7 = constant 7.0 : f32 - %a0 = affine.apply (d0) -> (d0) (%arg0) + %a0 = affine.apply affine_map<(d0) -> (d0)> (%arg0) affine.store %c7, %m[%a0] : memref<100xf32> // expected-remark@above {{dependence from 0 to 0 at depth 1 = false}} // expected-remark@above {{dependence from 0 to 1 at depth 1 = false}} - %a1 = affine.apply (d0) -> (d0 + 1) (%arg0) + %a1 = affine.apply affine_map<(d0) -> (d0 + 1)> (%arg0) %v0 = affine.load %m[%a1] : memref<100xf32> // expected-remark@above {{dependence from 1 to 0 at depth 1 = false}} // expected-remark@above {{dependence from 1 to 1 at depth 1 = false}} @@ -232,13 +232,13 @@ func @store_range_load_after_range() { %c7 = constant 7.0 : f32 %c10 = constant 10 : index affine.for %i0 = 0 to 10 { - %a0 = affine.apply (d0) -> (d0) (%i0) + %a0 = affine.apply affine_map<(d0) -> (d0)> (%i0) affine.store %c7, %m[%a0] : memref<100xf32> // expected-remark@above {{dependence from 0 to 0 at depth 1 = false}} // expected-remark@above {{dependence from 0 to 0 at depth 2 = false}} // expected-remark@above {{dependence from 0 to 1 at depth 1 = false}} // expected-remark@above {{dependence from 0 to 1 at depth 2 = false}} - %a1 = affine.apply (d0) -> (d0) (%c10) + %a1 = affine.apply affine_map<(d0) -> (d0)> (%c10) %v0 = affine.load %m[%a1] : memref<100xf32> // expected-remark@above {{dependence from 1 to 0 at depth 1 = false}} // expected-remark@above {{dependence from 1 to 0 at depth 2 = false}} @@ -255,13 +255,13 @@ func @store_load_func_symbol(%arg0: index, %arg1: index) { %c7 = constant 7.0 : f32 %c10 = constant 10 : index affine.for %i0 = 0 to %arg1 { - %a0 = affine.apply (d0) -> (d0) (%arg0) + %a0 = affine.apply affine_map<(d0) -> (d0)> (%arg0) affine.store %c7, %m[%a0] : memref<100xf32> // expected-remark@above {{dependence from 0 to 0 at depth 1 = [1, +inf]}} // expected-remark@above {{dependence from 0 to 0 at depth 2 = false}} // expected-remark@above {{dependence from 0 to 1 at depth 1 = [1, +inf]}} // expected-remark@above {{dependence from 0 to 1 at depth 2 = true}} - %a1 = affine.apply (d0) -> (d0) (%arg0) + %a1 = affine.apply affine_map<(d0) -> (d0)> (%arg0) %v0 = affine.load %m[%a1] : memref<100xf32> // expected-remark@above {{dependence from 1 to 0 at depth 1 = [1, +inf]}} // expected-remark@above {{dependence from 1 to 0 at depth 2 = false}} @@ -278,7 +278,7 @@ func @store_range_load_last_in_range() { %c7 = constant 7.0 : f32 %c10 = constant 10 : index affine.for %i0 = 0 to 10 { - %a0 = affine.apply (d0) -> (d0) (%i0) + %a0 = affine.apply affine_map<(d0) -> (d0)> (%i0) // For dependence from 0 to 1, we do not have a loop carried dependence // because only the final write in the loop accesses the same element as the // load, so this dependence appears only at depth 2 (loop independent). @@ -287,7 +287,7 @@ func @store_range_load_last_in_range() { // expected-remark@above {{dependence from 0 to 0 at depth 2 = false}} // expected-remark@above {{dependence from 0 to 1 at depth 1 = false}} // expected-remark@above {{dependence from 0 to 1 at depth 2 = true}} - %a1 = affine.apply (d0) -> (d0 - 1) (%c10) + %a1 = affine.apply affine_map<(d0) -> (d0 - 1)> (%c10) // For dependence from 1 to 0, we have write-after-read (WAR) dependences // for all loads in the loop to the store on the last iteration. %v0 = affine.load %m[%a1] : memref<100xf32> @@ -306,13 +306,13 @@ func @store_range_load_before_range() { %c7 = constant 7.0 : f32 %c0 = constant 0 : index affine.for %i0 = 1 to 11 { - %a0 = affine.apply (d0) -> (d0) (%i0) + %a0 = affine.apply affine_map<(d0) -> (d0)> (%i0) affine.store %c7, %m[%a0] : memref<100xf32> // expected-remark@above {{dependence from 0 to 0 at depth 1 = false}} // expected-remark@above {{dependence from 0 to 0 at depth 2 = false}} // expected-remark@above {{dependence from 0 to 1 at depth 1 = false}} // expected-remark@above {{dependence from 0 to 1 at depth 2 = false}} - %a1 = affine.apply (d0) -> (d0) (%c0) + %a1 = affine.apply affine_map<(d0) -> (d0)> (%c0) %v0 = affine.load %m[%a1] : memref<100xf32> // expected-remark@above {{dependence from 1 to 0 at depth 1 = false}} // expected-remark@above {{dependence from 1 to 0 at depth 2 = false}} @@ -329,7 +329,7 @@ func @store_range_load_first_in_range() { %c7 = constant 7.0 : f32 %c0 = constant 0 : index affine.for %i0 = 1 to 11 { - %a0 = affine.apply (d0) -> (d0) (%i0) + %a0 = affine.apply affine_map<(d0) -> (d0)> (%i0) // Dependence from 0 to 1 at depth 1 is a range because all loads at // constant index zero are reads after first store at index zero during // first iteration of the loop. @@ -338,7 +338,7 @@ func @store_range_load_first_in_range() { // expected-remark@above {{dependence from 0 to 0 at depth 2 = false}} // expected-remark@above {{dependence from 0 to 1 at depth 1 = [1, 9]}} // expected-remark@above {{dependence from 0 to 1 at depth 2 = true}} - %a1 = affine.apply (d0) -> (d0 + 1) (%c0) + %a1 = affine.apply affine_map<(d0) -> (d0 + 1)> (%c0) %v0 = affine.load %m[%a1] : memref<100xf32> // expected-remark@above {{dependence from 1 to 0 at depth 1 = false}} // expected-remark@above {{dependence from 1 to 0 at depth 2 = false}} @@ -354,13 +354,13 @@ func @store_plus_3() { %m = alloc() : memref<100xf32> %c7 = constant 7.0 : f32 affine.for %i0 = 1 to 11 { - %a0 = affine.apply (d0) -> (d0 + 3) (%i0) + %a0 = affine.apply affine_map<(d0) -> (d0 + 3)> (%i0) affine.store %c7, %m[%a0] : memref<100xf32> // expected-remark@above {{dependence from 0 to 0 at depth 1 = false}} // expected-remark@above {{dependence from 0 to 0 at depth 2 = false}} // expected-remark@above {{dependence from 0 to 1 at depth 1 = [3, 3]}} // expected-remark@above {{dependence from 0 to 1 at depth 2 = false}} - %a1 = affine.apply (d0) -> (d0) (%i0) + %a1 = affine.apply affine_map<(d0) -> (d0)> (%i0) %v0 = affine.load %m[%a1] : memref<100xf32> // expected-remark@above {{dependence from 1 to 0 at depth 1 = false}} // expected-remark@above {{dependence from 1 to 0 at depth 2 = false}} @@ -376,13 +376,13 @@ func @load_minus_2() { %m = alloc() : memref<100xf32> %c7 = constant 7.0 : f32 affine.for %i0 = 2 to 11 { - %a0 = affine.apply (d0) -> (d0) (%i0) + %a0 = affine.apply affine_map<(d0) -> (d0)> (%i0) affine.store %c7, %m[%a0] : memref<100xf32> // expected-remark@above {{dependence from 0 to 0 at depth 1 = false}} // expected-remark@above {{dependence from 0 to 0 at depth 2 = false}} // expected-remark@above {{dependence from 0 to 1 at depth 1 = [2, 2]}} // expected-remark@above {{dependence from 0 to 1 at depth 2 = false}} - %a1 = affine.apply (d0) -> (d0 - 2) (%i0) + %a1 = affine.apply affine_map<(d0) -> (d0 - 2)> (%i0) %v0 = affine.load %m[%a1] : memref<100xf32> // expected-remark@above {{dependence from 1 to 0 at depth 1 = false}} // expected-remark@above {{dependence from 1 to 0 at depth 2 = false}} @@ -400,8 +400,8 @@ func @perfectly_nested_loops_loop_independent() { affine.for %i0 = 0 to 11 { affine.for %i1 = 0 to 11 { // Dependence from access 0 to 1 is loop independent at depth = 3. - %a00 = affine.apply (d0, d1) -> (d0) (%i0, %i1) - %a01 = affine.apply (d0, d1) -> (d1) (%i0, %i1) + %a00 = affine.apply affine_map<(d0, d1) -> (d0)> (%i0, %i1) + %a01 = affine.apply affine_map<(d0, d1) -> (d1)> (%i0, %i1) affine.store %c7, %m[%a00, %a01] : memref<10x10xf32> // expected-remark@above {{dependence from 0 to 0 at depth 1 = false}} // expected-remark@above {{dependence from 0 to 0 at depth 2 = false}} @@ -409,8 +409,8 @@ func @perfectly_nested_loops_loop_independent() { // expected-remark@above {{dependence from 0 to 1 at depth 1 = false}} // expected-remark@above {{dependence from 0 to 1 at depth 2 = false}} // expected-remark@above {{dependence from 0 to 1 at depth 3 = true}} - %a10 = affine.apply (d0, d1) -> (d0) (%i0, %i1) - %a11 = affine.apply (d0, d1) -> (d1) (%i0, %i1) + %a10 = affine.apply affine_map<(d0, d1) -> (d0)> (%i0, %i1) + %a11 = affine.apply affine_map<(d0, d1) -> (d1)> (%i0, %i1) %v0 = affine.load %m[%a10, %a11] : memref<10x10xf32> // expected-remark@above {{dependence from 1 to 0 at depth 1 = false}} // expected-remark@above {{dependence from 1 to 0 at depth 2 = false}} @@ -431,8 +431,8 @@ func @perfectly_nested_loops_loop_carried_at_depth1() { affine.for %i0 = 0 to 9 { affine.for %i1 = 0 to 9 { // Dependence from access 0 to 1 is loop carried at depth 1. - %a00 = affine.apply (d0, d1) -> (d0) (%i0, %i1) - %a01 = affine.apply (d0, d1) -> (d1) (%i0, %i1) + %a00 = affine.apply affine_map<(d0, d1) -> (d0)> (%i0, %i1) + %a01 = affine.apply affine_map<(d0, d1) -> (d1)> (%i0, %i1) affine.store %c7, %m[%a00, %a01] : memref<10x10xf32> // expected-remark@above {{dependence from 0 to 0 at depth 1 = false}} // expected-remark@above {{dependence from 0 to 0 at depth 2 = false}} @@ -440,8 +440,8 @@ func @perfectly_nested_loops_loop_carried_at_depth1() { // expected-remark@above {{dependence from 0 to 1 at depth 1 = [2, 2][0, 0]}} // expected-remark@above {{dependence from 0 to 1 at depth 2 = false}} // expected-remark@above {{dependence from 0 to 1 at depth 3 = false}} - %a10 = affine.apply (d0, d1) -> (d0 - 2) (%i0, %i1) - %a11 = affine.apply (d0, d1) -> (d1) (%i0, %i1) + %a10 = affine.apply affine_map<(d0, d1) -> (d0 - 2)> (%i0, %i1) + %a11 = affine.apply affine_map<(d0, d1) -> (d1)> (%i0, %i1) %v0 = affine.load %m[%a10, %a11] : memref<10x10xf32> // expected-remark@above {{dependence from 1 to 0 at depth 1 = false}} // expected-remark@above {{dependence from 1 to 0 at depth 2 = false}} @@ -462,8 +462,8 @@ func @perfectly_nested_loops_loop_carried_at_depth2() { affine.for %i0 = 0 to 10 { affine.for %i1 = 0 to 10 { // Dependence from access 0 to 1 is loop carried at depth 2. - %a00 = affine.apply (d0, d1) -> (d0) (%i0, %i1) - %a01 = affine.apply (d0, d1) -> (d1) (%i0, %i1) + %a00 = affine.apply affine_map<(d0, d1) -> (d0)> (%i0, %i1) + %a01 = affine.apply affine_map<(d0, d1) -> (d1)> (%i0, %i1) affine.store %c7, %m[%a00, %a01] : memref<10x10xf32> // expected-remark@above {{dependence from 0 to 0 at depth 1 = false}} // expected-remark@above {{dependence from 0 to 0 at depth 2 = false}} @@ -471,8 +471,8 @@ func @perfectly_nested_loops_loop_carried_at_depth2() { // expected-remark@above {{dependence from 0 to 1 at depth 1 = false}} // expected-remark@above {{dependence from 0 to 1 at depth 2 = [0, 0][3, 3]}} // expected-remark@above {{dependence from 0 to 1 at depth 3 = false}} - %a10 = affine.apply (d0, d1) -> (d0) (%i0, %i1) - %a11 = affine.apply (d0, d1) -> (d1 - 3) (%i0, %i1) + %a10 = affine.apply affine_map<(d0, d1) -> (d0)> (%i0, %i1) + %a11 = affine.apply affine_map<(d0, d1) -> (d1 - 3)> (%i0, %i1) %v0 = affine.load %m[%a10, %a11] : memref<10x10xf32> // expected-remark@above {{dependence from 1 to 0 at depth 1 = false}} // expected-remark@above {{dependence from 1 to 0 at depth 2 = false}} @@ -493,8 +493,8 @@ func @one_common_loop() { // There is a loop-independent dependence from access 0 to 1 at depth 2. affine.for %i0 = 0 to 10 { affine.for %i1 = 0 to 10 { - %a00 = affine.apply (d0, d1) -> (d0) (%i0, %i1) - %a01 = affine.apply (d0, d1) -> (d1) (%i0, %i1) + %a00 = affine.apply affine_map<(d0, d1) -> (d0)> (%i0, %i1) + %a01 = affine.apply affine_map<(d0, d1) -> (d1)> (%i0, %i1) affine.store %c7, %m[%a00, %a01] : memref<10x10xf32> // expected-remark@above {{dependence from 0 to 0 at depth 1 = false}} // expected-remark@above {{dependence from 0 to 0 at depth 2 = false}} @@ -503,8 +503,8 @@ func @one_common_loop() { // expected-remark@above {{dependence from 0 to 1 at depth 2 = true}} } affine.for %i2 = 0 to 9 { - %a10 = affine.apply (d0, d1) -> (d0) (%i0, %i2) - %a11 = affine.apply (d0, d1) -> (d1) (%i0, %i2) + %a10 = affine.apply affine_map<(d0, d1) -> (d0)> (%i0, %i2) + %a11 = affine.apply affine_map<(d0, d1) -> (d1)> (%i0, %i2) %v0 = affine.load %m[%a10, %a11] : memref<10x10xf32> // expected-remark@above {{dependence from 1 to 0 at depth 1 = false}} // expected-remark@above {{dependence from 1 to 0 at depth 2 = false}} @@ -526,7 +526,7 @@ func @dependence_cycle() { // *) loop-independent dependence from access 1 to 2 at depth 2. // *) loop-carried dependence from access 3 to 0 at depth 1. affine.for %i0 = 0 to 9 { - %a0 = affine.apply (d0) -> (d0) (%i0) + %a0 = affine.apply affine_map<(d0) -> (d0)> (%i0) %v0 = affine.load %m.a[%a0] : memref<100xf32> // expected-remark@above {{dependence from 0 to 0 at depth 1 = false}} // expected-remark@above {{dependence from 0 to 0 at depth 2 = false}} @@ -536,7 +536,7 @@ func @dependence_cycle() { // expected-remark@above {{dependence from 0 to 2 at depth 2 = false}} // expected-remark@above {{dependence from 0 to 3 at depth 1 = false}} // expected-remark@above {{dependence from 0 to 3 at depth 2 = false}} - %a1 = affine.apply (d0) -> (d0) (%i0) + %a1 = affine.apply affine_map<(d0) -> (d0)> (%i0) affine.store %v0, %m.b[%a1] : memref<100xf32> // expected-remark@above {{dependence from 1 to 0 at depth 1 = false}} // expected-remark@above {{dependence from 1 to 0 at depth 2 = false}} @@ -546,7 +546,7 @@ func @dependence_cycle() { // expected-remark@above {{dependence from 1 to 2 at depth 2 = true}} // expected-remark@above {{dependence from 1 to 3 at depth 1 = false}} // expected-remark@above {{dependence from 1 to 3 at depth 2 = false}} - %a2 = affine.apply (d0) -> (d0) (%i0) + %a2 = affine.apply affine_map<(d0) -> (d0)> (%i0) %v1 = affine.load %m.b[%a2] : memref<100xf32> // expected-remark@above {{dependence from 2 to 0 at depth 1 = false}} // expected-remark@above {{dependence from 2 to 0 at depth 2 = false}} @@ -556,7 +556,7 @@ func @dependence_cycle() { // expected-remark@above {{dependence from 2 to 2 at depth 2 = false}} // expected-remark@above {{dependence from 2 to 3 at depth 1 = false}} // expected-remark@above {{dependence from 2 to 3 at depth 2 = false}} - %a3 = affine.apply (d0) -> (d0 + 1) (%i0) + %a3 = affine.apply affine_map<(d0) -> (d0 + 1)> (%i0) affine.store %v1, %m.a[%a3] : memref<100xf32> // expected-remark@above {{dependence from 3 to 0 at depth 1 = [1, 1]}} // expected-remark@above {{dependence from 3 to 0 at depth 2 = false}} @@ -577,8 +577,8 @@ func @negative_and_positive_direction_vectors(%arg0: index, %arg1: index) { %c7 = constant 7.0 : f32 affine.for %i0 = 0 to %arg0 { affine.for %i1 = 0 to %arg1 { - %a00 = affine.apply (d0, d1) -> (d0 - 1) (%i0, %i1) - %a01 = affine.apply (d0, d1) -> (d1 + 1) (%i0, %i1) + %a00 = affine.apply affine_map<(d0, d1) -> (d0 - 1)> (%i0, %i1) + %a01 = affine.apply affine_map<(d0, d1) -> (d1 + 1)> (%i0, %i1) %v0 = affine.load %m[%a00, %a01] : memref<10x10xf32> // expected-remark@above {{dependence from 0 to 0 at depth 1 = false}} // expected-remark@above {{dependence from 0 to 0 at depth 2 = false}} @@ -586,8 +586,8 @@ func @negative_and_positive_direction_vectors(%arg0: index, %arg1: index) { // expected-remark@above {{dependence from 0 to 1 at depth 1 = false}} // expected-remark@above {{dependence from 0 to 1 at depth 2 = false}} // expected-remark@above {{dependence from 0 to 1 at depth 3 = false}} - %a10 = affine.apply (d0, d1) -> (d0) (%i0, %i1) - %a11 = affine.apply (d0, d1) -> (d1) (%i0, %i1) + %a10 = affine.apply affine_map<(d0, d1) -> (d0)> (%i0, %i1) + %a11 = affine.apply affine_map<(d0, d1) -> (d1)> (%i0, %i1) affine.store %c7, %m[%a10, %a11] : memref<10x10xf32> // expected-remark@above {{dependence from 1 to 0 at depth 1 = [1, 1][-1, -1]}} // expected-remark@above {{dependence from 1 to 0 at depth 2 = false}} @@ -607,7 +607,7 @@ func @war_raw_waw_deps() { %c7 = constant 7.0 : f32 affine.for %i0 = 0 to 10 { affine.for %i1 = 0 to 10 { - %a0 = affine.apply (d0) -> (d0 + 1) (%i1) + %a0 = affine.apply affine_map<(d0) -> (d0 + 1)> (%i1) %v0 = affine.load %m[%a0] : memref<100xf32> // expected-remark@above {{dependence from 0 to 0 at depth 1 = false}} // expected-remark@above {{dependence from 0 to 0 at depth 2 = false}} @@ -615,7 +615,7 @@ func @war_raw_waw_deps() { // expected-remark@above {{dependence from 0 to 1 at depth 1 = [1, 9][1, 1]}} // expected-remark@above {{dependence from 0 to 1 at depth 2 = [0, 0][1, 1]}} // expected-remark@above {{dependence from 0 to 1 at depth 3 = false}} - %a1 = affine.apply (d0) -> (d0) (%i1) + %a1 = affine.apply affine_map<(d0) -> (d0)> (%i1) affine.store %c7, %m[%a1] : memref<100xf32> // expected-remark@above {{dependence from 1 to 0 at depth 1 = [1, 9][-1, -1]}} // expected-remark@above {{dependence from 1 to 0 at depth 2 = false}} @@ -634,7 +634,7 @@ func @mod_deps() { %m = alloc() : memref<100xf32> %c7 = constant 7.0 : f32 affine.for %i0 = 0 to 10 { - %a0 = affine.apply (d0) -> (d0 mod 2) (%i0) + %a0 = affine.apply affine_map<(d0) -> (d0 mod 2)> (%i0) // Results are conservative here since we currently don't have a way to // represent strided sets in FlatAffineConstraints. %v0 = affine.load %m[%a0] : memref<100xf32> @@ -642,7 +642,7 @@ func @mod_deps() { // expected-remark@above {{dependence from 0 to 0 at depth 2 = false}} // expected-remark@above {{dependence from 0 to 1 at depth 1 = [1, 9]}} // expected-remark@above {{dependence from 0 to 1 at depth 2 = false}} - %a1 = affine.apply (d0) -> ( (d0 + 1) mod 2) (%i0) + %a1 = affine.apply affine_map<(d0) -> ( (d0 + 1) mod 2)> (%i0) affine.store %c7, %m[%a1] : memref<100xf32> // expected-remark@above {{dependence from 1 to 0 at depth 1 = [1, 9]}} // expected-remark@above {{dependence from 1 to 0 at depth 2 = false}} @@ -671,7 +671,7 @@ func @loop_nest_depth() { affine.for %i3 = 0 to 8 { affine.for %i4 = 0 to 8 { affine.for %i5 = 0 to 16 { - %8 = affine.apply (d0, d1) -> (d0 * 16 + d1)(%i4, %i5) + %8 = affine.apply affine_map<(d0, d1) -> (d0 * 16 + d1)>(%i4, %i5) %9 = affine.load %0[%8, %i3] : memref<100x100xf32> // expected-remark@above {{dependence from 1 to 0 at depth 1 = false}} // expected-remark@above {{dependence from 1 to 1 at depth 1 = false}} @@ -696,9 +696,9 @@ func @mod_div_3d() { affine.for %i0 = 0 to 8 { affine.for %i1 = 0 to 8 { affine.for %i2 = 0 to 8 { - %idx0 = affine.apply (d0, d1, d2) -> (d0 floordiv 4) (%i0, %i1, %i2) - %idx1 = affine.apply (d0, d1, d2) -> (d1 mod 2) (%i0, %i1, %i2) - %idx2 = affine.apply (d0, d1, d2) -> (d2 floordiv 4) (%i0, %i1, %i2) + %idx0 = affine.apply affine_map<(d0, d1, d2) -> (d0 floordiv 4)> (%i0, %i1, %i2) + %idx1 = affine.apply affine_map<(d0, d1, d2) -> (d1 mod 2)> (%i0, %i1, %i2) + %idx2 = affine.apply affine_map<(d0, d1, d2) -> (d2 floordiv 4)> (%i0, %i1, %i2) affine.store %c0, %M[%idx0, %idx1, %idx2] : memref<2 x 2 x 2 x i32> // expected-remark@above {{dependence from 0 to 0 at depth 1 = [1, 3][-7, 7][-3, 3]}} // expected-remark@above {{dependence from 0 to 0 at depth 2 = [0, 0][2, 7][-3, 3]}} @@ -744,20 +744,20 @@ func @delinearize_mod_floordiv() { affine.for %ii = 0 to 64 { affine.for %jj = 0 to 9 { - %a0 = affine.apply (d0, d1) -> (d0 * (9 * 1024) + d1 * 128) (%ii, %jj) - %a10 = affine.apply (d0) -> - (d0 floordiv (2 * 3 * 3 * 128 * 128)) (%a0) - %a11 = affine.apply (d0) -> - ((d0 mod 294912) floordiv (3 * 3 * 128 * 128)) (%a0) - %a12 = affine.apply (d0) -> - ((((d0 mod 294912) mod 147456) floordiv 1152) floordiv 8) (%a0) - %a13 = affine.apply (d0) -> - ((((d0 mod 294912) mod 147456) mod 1152) floordiv 384) (%a0) - %a14 = affine.apply (d0) -> - (((((d0 mod 294912) mod 147456) mod 1152) mod 384) floordiv 128) (%a0) - %a15 = affine.apply (d0) -> + %a0 = affine.apply affine_map<(d0, d1) -> (d0 * (9 * 1024) + d1 * 128)> (%ii, %jj) + %a10 = affine.apply affine_map<(d0) -> + (d0 floordiv (2 * 3 * 3 * 128 * 128))> (%a0) + %a11 = affine.apply affine_map<(d0) -> + ((d0 mod 294912) floordiv (3 * 3 * 128 * 128))> (%a0) + %a12 = affine.apply affine_map<(d0) -> + ((((d0 mod 294912) mod 147456) floordiv 1152) floordiv 8)> (%a0) + %a13 = affine.apply affine_map<(d0) -> + ((((d0 mod 294912) mod 147456) mod 1152) floordiv 384)> (%a0) + %a14 = affine.apply affine_map<(d0) -> + (((((d0 mod 294912) mod 147456) mod 1152) mod 384) floordiv 128)> (%a0) + %a15 = affine.apply affine_map<(d0) -> ((((((d0 mod 294912) mod 147456) mod 1152) mod 384) mod 128) - floordiv 128) (%a0) + floordiv 128)> (%a0) %v0 = affine.load %in[%a10, %a11, %a13, %a14, %a12, %a15] : memref<2x2x3x3x16x1xi32> // expected-remark@above {{dependence from 1 to 0 at depth 1 = false}} // expected-remark@above {{dependence from 1 to 1 at depth 1 = false}} @@ -813,7 +813,7 @@ func @strided_loop_with_no_dependence() { %0 = alloc() : memref<10xf32> %cf0 = constant 0.0 : f32 affine.for %i0 = 0 to 8 step 2 { - %a0 = affine.apply (d0) -> (d0 + 1)(%i0) + %a0 = affine.apply affine_map<(d0) -> (d0 + 1)>(%i0) affine.store %cf0, %0[%a0] : memref<10xf32> // expected-remark@above {{dependence from 0 to 0 at depth 1 = false}} // expected-remark@above {{dependence from 0 to 0 at depth 2 = false}} @@ -836,7 +836,7 @@ func @strided_loop_with_loop_carried_dependence_at_depth1() { %0 = alloc() : memref<10xf32> %cf0 = constant 0.0 : f32 affine.for %i0 = 0 to 8 step 2 { - %a0 = affine.apply (d0) -> (d0 + 4)(%i0) + %a0 = affine.apply affine_map<(d0) -> (d0 + 4)>(%i0) affine.store %cf0, %0[%a0] : memref<10xf32> // expected-remark@above {{dependence from 0 to 0 at depth 1 = false}} // expected-remark@above {{dependence from 0 to 0 at depth 2 = false}} @@ -860,13 +860,13 @@ func @test_dep_store_depth1_load_depth2() { %0 = alloc() : memref<100xf32> %cst = constant 7.000000e+00 : f32 affine.for %i0 = 0 to 10 { - %a0 = affine.apply (d0) -> (d0 - 1)(%i0) + %a0 = affine.apply affine_map<(d0) -> (d0 - 1)>(%i0) affine.store %cst, %0[%a0] : memref<100xf32> // expected-remark@above {{dependence from 0 to 0 at depth 1 = false}} // expected-remark@above {{dependence from 0 to 0 at depth 2 = false}} // expected-remark@above {{dependence from 0 to 1 at depth 1 = false}} // expected-remark@above {{dependence from 0 to 1 at depth 2 = false}} - affine.for %i1 = (d0) -> (d0)(%i0) to (d0) -> (d0 + 1)(%i0) { + affine.for %i1 = affine_map<(d0) -> (d0)>(%i0) to affine_map<(d0) -> (d0 + 1)>(%i0) { %1 = affine.load %0[%i1] : memref<100xf32> // expected-remark@above {{dependence from 1 to 0 at depth 1 = [1, 1]}} // expected-remark@above {{dependence from 1 to 0 at depth 2 = false}} @@ -887,7 +887,7 @@ func @test_dep_store_depth2_load_depth1() { %0 = alloc() : memref<100xf32> %cst = constant 7.000000e+00 : f32 affine.for %i0 = 0 to 10 { - affine.for %i1 = (d0) -> (d0)(%i0) to (d0) -> (d0 + 1)(%i0) { + affine.for %i1 = affine_map<(d0) -> (d0)>(%i0) to affine_map<(d0) -> (d0 + 1)>(%i0) { affine.store %cst, %0[%i1] : memref<100xf32> // expected-remark@above {{dependence from 0 to 0 at depth 1 = false}} // expected-remark@above {{dependence from 0 to 0 at depth 2 = false}} @@ -895,7 +895,7 @@ func @test_dep_store_depth2_load_depth1() { // expected-remark@above {{dependence from 0 to 1 at depth 1 = [2, 2]}} // expected-remark@above {{dependence from 0 to 1 at depth 2 = false}} } - %a0 = affine.apply (d0) -> (d0 - 2)(%i0) + %a0 = affine.apply affine_map<(d0) -> (d0 - 2)>(%i0) %1 = affine.load %0[%a0] : memref<100xf32> // expected-remark@above {{dependence from 1 to 0 at depth 1 = false}} // expected-remark@above {{dependence from 1 to 0 at depth 2 = false}} diff --git a/mlir/test/Transforms/memref-normalize.mlir b/mlir/test/Transforms/memref-normalize.mlir index 90b363219ee..2ed69da5fb0 100644 --- a/mlir/test/Transforms/memref-normalize.mlir +++ b/mlir/test/Transforms/memref-normalize.mlir @@ -2,13 +2,13 @@ // CHECK-LABEL: func @permute() func @permute() { - %A = alloc() : memref<64x256xf32, (d0, d1) -> (d1, d0)> + %A = alloc() : memref<64x256xf32, affine_map<(d0, d1) -> (d1, d0)>> affine.for %i = 0 to 64 { affine.for %j = 0 to 256 { - affine.load %A[%i, %j] : memref<64x256xf32, (d0, d1) -> (d1, d0)> + affine.load %A[%i, %j] : memref<64x256xf32, affine_map<(d0, d1) -> (d1, d0)>> } } - dealloc %A : memref<64x256xf32, (d0, d1) -> (d1, d0)> + dealloc %A : memref<64x256xf32, affine_map<(d0, d1) -> (d1, d0)>> return } // The old memref alloc should disappear. @@ -25,11 +25,11 @@ func @permute() { // CHECK-LABEL: func @shift func @shift(%idx : index) { // CHECK-NEXT: alloc() : memref<65xf32> - %A = alloc() : memref<64xf32, (d0) -> (d0 + 1)> + %A = alloc() : memref<64xf32, affine_map<(d0) -> (d0 + 1)>> // CHECK-NEXT: affine.load %{{.*}}[symbol(%arg0) + 1] : memref<65xf32> - affine.load %A[%idx] : memref<64xf32, (d0) -> (d0 + 1)> + affine.load %A[%idx] : memref<64xf32, affine_map<(d0) -> (d0 + 1)>> affine.for %i = 0 to 64 { - affine.load %A[%i] : memref<64xf32, (d0) -> (d0 + 1)> + affine.load %A[%i] : memref<64xf32, affine_map<(d0) -> (d0 + 1)>> // CHECK: %{{.*}} = affine.load %{{.*}}[%arg{{.*}} + 1] : memref<65xf32> } return @@ -38,14 +38,14 @@ func @shift(%idx : index) { // CHECK-LABEL: func @high_dim_permute() func @high_dim_permute() { // CHECK-NOT: memref<64x128x256xf32, - %A = alloc() : memref<64x128x256xf32, (d0, d1, d2) -> (d2, d0, d1)> + %A = alloc() : memref<64x128x256xf32, affine_map<(d0, d1, d2) -> (d2, d0, d1)>> // CHECK: %[[I:arg[0-9]+]] affine.for %i = 0 to 64 { // CHECK: %[[J:arg[0-9]+]] affine.for %j = 0 to 128 { // CHECK: %[[K:arg[0-9]+]] affine.for %k = 0 to 256 { - affine.load %A[%i, %j, %k] : memref<64x128x256xf32, (d0, d1, d2) -> (d2, d0, d1)> + affine.load %A[%i, %j, %k] : memref<64x128x256xf32, affine_map<(d0, d1, d2) -> (d2, d0, d1)>> // CHECK: %{{.*}} = affine.load %{{.*}}[%[[K]], %[[I]], %[[J]]] : memref<256x64x128xf32> } } @@ -55,7 +55,7 @@ func @high_dim_permute() { // CHECK-LABEL: func @invalid_map func @invalid_map() { - %A = alloc() : memref<64x128xf32, (d0, d1) -> (d0, -d1 - 10)> + %A = alloc() : memref<64x128xf32, affine_map<(d0, d1) -> (d0, -d1 - 10)>> // CHECK: %{{.*}} = alloc() : memref<64x128xf32, return } @@ -64,22 +64,22 @@ func @invalid_map() { // CHECK-LABEL: func @data_tiling func @data_tiling(%idx : index) { // CHECK: alloc() : memref<8x32x8x16xf32> - %A = alloc() : memref<64x512xf32, (d0, d1) -> (d0 floordiv 8, d1 floordiv 16, d0 mod 8, d1 mod 16)> + %A = alloc() : memref<64x512xf32, affine_map<(d0, d1) -> (d0 floordiv 8, d1 floordiv 16, d0 mod 8, d1 mod 16)>> // CHECK: affine.load %{{.*}}[symbol(%arg0) floordiv 8, symbol(%arg0) floordiv 16, symbol(%arg0) mod 8, symbol(%arg0) mod 16] - affine.load %A[%idx, %idx] : memref<64x512xf32, (d0, d1) -> (d0 floordiv 8, d1 floordiv 16, d0 mod 8, d1 mod 16)> + affine.load %A[%idx, %idx] : memref<64x512xf32, affine_map<(d0, d1) -> (d0 floordiv 8, d1 floordiv 16, d0 mod 8, d1 mod 16)>> return } // Strides 2 and 4 along respective dimensions. // CHECK-LABEL: func @strided func @strided() { - %A = alloc() : memref<64x128xf32, (d0, d1) -> (2*d0, 4*d1)> + %A = alloc() : memref<64x128xf32, affine_map<(d0, d1) -> (2*d0, 4*d1)>> // CHECK: affine.for %[[IV0:.*]] = affine.for %i = 0 to 64 { // CHECK: affine.for %[[IV1:.*]] = affine.for %j = 0 to 128 { // CHECK: affine.load %{{.*}}[%[[IV0]] * 2, %[[IV1]] * 4] : memref<127x509xf32> - affine.load %A[%i, %j] : memref<64x128xf32, (d0, d1) -> (2*d0, 4*d1)> + affine.load %A[%i, %j] : memref<64x128xf32, affine_map<(d0, d1) -> (2*d0, 4*d1)>> } } return @@ -88,13 +88,13 @@ func @strided() { // Strided, but the strides are in the linearized space. // CHECK-LABEL: func @strided_cumulative func @strided_cumulative() { - %A = alloc() : memref<2x5xf32, (d0, d1) -> (3*d0 + 17*d1)> + %A = alloc() : memref<2x5xf32, affine_map<(d0, d1) -> (3*d0 + 17*d1)>> // CHECK: affine.for %[[IV0:.*]] = affine.for %i = 0 to 2 { // CHECK: affine.for %[[IV1:.*]] = affine.for %j = 0 to 5 { // CHECK: affine.load %{{.*}}[%[[IV0]] * 3 + %[[IV1]] * 17] : memref<72xf32> - affine.load %A[%i, %j] : memref<2x5xf32, (d0, d1) -> (3*d0 + 17*d1)> + affine.load %A[%i, %j] : memref<2x5xf32, affine_map<(d0, d1) -> (3*d0 + 17*d1)>> } } return @@ -105,11 +105,11 @@ func @strided_cumulative() { // CHECK-LABEL: func @symbolic_operands func @symbolic_operands(%s : index) { // CHECK: alloc() : memref<100xf32> - %A = alloc()[%s] : memref<10x10xf32, (d0,d1)[s0] -> (10*d0 + d1)> + %A = alloc()[%s] : memref<10x10xf32, affine_map<(d0,d1)[s0] -> (10*d0 + d1)>> affine.for %i = 0 to 10 { affine.for %j = 0 to 10 { // CHECK: affine.load %{{.*}}[%{{.*}} * 10 + %{{.*}}] : memref<100xf32> - affine.load %A[%i, %j] : memref<10x10xf32, (d0,d1)[s0] -> (10*d0 + d1)> + affine.load %A[%i, %j] : memref<10x10xf32, affine_map<(d0,d1)[s0] -> (10*d0 + d1)>> } } return @@ -117,20 +117,20 @@ func @symbolic_operands(%s : index) { // Memref escapes; no normalization. // CHECK-LABEL: func @escaping() -> memref<64xf32, #map{{[0-9]+}}> -func @escaping() -> memref<64xf32, (d0) -> (d0 + 2)> { +func @escaping() -> memref<64xf32, affine_map<(d0) -> (d0 + 2)>> { // CHECK: %{{.*}} = alloc() : memref<64xf32, #map{{[0-9]+}}> - %A = alloc() : memref<64xf32, (d0) -> (d0 + 2)> - return %A : memref<64xf32, (d0) -> (d0 + 2)> + %A = alloc() : memref<64xf32, affine_map<(d0) -> (d0 + 2)>> + return %A : memref<64xf32, affine_map<(d0) -> (d0 + 2)>> } // Semi-affine maps, normalization not implemented yet. // CHECK-LABEL: func @semi_affine_layout_map func @semi_affine_layout_map(%s0: index, %s1: index) { - %A = alloc()[%s0, %s1] : memref<256x1024xf32, (d0, d1)[s0, s1] -> (d0*s0 + d1*s1)> + %A = alloc()[%s0, %s1] : memref<256x1024xf32, affine_map<(d0, d1)[s0, s1] -> (d0*s0 + d1*s1)>> affine.for %i = 0 to 256 { affine.for %j = 0 to 1024 { // CHECK: memref<256x1024xf32, #map{{[0-9]+}}> - affine.load %A[%i, %j] : memref<256x1024xf32, (d0, d1)[s0, s1] -> (d0*s0 + d1*s1)> + affine.load %A[%i, %j] : memref<256x1024xf32, affine_map<(d0, d1)[s0, s1] -> (d0*s0 + d1*s1)>> } } return diff --git a/mlir/test/Transforms/pipeline-data-transfer.mlir b/mlir/test/Transforms/pipeline-data-transfer.mlir index c4e17ce1682..8293120d50e 100644 --- a/mlir/test/Transforms/pipeline-data-transfer.mlir +++ b/mlir/test/Transforms/pipeline-data-transfer.mlir @@ -2,14 +2,14 @@ // ----- -// CHECK-DAG: [[MOD_2:#map[0-9]+]] = (d0) -> (d0 mod 2) -// CHECK-DAG: [[MAP_MINUS_1:#map[0-9]+]] = (d0) -> (d0 - 1) +// CHECK-DAG: [[MOD_2:#map[0-9]+]] = affine_map<(d0) -> (d0 mod 2)> +// CHECK-DAG: [[MAP_MINUS_1:#map[0-9]+]] = affine_map<(d0) -> (d0 - 1)> // CHECK-LABEL: func @loop_nest_dma() { func @loop_nest_dma() { - %A = alloc() : memref<256 x f32, (d0) -> (d0), 0> - %Ah = alloc() : memref<32 x f32, (d0) -> (d0), 1> + %A = alloc() : memref<256 x f32, affine_map<(d0) -> (d0)>, 0> + %Ah = alloc() : memref<32 x f32, affine_map<(d0) -> (d0)>, 1> %tag = alloc() : memref<1 x f32> @@ -19,15 +19,15 @@ func @loop_nest_dma() { affine.for %i = 0 to 8 { affine.dma_start %A[%i], %Ah[%i], %tag[%zero], %num_elts : memref<256 x f32>, memref<32 x f32, 1>, memref<1 x f32> affine.dma_wait %tag[%zero], %num_elts : memref<1 x f32> - %v = affine.load %Ah[%i] : memref<32 x f32, (d0) -> (d0), 1> + %v = affine.load %Ah[%i] : memref<32 x f32, affine_map<(d0) -> (d0)>, 1> %r = "compute"(%v) : (f32) -> (f32) - affine.store %r, %Ah[%i] : memref<32 x f32, (d0) -> (d0), 1> + affine.store %r, %Ah[%i] : memref<32 x f32, affine_map<(d0) -> (d0)>, 1> affine.for %j = 0 to 32 { "do_more_compute"(%i, %j) : (index, index) -> () } } dealloc %tag : memref<1 x f32> - dealloc %Ah : memref<32 x f32, (d0) -> (d0), 1> + dealloc %Ah : memref<32 x f32, affine_map<(d0) -> (d0)>, 1> return } // CHECK: %{{.*}} = alloc() : memref<256xf32> @@ -64,8 +64,8 @@ func @loop_nest_dma() { // ----- -// CHECK-DAG: [[FLOOR_MOD_2:#map[0-9]+]] = (d0) -> ((d0 floordiv 4) mod 2) -// CHECK-DAG: [[REMAP_SHIFT_MINUS_4:#map[0-9]+]] = (d0) -> (d0 - 4) +// CHECK-DAG: [[FLOOR_MOD_2:#map[0-9]+]] = affine_map<(d0) -> ((d0 floordiv 4) mod 2)> +// CHECK-DAG: [[REMAP_SHIFT_MINUS_4:#map[0-9]+]] = affine_map<(d0) -> (d0 - 4)> // CHECK-LABEL: @loop_step func @loop_step(%arg0: memref<512xf32>, @@ -105,8 +105,8 @@ func @loop_step(%arg0: memref<512xf32>, // ----- -#map1 = (d0, d1) -> ((d0 * 2048 + d1 * 256) floordiv 32) -#map2 = (d0) -> ((d0 * 2048) floordiv 32) +#map1 = affine_map<(d0, d1) -> ((d0 * 2048 + d1 * 256) floordiv 32)> +#map2 = affine_map<(d0) -> ((d0 * 2048) floordiv 32)> // CHECK-LABEL: func @loop_dma_nested(%{{.*}}: memref<512x32xvector<8xf32> func @loop_dma_nested(%arg0: memref<512x32xvector<8xf32>>, %arg1: memref<512x32xvector<8xf32>>, %arg2: memref<512x32xvector<8xf32>>) { %num_elts = constant 256 : index @@ -199,7 +199,7 @@ func @loop_dma_nested(%arg0: memref<512x32xvector<8xf32>>, %arg1: memref<512x32x } // ----- -#map2 = (d0) -> ((d0 * 2048) floordiv 32) +#map2 = affine_map<(d0) -> ((d0 * 2048) floordiv 32)> // CHECK: func @loop_dma_dependent func @loop_dma_dependent(%arg2: memref<512x32xvector<8xf32>>) { @@ -356,8 +356,8 @@ func @dynamic_shape_dma_buffer(%arg0: memref<512 x 32 x f32>) { // before performing any replacement. // CHECK-LABEL: func @escaping_and_indexed_use_mix func @escaping_and_indexed_use_mix() { - %A = alloc() : memref<256 x f32, (d0) -> (d0), 0> - %Ah = alloc() : memref<32 x f32, (d0) -> (d0), 1> + %A = alloc() : memref<256 x f32, affine_map<(d0) -> (d0)>, 0> + %Ah = alloc() : memref<32 x f32, affine_map<(d0) -> (d0)>, 1> %tag = alloc() : memref<1 x f32> %zero = constant 0 : index %num_elts = constant 32 : index @@ -367,11 +367,11 @@ func @escaping_and_indexed_use_mix() { affine.dma_start %A[%i], %Ah[%i], %tag[%zero], %num_elts : memref<256 x f32>, memref<32 x f32, 1>, memref<1 x f32> affine.dma_wait %tag[%zero], %num_elts : memref<1 x f32> "compute"(%Ah) : (memref<32 x f32, 1>) -> () - %v = affine.load %Ah[%i] : memref<32 x f32, (d0) -> (d0), 1> + %v = affine.load %Ah[%i] : memref<32 x f32, affine_map<(d0) -> (d0)>, 1> "foo"(%v) : (f32) -> () } - dealloc %A : memref<256 x f32, (d0) -> (d0), 0> - dealloc %Ah : memref<32 x f32, (d0) -> (d0), 1> + dealloc %A : memref<256 x f32, affine_map<(d0) -> (d0)>, 0> + dealloc %Ah : memref<32 x f32, affine_map<(d0) -> (d0)>, 1> return } // No replacement. diff --git a/mlir/test/Transforms/simplify-affine-structures.mlir b/mlir/test/Transforms/simplify-affine-structures.mlir index 9e5e7f966d2..89f37d0b6c9 100644 --- a/mlir/test/Transforms/simplify-affine-structures.mlir +++ b/mlir/test/Transforms/simplify-affine-structures.mlir @@ -1,39 +1,40 @@ // RUN: mlir-opt %s -simplify-affine-structures | FileCheck %s -// CHECK-DAG: [[SET_EMPTY_2D:#set[0-9]+]] = (d0, d1) : (1 == 0) -// CHECK-DAG: #set1 = (d0, d1) : (d0 - 100 == 0, d1 - 10 == 0, -d0 + 100 >= 0, d1 >= 0, d1 + 101 >= 0) -// CHECK-DAG: #set2 = (d0, d1)[s0, s1] : (1 == 0) -// CHECK-DAG: #set3 = (d0, d1)[s0, s1] : (d0 * 7 + d1 * 5 + s0 * 11 + s1 == 0, d0 * 5 - d1 * 11 + s0 * 7 + s1 == 0, d0 * 11 + d1 * 7 - s0 * 5 + s1 == 0, d0 * 7 + d1 * 5 + s0 * 11 + s1 == 0) -// CHECK-DAG: [[SET_EMPTY_1D:#set[0-9]+]] = (d0) : (1 == 0) -// CHECK-DAG: [[SET_EMPTY_1D_2S:#set[0-9]+]] = (d0)[s0, s1] : (1 == 0) -// CHECK-DAG: [[SET_EMPTY_3D:#set[0-9]+]] = (d0, d1, d2) : (1 == 0) +// CHECK-DAG: [[SET_EMPTY_2D:#set[0-9]+]] = affine_set<(d0, d1) : (1 == 0)> +// CHECK-DAG: #set1 = affine_set<(d0, d1) : (d0 - 100 == 0, d1 - 10 == 0, -d0 + 100 >= 0, d1 >= 0, d1 + 101 >= 0)> +// CHECK-DAG: #set2 = affine_set<(d0, d1)[s0, s1] : (1 == 0)> +// CHECK-DAG: #set3 = affine_set<(d0, d1)[s0, s1] : (d0 * 7 + d1 * 5 + s0 * 11 + s1 == 0, d0 * 5 - d1 * 11 + s0 * 7 + s1 == 0, d0 * 11 + d1 * 7 - s0 * 5 + s1 == 0, d0 * 7 + d1 * 5 + s0 * 11 + s1 == 0)> +// CHECK-DAG: [[SET_EMPTY_1D:#set[0-9]+]] = affine_set<(d0) : (1 == 0)> +// CHECK-DAG: [[SET_EMPTY_1D_2S:#set[0-9]+]] = affine_set<(d0)[s0, s1] : (1 == 0)> +// CHECK-DAG: [[SET_EMPTY_3D:#set[0-9]+]] = affine_set<(d0, d1, d2) : (1 == 0)> // Set for test case: test_gaussian_elimination_non_empty_set2 -// #set2 = (d0, d1) : (d0 - 100 == 0, d1 - 10 == 0, -d0 + 100 >= 0, d1 >= 0, d1 + 101 >= 0) -#set2 = (d0, d1) : (d0 - 100 == 0, d1 - 10 == 0, -d0 + 100 >= 0, d1 >= 0, d1 + 101 >= 0) +// #set2 = affine_set<(d0, d1) : (d0 - 100 == 0, d1 - 10 == 0, -d0 + 100 >= 0, d1 >= 0, d1 + 101 >= 0)> +#set2 = affine_set<(d0, d1) : (d0 - 100 == 0, d1 - 10 == 0, -d0 + 100 >= 0, d1 >= 0, d1 + 101 >= 0)> // Set for test case: test_gaussian_elimination_empty_set3 -// #set3 = (d0, d1)[s0, s1] : (1 == 0) -#set3 = (d0, d1)[s0, s1] : (d0 - s0 == 0, d0 + s0 == 0, s0 - 1 == 0) +// #set3 = affine_set<(d0, d1)[s0, s1] : (1 == 0)> +#set3 = affine_set<(d0, d1)[s0, s1] : (d0 - s0 == 0, d0 + s0 == 0, s0 - 1 == 0)> // Set for test case: test_gaussian_elimination_non_empty_set4 -#set4 = (d0, d1)[s0, s1] : (d0 * 7 + d1 * 5 + s0 * 11 + s1 == 0, - d0 * 5 - d1 * 11 + s0 * 7 + s1 == 0, - d0 * 11 + d1 * 7 - s0 * 5 + s1 == 0, - d0 * 7 + d1 * 5 + s0 * 11 + s1 == 0) +#set4 = affine_set<(d0, d1)[s0, s1] : (d0 * 7 + d1 * 5 + s0 * 11 + s1 == 0, + d0 * 5 - d1 * 11 + s0 * 7 + s1 == 0, + d0 * 11 + d1 * 7 - s0 * 5 + s1 == 0, + d0 * 7 + d1 * 5 + s0 * 11 + s1 == 0)> // Add invalid constraints to previous non-empty set to make it empty. // Set for test case: test_gaussian_elimination_empty_set5 -#set5 = (d0, d1)[s0, s1] : (d0 * 7 + d1 * 5 + s0 * 11 + s1 == 0, - d0 * 5 - d1 * 11 + s0 * 7 + s1 == 0, - d0 * 11 + d1 * 7 - s0 * 5 + s1 == 0, - d0 * 7 + d1 * 5 + s0 * 11 + s1 == 0, - d0 - 1 == 0, d0 + 2 == 0) +#set5 = affine_set<(d0, d1)[s0, s1] : (d0 * 7 + d1 * 5 + s0 * 11 + s1 == 0, + d0 * 5 - d1 * 11 + s0 * 7 + s1 == 0, + d0 * 11 + d1 * 7 - s0 * 5 + s1 == 0, + d0 * 7 + d1 * 5 + s0 * 11 + s1 == 0, + d0 - 1 == 0, d0 + 2 == 0)> // This is an artificially created system to exercise the worst case behavior of // FM elimination - as a safeguard against improperly constructed constraint // systems or fuzz input. -#set_fuzz_virus = (d0, d1, d2, d3, d4, d5) : ( 1089234*d0 + 203472*d1 + 82342 >= 0, +#set_fuzz_virus = affine_set<(d0, d1, d2, d3, d4, d5) : ( + 1089234*d0 + 203472*d1 + 82342 >= 0, -55*d0 + 24*d1 + 238*d2 - 234*d3 - 9743 >= 0, -5445*d0 - 284*d1 + 23*d2 + 34*d3 - 5943 >= 0, -5445*d0 + 284*d1 + 238*d2 - 34*d3 >= 0, @@ -63,20 +64,20 @@ 2039*d0 + 793*d2 - 99*d3 - 24*d4 + 234*d5 >= 0, 78*d2 - 788*d5 + 257 >= 0, d3 - (d5 + 97*d0) floordiv 423 >= 0, - 234* (d0 + d3 mod 5 floordiv 2342) mod 2309 + 234* (d0 + d3 mod 5 floordiv 2342) mod 2309 + (d0 + 2038*d3) floordiv 208 >= 0, - 239* (d0 + 2300 * d3) floordiv 2342 + 239* (d0 + 2300 * d3) floordiv 2342 mod 2309 mod 239423 == 0, - d0 + d3 mod 2642 + (d3 + 2*d0) mod 1247 + d0 + d3 mod 2642 + (d3 + 2*d0) mod 1247 mod 2038 mod 2390 mod 2039 floordiv 55 >= 0 -) +)> // CHECK-LABEL: func @test_gaussian_elimination_empty_set0() { func @test_gaussian_elimination_empty_set0() { affine.for %arg0 = 1 to 10 { affine.for %arg1 = 1 to 100 { // CHECK: [[SET_EMPTY_2D]](%arg0, %arg1) - affine.if (d0, d1) : (2 == 0)(%arg0, %arg1) { + affine.if affine_set<(d0, d1) : (2 == 0)>(%arg0, %arg1) { } } } @@ -88,7 +89,7 @@ func @test_gaussian_elimination_empty_set1() { affine.for %arg0 = 1 to 10 { affine.for %arg1 = 1 to 100 { // CHECK: [[SET_EMPTY_2D]](%arg0, %arg1) - affine.if (d0, d1) : (1 >= 0, -1 >= 0) (%arg0, %arg1) { + affine.if affine_set<(d0, d1) : (1 >= 0, -1 >= 0)> (%arg0, %arg1) { } } } @@ -166,33 +167,33 @@ func @test_empty_set(%N : index) { affine.for %i = 0 to 10 { affine.for %j = 0 to 10 { // CHECK: affine.if [[SET_EMPTY_2D]](%arg1, %arg2) - affine.if (d0, d1) : (d0 - d1 >= 0, d1 - d0 - 1 >= 0)(%i, %j) { + affine.if affine_set<(d0, d1) : (d0 - d1 >= 0, d1 - d0 - 1 >= 0)>(%i, %j) { "foo"() : () -> () } // CHECK: affine.if [[SET_EMPTY_1D]](%arg1) - affine.if (d0) : (d0 >= 0, -d0 - 1 >= 0)(%i) { + affine.if affine_set<(d0) : (d0 >= 0, -d0 - 1 >= 0)>(%i) { "bar"() : () -> () } // CHECK: affine.if [[SET_EMPTY_1D]](%arg1) - affine.if (d0) : (d0 >= 0, -d0 - 1 >= 0)(%i) { + affine.if affine_set<(d0) : (d0 >= 0, -d0 - 1 >= 0)>(%i) { "foo"() : () -> () } // CHECK: affine.if [[SET_EMPTY_1D_2S]](%arg1)[%arg0, %arg0] - affine.if (d0)[s0, s1] : (d0 >= 0, -d0 + s0 - 1 >= 0, -s0 >= 0)(%i)[%N, %N] { + affine.if affine_set<(d0)[s0, s1] : (d0 >= 0, -d0 + s0 - 1 >= 0, -s0 >= 0)>(%i)[%N, %N] { "bar"() : () -> () } // CHECK: affine.if [[SET_EMPTY_3D]](%arg1, %arg2, %arg0) // The set below implies d0 = d1; so d1 >= d0, but d0 >= d1 + 1. - affine.if (d0, d1, d2) : (d0 - d1 == 0, d2 - d0 >= 0, d0 - d1 - 1 >= 0)(%i, %j, %N) { + affine.if affine_set<(d0, d1, d2) : (d0 - d1 == 0, d2 - d0 >= 0, d0 - d1 - 1 >= 0)>(%i, %j, %N) { "foo"() : () -> () } // CHECK: affine.if [[SET_EMPTY_2D]](%arg1, %arg2) // The set below has rational solutions but no integer solutions; GCD test catches it. - affine.if (d0, d1) : (d0*2 -d1*2 - 1 == 0, d0 >= 0, -d0 + 100 >= 0, d1 >= 0, -d1 + 100 >= 0)(%i, %j) { + affine.if affine_set<(d0, d1) : (d0*2 -d1*2 - 1 == 0, d0 >= 0, -d0 + 100 >= 0, d1 >= 0, -d1 + 100 >= 0)>(%i, %j) { "foo"() : () -> () } // CHECK: affine.if [[SET_EMPTY_2D]](%arg1, %arg2) - affine.if (d0, d1) : (d1 == 0, d0 - 1 >= 0, - d0 - 1 >= 0)(%i, %j) { + affine.if affine_set<(d0, d1) : (d1 == 0, d0 - 1 >= 0, - d0 - 1 >= 0)>(%i, %j) { "foo"() : () -> () } } @@ -202,12 +203,12 @@ func @test_empty_set(%N : index) { affine.for %l = 0 to 10 { // Empty because no multiple of 8 lies between 4 and 7. // CHECK: affine.if [[SET_EMPTY_1D]](%arg1) - affine.if (d0) : (8*d0 - 4 >= 0, -8*d0 + 7 >= 0)(%k) { + affine.if affine_set<(d0) : (8*d0 - 4 >= 0, -8*d0 + 7 >= 0)>(%k) { "foo"() : () -> () } // Same as above but with equalities and inequalities. // CHECK: affine.if [[SET_EMPTY_2D]](%arg1, %arg2) - affine.if (d0, d1) : (d0 - 4*d1 == 0, 4*d1 - 5 >= 0, -4*d1 + 7 >= 0)(%k, %l) { + affine.if affine_set<(d0, d1) : (d0 - 4*d1 == 0, 4*d1 - 5 >= 0, -4*d1 + 7 >= 0)>(%k, %l) { "foo"() : () -> () } // Same as above but with a combination of multiple identifiers. 4*d0 + @@ -215,12 +216,12 @@ func @test_empty_set(%N : index) { // tightening will tighten constraints to 4*d0 + 8*d1 >= 12 and 4*d0 + // 8*d1 <= 8; hence infeasible. // CHECK: affine.if [[SET_EMPTY_2D]](%arg1, %arg2) - affine.if (d0, d1) : (4*d0 + 8*d1 - 9 >= 0, -4*d0 - 8*d1 + 11 >= 0)(%k, %l) { + affine.if affine_set<(d0, d1) : (4*d0 + 8*d1 - 9 >= 0, -4*d0 - 8*d1 + 11 >= 0)>(%k, %l) { "foo"() : () -> () } // Same as above but with equalities added into the mix. // CHECK: affine.if [[SET_EMPTY_3D]](%arg1, %arg1, %arg2) - affine.if (d0, d1, d2) : (d0 - 4*d2 == 0, d0 + 8*d1 - 9 >= 0, -d0 - 8*d1 + 11 >= 0)(%k, %k, %l) { + affine.if affine_set<(d0, d1, d2) : (d0 - 4*d2 == 0, d0 + 8*d1 - 9 >= 0, -d0 - 8*d1 + 11 >= 0)>(%k, %k, %l) { "foo"() : () -> () } } @@ -228,7 +229,7 @@ func @test_empty_set(%N : index) { affine.for %m = 0 to 10 { // CHECK: affine.if [[SET_EMPTY_1D]](%arg{{[0-9]+}}) - affine.if (d0) : (d0 mod 2 - 3 == 0) (%m) { + affine.if affine_set<(d0) : (d0 mod 2 - 3 == 0)> (%m) { "foo"() : () -> () } } diff --git a/mlir/test/Transforms/slicing-utils.mlir b/mlir/test/Transforms/slicing-utils.mlir index 8c6fb01e1f7..145695db5fb 100644 --- a/mlir/test/Transforms/slicing-utils.mlir +++ b/mlir/test/Transforms/slicing-utils.mlir @@ -225,7 +225,7 @@ func @slicing_test_2() { %c2 = constant 2 : index %c16 = constant 16 : index affine.for %i0 = %c0 to %c16 { - affine.for %i1 = (i)[] -> (i)(%i0) to 10 { + affine.for %i1 = affine_map<(i)[] -> (i)>(%i0) to 10 { // BWD: matched: %[[b:.*]] {{.*}} backward static slice: // BWD: affine.for {{.*}} diff --git a/mlir/test/Transforms/strip-debuginfo.mlir b/mlir/test/Transforms/strip-debuginfo.mlir index 9c746fa9c09..49bb22052f9 100644 --- a/mlir/test/Transforms/strip-debuginfo.mlir +++ b/mlir/test/Transforms/strip-debuginfo.mlir @@ -1,7 +1,7 @@ // RUN: mlir-opt %s -mlir-print-debuginfo -strip-debuginfo | FileCheck %s // This test verifies that debug locations are stripped. -#set0 = (d0) : (1 == 0) +#set0 = affine_set<(d0) : (1 == 0)> // CHECK-LABEL: func @inline_notation func @inline_notation() -> i32 { diff --git a/mlir/test/Transforms/unroll-jam.mlir b/mlir/test/Transforms/unroll-jam.mlir index be46548f652..60de5f17508 100644 --- a/mlir/test/Transforms/unroll-jam.mlir +++ b/mlir/test/Transforms/unroll-jam.mlir @@ -1,15 +1,15 @@ // RUN: mlir-opt %s -affine-loop-unroll-jam -unroll-jam-factor=2 | FileCheck %s // RUN: mlir-opt %s -affine-loop-unroll-jam -unroll-jam-factor=4 | FileCheck --check-prefix=UJAM-FOUR %s -// CHECK-DAG: [[MAP_PLUS_1:#map[0-9]+]] = (d0) -> (d0 + 1) -// CHECK-DAG: [[MAP_DIV_OFFSET:#map[0-9]+]] = ()[s0] -> (((s0 - 1) floordiv 2) * 2 + 1) -// CHECK-DAG: [[MAP_MULTI_RES:#map[0-9]+]] = ()[s0, s1] -> ((s0 floordiv 2) * 2, (s1 floordiv 2) * 2, 1024) -// CHECK-DAG: [[MAP_SYM_UB:#map[0-9]+]] = ()[s0, s1] -> (s0, s1, 1024) +// CHECK-DAG: [[MAP_PLUS_1:#map[0-9]+]] = affine_map<(d0) -> (d0 + 1)> +// CHECK-DAG: [[MAP_DIV_OFFSET:#map[0-9]+]] = affine_map<()[s0] -> (((s0 - 1) floordiv 2) * 2 + 1)> +// CHECK-DAG: [[MAP_MULTI_RES:#map[0-9]+]] = affine_map<()[s0, s1] -> ((s0 floordiv 2) * 2, (s1 floordiv 2) * 2, 1024)> +// CHECK-DAG: [[MAP_SYM_UB:#map[0-9]+]] = affine_map<()[s0, s1] -> (s0, s1, 1024)> -// UJAM-FOUR-DAG: [[UBMAP:#map[0-9]+]] = ()[s0] -> (s0 + 8) -// UJAM-FOUR-DAG: [[MAP_PLUS_1:#map[0-9]+]] = (d0) -> (d0 + 1) -// UJAM-FOUR-DAG: [[MAP_PLUS_2:#map[0-9]+]] = (d0) -> (d0 + 2) -// UJAM-FOUR-DAG: [[MAP_PLUS_3:#map[0-9]+]] = (d0) -> (d0 + 3) +// UJAM-FOUR-DAG: [[UBMAP:#map[0-9]+]] = affine_map<()[s0] -> (s0 + 8)> +// UJAM-FOUR-DAG: [[MAP_PLUS_1:#map[0-9]+]] = affine_map<(d0) -> (d0 + 1)> +// UJAM-FOUR-DAG: [[MAP_PLUS_2:#map[0-9]+]] = affine_map<(d0) -> (d0 + 2)> +// UJAM-FOUR-DAG: [[MAP_PLUS_3:#map[0-9]+]] = affine_map<(d0) -> (d0 + 3)> // CHECK-LABEL: func @unroll_jam_imperfect_nest() { func @unroll_jam_imperfect_nest() { @@ -89,7 +89,7 @@ func @loop_nest_unknown_count_2(%N : index) { // UJAM-FOUR-NEXT: affine.for [[IV0]] = 1 to 100 { // UJAM-FOUR-NEXT: "foo"([[RES]]) // UJAM-FOUR-NEXT: } - affine.for %i = %N to ()[s0] -> (s0+9) ()[%N] { + affine.for %i = %N to affine_map<()[s0] -> (s0+9)> ()[%N] { affine.for %j = 1 to 100 { "foo"(%i) : (index) -> () } @@ -102,7 +102,7 @@ func @loop_nest_unknown_count_2(%N : index) { // CHECK-SAME: [[N:arg[0-9]+]]: index // CHECK-SAME: [[K:arg[0-9]+]]: index func @loop_nest_symbolic_and_min_upper_bound(%M : index, %N : index, %K : index) { - affine.for %i = 0 to min ()[s0, s1] -> (s0, s1, 1024)()[%M, %N] { + affine.for %i = 0 to min affine_map<()[s0, s1] -> (s0, s1, 1024)>()[%M, %N] { affine.for %j = 0 to %K { "foo"(%i, %j) : (index, index) -> () } diff --git a/mlir/test/Transforms/unroll.mlir b/mlir/test/Transforms/unroll.mlir index da2a5e59bc9..3414aa1e0d5 100644 --- a/mlir/test/Transforms/unroll.mlir +++ b/mlir/test/Transforms/unroll.mlir @@ -3,25 +3,25 @@ // RUN: mlir-opt %s -affine-loop-unroll -unroll-factor=4 | FileCheck %s --check-prefix UNROLL-BY-4 // RUN: mlir-opt %s -affine-loop-unroll -unroll-factor=1 | FileCheck %s --check-prefix UNROLL-BY-1 -// UNROLL-FULL-DAG: [[MAP0:#map[0-9]+]] = (d0) -> (d0 + 1) -// UNROLL-FULL-DAG: [[MAP1:#map[0-9]+]] = (d0) -> (d0 + 2) -// UNROLL-FULL-DAG: [[MAP2:#map[0-9]+]] = (d0) -> (d0 + 3) -// UNROLL-FULL-DAG: [[MAP3:#map[0-9]+]] = (d0) -> (d0 + 4) -// UNROLL-FULL-DAG: [[MAP4:#map[0-9]+]] = (d0, d1) -> (d0 + 1) -// UNROLL-FULL-DAG: [[MAP5:#map[0-9]+]] = (d0, d1) -> (d0 + 3) -// UNROLL-FULL-DAG: [[MAP6:#map[0-9]+]] = (d0)[s0] -> (d0 + s0 + 1) - -// SHORT-DAG: [[MAP0:#map[0-9]+]] = (d0) -> (d0 + 1) - -// UNROLL-BY-4-DAG: [[MAP0:#map[0-9]+]] = (d0) -> (d0 + 1) -// UNROLL-BY-4-DAG: [[MAP1:#map[0-9]+]] = (d0) -> (d0 + 2) -// UNROLL-BY-4-DAG: [[MAP2:#map[0-9]+]] = (d0) -> (d0 + 3) -// UNROLL-BY-4-DAG: [[MAP3:#map[0-9]+]] = (d0, d1) -> (d0 + 1) -// UNROLL-BY-4-DAG: [[MAP4:#map[0-9]+]] = (d0, d1) -> (d0 + 3) -// UNROLL-BY-4-DAG: [[MAP5:#map[0-9]+]] = (d0)[s0] -> (d0 + s0 + 1) -// UNROLL-BY-4-DAG: [[MAP6:#map[0-9]+]] = (d0, d1) -> (d0 * 16 + d1) -// UNROLL-BY-4-DAG: [[MAP11:#map[0-9]+]] = (d0) -> (d0) -// UNROLL-BY-4-DAG: [[MAP_TRIP_COUNT_MULTIPLE_FOUR:#map[0-9]+]] = ()[s0, s1, s2] -> (s0 + ((-s0 + s1) floordiv 4) * 4, s0 + ((-s0 + s2) floordiv 4) * 4, s0 + ((-s0) floordiv 4) * 4 + 1024) +// UNROLL-FULL-DAG: [[MAP0:#map[0-9]+]] = affine_map<(d0) -> (d0 + 1)> +// UNROLL-FULL-DAG: [[MAP1:#map[0-9]+]] = affine_map<(d0) -> (d0 + 2)> +// UNROLL-FULL-DAG: [[MAP2:#map[0-9]+]] = affine_map<(d0) -> (d0 + 3)> +// UNROLL-FULL-DAG: [[MAP3:#map[0-9]+]] = affine_map<(d0) -> (d0 + 4)> +// UNROLL-FULL-DAG: [[MAP4:#map[0-9]+]] = affine_map<(d0, d1) -> (d0 + 1)> +// UNROLL-FULL-DAG: [[MAP5:#map[0-9]+]] = affine_map<(d0, d1) -> (d0 + 3)> +// UNROLL-FULL-DAG: [[MAP6:#map[0-9]+]] = affine_map<(d0)[s0] -> (d0 + s0 + 1)> + +// SHORT-DAG: [[MAP0:#map[0-9]+]] = affine_map<(d0) -> (d0 + 1)> + +// UNROLL-BY-4-DAG: [[MAP0:#map[0-9]+]] = affine_map<(d0) -> (d0 + 1)> +// UNROLL-BY-4-DAG: [[MAP1:#map[0-9]+]] = affine_map<(d0) -> (d0 + 2)> +// UNROLL-BY-4-DAG: [[MAP2:#map[0-9]+]] = affine_map<(d0) -> (d0 + 3)> +// UNROLL-BY-4-DAG: [[MAP3:#map[0-9]+]] = affine_map<(d0, d1) -> (d0 + 1)> +// UNROLL-BY-4-DAG: [[MAP4:#map[0-9]+]] = affine_map<(d0, d1) -> (d0 + 3)> +// UNROLL-BY-4-DAG: [[MAP5:#map[0-9]+]] = affine_map<(d0)[s0] -> (d0 + s0 + 1)> +// UNROLL-BY-4-DAG: [[MAP6:#map[0-9]+]] = affine_map<(d0, d1) -> (d0 * 16 + d1)> +// UNROLL-BY-4-DAG: [[MAP11:#map[0-9]+]] = affine_map<(d0) -> (d0)> +// UNROLL-BY-4-DAG: [[MAP_TRIP_COUNT_MULTIPLE_FOUR:#map[0-9]+]] = affine_map<()[s0, s1, s2] -> (s0 + ((-s0 + s1) floordiv 4) * 4, s0 + ((-s0 + s2) floordiv 4) * 4, s0 + ((-s0) floordiv 4) * 4 + 1024)> // UNROLL-FULL-LABEL: func @loop_nest_simplest() { func @loop_nest_simplest() { @@ -77,7 +77,7 @@ func @loop_nest_body_def_use() { // UNROLL-FULL-NEXT: %9 = affine.apply [[MAP0]](%8) // UNROLL-FULL-NEXT: %10 = "addi32"(%9, %c0_0) : (index, index) -> index affine.for %j = 0 to 4 { - %x = "affine.apply" (%j) { map = (d0) -> (d0 + 1) } : + %x = "affine.apply" (%j) { map = affine_map<(d0) -> (d0 + 1)> } : (index) -> (index) %y = "addi32"(%x, %c0) : (index, index) -> index } @@ -97,7 +97,7 @@ func @loop_nest_strided() { // UNROLL-FULL-NEXT: %3 = affine.apply [[MAP0]](%2) // UNROLL-FULL-NEXT: %4 = "addi32"(%3, %3) : (index, index) -> index affine.for %j = 2 to 6 step 2 { - %x = "affine.apply" (%j) { map = (d0) -> (d0 + 1) } : + %x = "affine.apply" (%j) { map = affine_map<(d0) -> (d0 + 1)> } : (index) -> (index) %y = "addi32"(%x, %x) : (index, index) -> index } @@ -110,7 +110,7 @@ func @loop_nest_strided() { // UNROLL-FULL-NEXT: %11 = affine.apply [[MAP0]](%10) // UNROLL-FULL-NEXT: %12 = "addi32"(%11, %11) : (index, index) -> index affine.for %k = 2 to 7 step 2 { - %z = "affine.apply" (%k) { map = (d0) -> (d0 + 1) } : + %z = "affine.apply" (%k) { map = affine_map<(d0) -> (d0 + 1)> } : (index) -> (index) %w = "addi32"(%z, %z) : (index, index) -> index } @@ -133,9 +133,9 @@ func @loop_nest_multiple_results() { // UNROLL-FULL-NEXT: %7 = affine.apply #map{{.*}}(%arg0, %4) // UNROLL-FULL-NEXT: %8:2 = "fma"(%7, %5, %5) : (index, index, index) -> (index, index) affine.for %j = 0 to 2 step 1 { - %x = affine.apply (d0, d1) -> (d0 + 1) (%i, %j) + %x = affine.apply affine_map<(d0, d1) -> (d0 + 1)> (%i, %j) %y = "addi32"(%x, %x) : (index, index) -> index - %z = affine.apply (d0, d1) -> (d0 + 3) (%i, %j) + %z = affine.apply affine_map<(d0, d1) -> (d0 + 3)> (%i, %j) %w:2 = "fma"(%z, %x, %x) : (index, index, index) -> (index, index) } } // UNROLL-FULL: } @@ -169,7 +169,7 @@ func @loop_nest_seq_imperfect(%a : memref<128x128xf32>) { // UNROLL-FULL-NEXT: %14 = "vmulf"(%12, %13) : (index, index) -> index // UNROLL-FULL-NEXT: %15 = "vaddf"(%14, %14) : (index, index) -> index affine.for %j = 0 to 4 { - %x = "affine.apply" (%j) { map = (d0) -> (d0 + 1) } : + %x = "affine.apply" (%j) { map = affine_map<(d0) -> (d0 + 1)> } : (index) -> (index) %y = "vmulf"(%j, %x) : (index, index) -> index %z = "vaddf"(%y, %y) : (index, index) -> index @@ -198,7 +198,7 @@ func @loop_nest_seq_multiple() { // UNROLL-FULL-NEXT: %6 = affine.apply [[MAP0]](%5) // UNROLL-FULL-NEXT: "mul"(%6, %6) : (index, index) -> () affine.for %j = 0 to 4 { - %x = "affine.apply" (%j) { map = (d0) -> (d0 + 1) } : + %x = "affine.apply" (%j) { map = affine_map<(d0) -> (d0 + 1)> } : (index) -> (index) "mul"(%x, %x) : (index, index) -> () } @@ -219,9 +219,9 @@ func @loop_nest_seq_multiple() { // UNROLL-FULL-NEXT: %16 = affine.apply [[MAP0]](%15) // UNROLL-FULL-NEXT: %17 = affine.apply [[MAP6]](%15)[%c99] affine.for %n = 0 to 4 { - %y = "affine.apply" (%n) { map = (d0) -> (d0 + 1) } : + %y = "affine.apply" (%n) { map = affine_map<(d0) -> (d0 + 1)> } : (index) -> (index) - %z = "affine.apply" (%n, %k) { map = (d0) [s0] -> (d0 + s0 + 1) } : + %z = "affine.apply" (%n, %k) { map = affine_map<(d0) [s0] -> (d0 + s0 + 1)> } : (index, index) -> (index) } // UNROLL-FULL } } // UNROLL-FULL } @@ -252,7 +252,7 @@ func @loop_nest_outer_unroll() { // SHORT-NEXT: } affine.for %i = 0 to 2 { affine.for %j = 0 to 4 { - %x = "affine.apply" (%j) { map = (d0) -> (d0 + 1) } : + %x = "affine.apply" (%j) { map = affine_map<(d0) -> (d0 + 1)> } : (index) -> (index) %y = "addi32"(%x, %x) : (index, index) -> index } @@ -265,9 +265,9 @@ func @loop_nest_outer_unroll() { // count threshold set to 2. // SHORT-LABEL: func @loop_nest_seq_long() -> i32 { func @loop_nest_seq_long() -> i32 { - %A = alloc() : memref<512 x 512 x i32, (d0, d1) -> (d0, d1), 2> - %B = alloc() : memref<512 x 512 x i32, (d0, d1) -> (d0, d1), 2> - %C = alloc() : memref<512 x 512 x i32, (d0, d1) -> (d0, d1), 2> + %A = alloc() : memref<512 x 512 x i32, affine_map<(d0, d1) -> (d0, d1)>, 2> + %B = alloc() : memref<512 x 512 x i32, affine_map<(d0, d1) -> (d0, d1)>, 2> + %C = alloc() : memref<512 x 512 x i32, affine_map<(d0, d1) -> (d0, d1)>, 2> %zero = constant 0 : i32 %one = constant 1 : i32 @@ -279,9 +279,9 @@ func @loop_nest_seq_long() -> i32 { affine.for %n0 = 0 to 512 { // CHECK: affine.for %arg1 = 0 to 8 affine.for %n1 = 0 to 8 { - store %one, %A[%n0, %n1] : memref<512 x 512 x i32, (d0, d1) -> (d0, d1), 2> - store %two, %B[%n0, %n1] : memref<512 x 512 x i32, (d0, d1) -> (d0, d1), 2> - store %zero, %C[%n0, %n1] : memref<512 x 512 x i32, (d0, d1) -> (d0, d1), 2> + store %one, %A[%n0, %n1] : memref<512 x 512 x i32, affine_map<(d0, d1) -> (d0, d1)>, 2> + store %two, %B[%n0, %n1] : memref<512 x 512 x i32, affine_map<(d0, d1) -> (d0, d1)>, 2> + store %zero, %C[%n0, %n1] : memref<512 x 512 x i32, affine_map<(d0, d1) -> (d0, d1)>, 2> } } @@ -291,28 +291,28 @@ func @loop_nest_seq_long() -> i32 { affine.for %arg2 = 0 to 8 { // CHECK-NOT: affine.for // CHECK: %{{[0-9]+}} = affine.apply - %b2 = "affine.apply" (%y, %arg2) {map = (d0, d1) -> (16*d0 + d1)} : (index, index) -> index - %z = load %B[%x, %b2] : memref<512 x 512 x i32, (d0, d1) -> (d0, d1), 2> + %b2 = "affine.apply" (%y, %arg2) {map = affine_map<(d0, d1) -> (16*d0 + d1)>} : (index, index) -> index + %z = load %B[%x, %b2] : memref<512 x 512 x i32, affine_map<(d0, d1) -> (d0, d1)>, 2> "op1"(%z) : (i32) -> () } affine.for %j1 = 0 to 8 { affine.for %j2 = 0 to 8 { - %a2 = "affine.apply" (%y, %j2) {map = (d0, d1) -> (16*d0 + d1)} : (index, index) -> index - %v203 = load %A[%j1, %a2] : memref<512 x 512 x i32, (d0, d1) -> (d0, d1), 2> + %a2 = "affine.apply" (%y, %j2) {map = affine_map<(d0, d1) -> (16*d0 + d1)>} : (index, index) -> index + %v203 = load %A[%j1, %a2] : memref<512 x 512 x i32, affine_map<(d0, d1) -> (d0, d1)>, 2> "op2"(%v203) : (i32) -> () } affine.for %k2 = 0 to 8 { %s0 = "op3"() : () -> i32 - %c2 = "affine.apply" (%x, %k2) {map = (d0, d1) -> (16*d0 + d1)} : (index, index) -> index - %s1 = load %C[%j1, %c2] : memref<512 x 512 x i32, (d0, d1) -> (d0, d1), 2> + %c2 = "affine.apply" (%x, %k2) {map = affine_map<(d0, d1) -> (16*d0 + d1)>} : (index, index) -> index + %s1 = load %C[%j1, %c2] : memref<512 x 512 x i32, affine_map<(d0, d1) -> (d0, d1)>, 2> %s2 = "addi32"(%s0, %s1) : (i32, i32) -> i32 - store %s2, %C[%j1, %c2] : memref<512 x 512 x i32, (d0, d1) -> (d0, d1), 2> + store %s2, %C[%j1, %c2] : memref<512 x 512 x i32, affine_map<(d0, d1) -> (d0, d1)>, 2> } } "op4"() : () -> () } } - %ret = load %C[%zero_idx, %zero_idx] : memref<512 x 512 x i32, (d0, d1) -> (d0, d1), 2> + %ret = load %C[%zero_idx, %zero_idx] : memref<512 x 512 x i32, affine_map<(d0, d1) -> (d0, d1)>, 2> return %ret : i32 } @@ -441,7 +441,7 @@ func @loop_nest_operand1() { // UNROLL-BY-4-NEXT: } // UNROLL-BY-4-NEXT: return affine.for %i = 0 to 100 step 2 { - affine.for %j = 0 to (d0) -> (d0 - d0 mod 4) (%i) { + affine.for %j = 0 to affine_map<(d0) -> (d0 - d0 mod 4)> (%i) { %x = "foo"() : () -> i32 } } @@ -461,7 +461,7 @@ func @loop_nest_operand2() { // UNROLL-BY-4-NEXT: } // UNROLL-BY-4-NEXT: return affine.for %i = 0 to 100 step 2 { - affine.for %j = (d0) -> (d0) (%i) to (d0) -> (5*d0 + 4) (%i) { + affine.for %j = affine_map<(d0) -> (d0)> (%i) to affine_map<(d0) -> (5*d0 + 4)> (%i) { %x = "foo"() : () -> i32 } } @@ -481,7 +481,7 @@ func @loop_nest_operand3() { // UNROLL-BY-4-NEXT: %4 = "foo"() : () -> i32 // UNROLL-BY-4-NEXT: } // UNROLL-BY-4-NEXT: %0 = "foo"() : () -> i32 - affine.for %j = (d0) -> (d0) (%i) to (d0) -> (d0 + 9) (%i) { + affine.for %j = affine_map<(d0) -> (d0)> (%i) to affine_map<(d0) -> (d0 + 9)> (%i) { %x = "foo"() : () -> i32 } } // UNROLL-BY-4: } @@ -533,7 +533,7 @@ func @loop_nest_symbolic_bound_with_step(%N : index) { // UNROLL-BY-4-LABEL: func @loop_nest_symbolic_and_min_upper_bound func @loop_nest_symbolic_and_min_upper_bound(%M : index, %N : index, %K : index) { - affine.for %i = %M to min ()[s0, s1] -> (s0, s1, 1024)()[%N, %K] { + affine.for %i = %M to min affine_map<()[s0, s1] -> (s0, s1, 1024)>()[%N, %K] { "foo"() : () -> () } return @@ -553,9 +553,9 @@ func @loop_nest_symbolic_and_min_upper_bound(%M : index, %N : index, %K : index) // through composition. Check for no cleanup loop. // UNROLL-BY-4-LABEL: func @loop_nest_non_trivial_multiple_upper_bound func @loop_nest_non_trivial_multiple_upper_bound(%M : index, %N : index) { - %T = affine.apply (d0) -> (4*d0 + 1)(%M) - %K = affine.apply (d0) -> (d0 - 1) (%T) - affine.for %i = 0 to min (d0, d1) -> (4 * d0, d1, 1024)(%N, %K) { + %T = affine.apply affine_map<(d0) -> (4*d0 + 1)>(%M) + %K = affine.apply affine_map<(d0) -> (d0 - 1)> (%T) + affine.for %i = 0 to min affine_map<(d0, d1) -> (4 * d0, d1, 1024)>(%N, %K) { "foo"() : () -> () } return @@ -566,8 +566,8 @@ func @loop_nest_non_trivial_multiple_upper_bound(%M : index, %N : index) { // UNROLL-BY-4-LABEL: func @loop_nest_non_trivial_multiple_upper_bound_alt func @loop_nest_non_trivial_multiple_upper_bound_alt(%M : index, %N : index) { - %K = affine.apply (d0) -> (4*d0) (%M) - affine.for %i = 0 to min ()[s0, s1] -> (4 * s0, s1, 1024)()[%N, %K] { + %K = affine.apply affine_map<(d0) -> (4*d0)> (%M) + affine.for %i = 0 to min affine_map<()[s0, s1] -> (4 * s0, s1, 1024)>()[%N, %K] { "foo"() : () -> () } // UNROLL-BY-4: affine.for %arg2 = 0 to min |