[Mlir-commits] [mlir] 2d231c7 - [MLIR] NFC clean up loop tiling test cases

Uday Bondhugula llvmlistbot at llvm.org
Mon Apr 20 12:44:06 PDT 2020


Author: Uday Bondhugula
Date: 2020-04-21T01:13:46+05:30
New Revision: 2d231c703d6cab7eeb4e9a40c1347b95bdbf4606

URL: https://github.com/llvm/llvm-project/commit/2d231c703d6cab7eeb4e9a40c1347b95bdbf4606
DIFF: https://github.com/llvm/llvm-project/commit/2d231c703d6cab7eeb4e9a40c1347b95bdbf4606.diff

LOG: [MLIR] NFC clean up loop tiling test cases

Summary:
Improve the checks and drop redundant ones. Rename the outlined maps
better.

Reviewers: andydavis1, nicolasvasilache

Subscribers: mehdi_amini, rriddle, jpienaar, shauheen, antiagainst, nicolasvasilache, arpith-jacob, mgester, lucyrfox, aartbik, liufengdb, Joonsoo, grosul1, frgossen, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D78514

Added: 
    

Modified: 
    mlir/test/Dialect/Affine/loop-tiling.mlir

Removed: 
    


################################################################################
diff  --git a/mlir/test/Dialect/Affine/loop-tiling.mlir b/mlir/test/Dialect/Affine/loop-tiling.mlir
index 380e82c3a326..1aee50f15839 100644
--- a/mlir/test/Dialect/Affine/loop-tiling.mlir
+++ b/mlir/test/Dialect/Affine/loop-tiling.mlir
@@ -1,11 +1,11 @@
-// RUN: mlir-opt -allow-unregistered-dialect %s -split-input-file -affine-loop-tile="tile-size=32" | FileCheck %s
-// RUN: mlir-opt -allow-unregistered-dialect %s -split-input-file -affine-loop-tile="cache-size=512" | FileCheck %s --check-prefix=MODEL
-// RUN: mlir-opt -allow-unregistered-dialect %s -split-input-file -affine-loop-tile="tile-size=32 separate" | FileCheck %s --check-prefix=SEPARATE
+// RUN: mlir-opt %s -split-input-file -affine-loop-tile="tile-size=32" | FileCheck %s
+// RUN: mlir-opt %s -split-input-file -affine-loop-tile="cache-size=512" | FileCheck %s --check-prefix=MODEL
+// RUN: mlir-opt %s -split-input-file -affine-loop-tile="tile-size=32 separate" | FileCheck %s --check-prefix=SEPARATE
 
 // -----
 
-// 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: [[UB:#map[0-9]+]] = affine_map<(d0) -> (d0 + 32)>
+// CHECK-DAG: [[UB_MIN:#map[0-9]+]] = affine_map<(d0) -> (d0 + 32, 50)>
 // CHECK-DAG: [[ID:#map[0-9]+]] = affine_map<(d0) -> (d0)>
 // CHECK-DAG: [[ID_PLUS_21:#map[0-9]+]] = affine_map<(d0) -> (d0 + 21)>
 
@@ -13,10 +13,10 @@
 // CHECK-NEXT:   affine.for %{{.*}} = 0 to 256 step 32 {
 // CHECK-NEXT:     affine.for %{{.*}} = 0 to 512 step 32 {
 // CHECK-NEXT:       affine.for %{{.*}} = 0 to 1024 step 32 {
-// CHECK-NEXT:         affine.for %{{.*}} = [[ID]](%{{.*}}) to [[MAP0]](%{{.*}}) {
-// CHECK-NEXT:           affine.for %{{.*}} = [[ID]](%{{.*}}) to [[MAP0]](%{{.*}}) {
-// CHECK-NEXT:             affine.for %{{.*}} = [[ID]](%{{.*}}) to [[MAP0]](%{{.*}}) {
-// CHECK-NEXT:               "foo"(%{{.*}}, %{{.*}}, %{{.*}}) : (index, index, index) -> ()
+// CHECK-NEXT:         affine.for %[[I:.*]] = [[ID]](%{{.*}}) to [[UB]](%{{.*}}) {
+// CHECK-NEXT:           affine.for %[[J:.*]] = [[ID]](%{{.*}}) to [[UB]](%{{.*}}) {
+// CHECK-NEXT:             affine.for %[[K:.*]] = [[ID]](%{{.*}}) to [[UB]](%{{.*}}) {
+// CHECK-NEXT:               "test.foo"(%[[I]], %[[J]], %[[K]])
 // CHECK-NEXT:             }
 // CHECK-NEXT:           }
 // CHECK-NEXT:         }
@@ -24,32 +24,32 @@
 // CHECK-NEXT:     }
 // CHECK-NEXT:   }
 // CHECK-NEXT:   affine.for %{{.*}} = 0 to 50 step 32 {
-// CHECK-NEXT:     affine.for %{{.*}} = [[ID]](%{{.*}}) to min [[MAP1]](%{{.*}}) {
-// CHECK-NEXT:       "bar"(%{{.*}}, %{{.*}}) : (index, index) -> ()
+// CHECK-NEXT:     affine.for %[[X:.*]] = [[ID]](%{{.*}}) to min [[UB_MIN]](%{{.*}}) {
+// CHECK-NEXT:       "test.bar"(%[[X]], %[[X]])
 // CHECK-NEXT:     }
 // CHECK-NEXT:   }
 // CHECK-NEXT: affine.for %[[I:.*]] = 0 to 21 step 32 {
-// CHECK-NEXT:    affine.for %{{.*}} = [[ID]](%[[I]]) to [[ID_PLUS_21]](%[[I]]) {
-// CHECK-NEXT:      "foobar"(%{{.*}}) : (index) -> ()
-// CHECK-NEXT:    }
-// CHECK-NEXT:  }
+// CHECK-NEXT:   affine.for %[[Y:.*]] = [[ID]](%[[I]]) to [[ID_PLUS_21]](%[[I]])  {
+// CHECK-NEXT:     "test.foobar"(%[[Y]])
+// CHECK-NEXT:   }
+// CHECK-NEXT: }
 // CHECK-NEXT:  return
 func @loop_tiling() {
   affine.for %i = 0 to 256 {
     affine.for %j = 0 to 512 {
       affine.for %k = 0 to 1024 {
-        "foo"(%i, %j, %k) : (index, index, index) -> ()
+        "test.foo"(%i, %j, %k) : (index, index, index) -> ()
       }
     }
   }
 
   affine.for %x = 0 to 50 {
-    "bar"(%x, %x) : (index, index) -> ()
+    "test.bar"(%x, %x) : (index, index) -> ()
   }
 
   // Intra-tile loop won't need a min expression.
   affine.for %y = 0 to 21 {
-    "foobar"(%y) : (index) -> ()
+    "test.foobar"(%y) : (index) -> ()
   }
 
   return
@@ -67,13 +67,13 @@ func @loop_tiling() {
 // 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 affine_map<(d0) -> (d0)> (%iTT)
+  affine.for %i = max #lb()[%L] to min #ub()[%M, %U] {
+    addi %i, %i : index
   }
   return
 // CHECK:       affine.for %{{.*}} = max [[LB]]()[%{{.*}}] to min [[UB]]()[%{{.*}}, %{{.*}}] step 32 {
-// CHECK-NEXT:    affine.for %{{.*}} = [[IDENTITY]](%{{.*}}) to min [[UB_INTRA_TILE]](%{{.*}})[%{{.*}}, %{{.*}}] {
-// CHECK-NEXT:      %{{.*}} = affine.apply [[IDENTITY]](%{{.*}})
+// CHECK-NEXT:    affine.for %[[I:.*]] = [[IDENTITY]](%{{.*}}) to min [[UB_INTRA_TILE]](%{{.*}})[%{{.*}}, %{{.*}}] {
+// CHECK-NEXT:      addi %[[I]], %[[I]]
 // CHECK-NEXT:    }
 // CHECK-NEXT:  }
 }
@@ -128,19 +128,19 @@ func @tile_with_symbolic_loop_upper_bounds(%arg0: memref<?x?xf32>, %arg1: memref
   return
 }
 
-// CHECK:       %{{.*}} = dim %{{.*}}, 0 : memref<?x?xf32>
+// CHECK:       dim %{{.*}}, 0 : memref<?x?xf32>
 // CHECK-NEXT:  affine.for %{{.*}} = 0 to %{{.*}} step 32 {
 // CHECK-NEXT:    affine.for %{{.*}} = 0 to %{{.*}} step 32 {
 // CHECK-NEXT:      affine.for %{{.*}} = #map3(%{{.*}}) to min [[UBMAP]](%{{.*}})[%{{.*}}] {
 // CHECK-NEXT:        affine.for %{{.*}} = #map3(%{{.*}}) to min [[UBMAP]](%{{.*}})[%{{.*}}] {
 // CHECK-NEXT:          affine.store %{{.*}}, %{{.*}}[%{{.*}}, %{{.*}}] : memref<?x?xf32>
 // CHECK-NEXT:          affine.for %{{.*}} = 0 to %{{.*}} {
-// CHECK-NEXT:            %{{.*}} = affine.load %{{.*}}[%{{.*}}, %{{.*}}] : memref<?x?xf32>
-// CHECK-NEXT:            %{{.*}} = affine.load %{{.*}}[%{{.*}}, %{{.*}}] : memref<?x?xf32>
-// CHECK-NEXT:            %{{.*}} = mulf %{{.*}}, %{{.*}} : f32
-// CHECK-NEXT:            %{{.*}} = affine.load %{{.*}}[%{{.*}}, %{{.*}}] : memref<?x?xf32>
-// CHECK-NEXT:            %{{.*}} = addf %{{.*}}, %{{.*}} : f32
-// CHECK-NEXT:            affine.store %{{.*}}, %{{.*}}[%{{.*}}, %{{.*}}] : memref<?x?xf32>
+// CHECK-NEXT:            affine.load
+// CHECK-NEXT:            affine.load
+// CHECK-NEXT:            mulf
+// CHECK-NEXT:            affine.load
+// CHECK-NEXT:            addf
+// CHECK-NEXT:            affine.store
 // CHECK-NEXT:          }
 // CHECK-NEXT:        }
 // CHECK-NEXT:      }
@@ -162,10 +162,10 @@ func @tile_with_loop_upper_bounds_in_two_symbols(%arg0: memref<?xf32>, %limit: i
   return
 }
 
-// CHECK:       %{{.*}} = dim %{{.*}}, 0 : memref<?xf32>
+// CHECK:       dim %{{.*}}, 0 : memref<?xf32>
 // CHECK-NEXT:  affine.for %{{.*}} = 0 to [[MAP1]]()[%{{.*}}, %{{.*}}] step 32 {
 // CHECK-NEXT:    affine.for %{{.*}} = [[MAP0]](%{{.*}}) to min [[UBMAP]](%{{.*}})[%{{.*}}, %{{.*}}] {
-// CHECK-NEXT:      %{{.*}} = affine.load %{{.*}}[%{{.*}}] : memref<?xf32>
+// CHECK-NEXT:      affine.load
 // CHECK-NEXT:    }
 // CHECK-NEXT:  }
 
@@ -192,9 +192,9 @@ func @tile_size_larger_than_trip_count_symbolic_bound(%M: index, %N :  index) {
 
 // -----
 
-// CHECK-LABEL: func @trip_count_1
-// SEPARATE-LABEL: func @trip_count_1
-func @trip_count_1(%arg0: memref<196608x1xf32>, %arg1: memref<196608x1xf32>)
+// CHECK-LABEL: func @trip_count_one
+// SEPARATE-LABEL: func @trip_count_one
+func @trip_count_one(%arg0: memref<196608x1xf32>, %arg1: memref<196608x1xf32>)
     -> memref<196608x1xf32> {
   affine.for %i1 = 0 to 196608 {
     affine.for %i3 = 0 to 1 {
@@ -205,14 +205,15 @@ func @trip_count_1(%arg0: memref<196608x1xf32>, %arg1: memref<196608x1xf32>)
   // CHECK: affine.load %{{.*}}[%{{.*}}, %{{.*}}] : memref<196608x1xf32>
   return %arg1 : memref<196608x1xf32>
 }
+// To make sure SEPRATE-DAGs further below do not match with something above.
 // SEPARATE: return
 
 // -----
 
 func @separate_full_tile_2d(%M : index, %N : index) {
-  affine.for %i0 = 0 to %M {
-    affine.for %i1 = 0 to %N {
-      "foo"() : () -> ()
+  affine.for %i = 0 to %M {
+    affine.for %j = 0 to %N {
+      "test.foo"() : () -> ()
     }
   }
   return
@@ -223,18 +224,21 @@ func @separate_full_tile_2d(%M : index, %N : index) {
 // SEPARATE-DAG: #[[FULL_TILE_UB:.*]] = affine_map<(d0) -> (d0 + 32)>
 // SEPARATE-DAG: #[[PART_TILE_UB:.*]] = affine_map<(d0)[s0] -> (d0 + 32, s0)>
 
-// SEPARATE:       affine.for %arg2
-// SEPARATE-NEXT:    affine.for %arg3
+// SEPARATE-LABEL: func @separate_full_tile_2d(
+// SEPARATE: %[[M:.*]]: index, %[[N:.*]]: index
+
+// SEPARATE:       affine.for %[[I:.*]] =
+// SEPARATE-NEXT:    affine.for %[[J:.*]] =
 // SEPARATE-NEXT:      affine.if #[[SEP_COND]](%arg2, %arg3)[%arg0, %arg1] {
-// SEPARATE-NEXT:        affine.for %arg4 = #[[LB]](%arg2) to #[[FULL_TILE_UB]](%arg2) {
-// SEPARATE-NEXT:          affine.for %arg5 = #[[LB]](%arg3) to #[[FULL_TILE_UB]](%arg3) {
-// SEPARATE-NEXT:           "foo"
+// SEPARATE-NEXT:        affine.for %{{.*}} = #[[LB]](%[[I]]) to #[[FULL_TILE_UB]](%[[I]]) {
+// SEPARATE-NEXT:          affine.for %{{.*}} = #[[LB]](%[[J]]) to #[[FULL_TILE_UB]](%[[J]]) {
+// SEPARATE-NEXT:           "test.foo"
 // SEPARATE-NEXT:          }
 // SEPARATE-NEXT:        }
 // SEPARATE-NEXT:      } else {
-// SEPARATE-NEXT:        affine.for %arg4 = #[[LB]](%arg2) to min #[[PART_TILE_UB]](%arg2)[%arg0] {
-// SEPARATE-NEXT:          affine.for %arg5 = #[[LB]](%arg3) to min #[[PART_TILE_UB]](%arg3)[%arg1] {
-// SEPARATE-NEXT:           "foo"
+// SEPARATE-NEXT:        affine.for %{{.*}} = #[[LB]](%[[I]]) to min #[[PART_TILE_UB]](%[[I]])[%[[M]]] {
+// SEPARATE-NEXT:          affine.for %{{.*}} = #[[LB]](%[[J]]) to min #[[PART_TILE_UB]](%[[J]])[%[[N]]] {
+// SEPARATE-NEXT:           "test.foo"
 // SEPARATE-NEXT:          }
 // SEPARATE-NEXT:        }
 // SEPARATE-NEXT:      }


        


More information about the Mlir-commits mailing list