1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157
|
// RUN: mlir-opt -test-generic-ir-visitors-interrupt -allow-unregistered-dialect -split-input-file %s | FileCheck %s
// Walk is interrupted before visiting "foo"
func.func @main(%arg0: f32) -> f32 {
%v1 = "foo"() {interrupt_before_all = true} : () -> f32
%v2 = arith.addf %v1, %arg0 : f32
return %v2 : f32
}
// CHECK: step 0 op 'builtin.module' before all regions
// CHECK: step 1 op 'func.func' before all regions
// CHECK: step 2 walk was interrupted
// -----
// Walk is interrupted after visiting "foo" (which has a single empty region)
func.func @main(%arg0: f32) -> f32 {
%v1 = "foo"() ({ "bar"() : ()-> () }) {interrupt_after_all = true} : () -> f32
%v2 = arith.addf %v1, %arg0 : f32
return %v2 : f32
}
// CHECK: step 0 op 'builtin.module' before all regions
// CHECK: step 1 op 'func.func' before all regions
// CHECK: step 2 op 'foo' before all regions
// CHECK: step 3 op 'bar' before all regions
// CHECK: step 4 walk was interrupted
// -----
// Walk is interrupted after visiting "foo"'s 1st region.
func.func @main(%arg0: f32) -> f32 {
%v1 = "foo"() ({
"bar0"() : () -> ()
}, {
"bar1"() : () -> ()
}) {interrupt_after_region = 0} : () -> f32
%v2 = arith.addf %v1, %arg0 : f32
return %v2 : f32
}
// CHECK: step 0 op 'builtin.module' before all regions
// CHECK: step 1 op 'func.func' before all regions
// CHECK: step 2 op 'foo' before all regions
// CHECK: step 3 op 'bar0' before all regions
// CHECK: step 4 walk was interrupted
// -----
// Test static filtering.
func.func @main() {
"foo"() : () -> ()
"test.two_region_op"()(
{"work"() : () -> ()},
{"work"() : () -> ()}
) {interrupt_after_all = true} : () -> ()
return
}
// CHECK: step 0 op 'builtin.module' before all regions
// CHECK: step 1 op 'func.func' before all regions
// CHECK: step 2 op 'foo' before all regions
// CHECK: step 3 op 'test.two_region_op' before all regions
// CHECK: step 4 op 'work' before all regions
// CHECK: step 5 op 'test.two_region_op' before region #1
// CHECK: step 6 op 'work' before all regions
// CHECK: step 7 walk was interrupted
// CHECK: step 8 op 'test.two_region_op' before all regions
// CHECK: step 9 op 'test.two_region_op' before region #1
// CHECK: step 10 walk was interrupted
// -----
// Test static filtering.
func.func @main() {
"foo"() : () -> ()
"test.two_region_op"()(
{"work"() : () -> ()},
{"work"() : () -> ()}
) {interrupt_after_region = 0} : () -> ()
return
}
// CHECK: step 0 op 'builtin.module' before all regions
// CHECK: step 1 op 'func.func' before all regions
// CHECK: step 2 op 'foo' before all regions
// CHECK: step 3 op 'test.two_region_op' before all regions
// CHECK: step 4 op 'work' before all regions
// CHECK: step 5 walk was interrupted
// CHECK: step 6 op 'test.two_region_op' before all regions
// CHECK: step 7 walk was interrupted
// -----
// Test skipping.
// Walk is skipped before visiting "foo".
func.func @main(%arg0: f32) -> f32 {
%v1 = "foo"() ({
"bar0"() : () -> ()
}, {
"bar1"() : () -> ()
}) {skip_before_all = true} : () -> f32
%v2 = arith.addf %v1, %arg0 : f32
return %v2 : f32
}
// CHECK: step 0 op 'builtin.module' before all regions
// CHECK: step 1 op 'func.func' before all regions
// CHECK: step 2 op 'arith.addf' before all regions
// CHECK: step 3 op 'func.return' before all regions
// CHECK: step 4 op 'func.func' after all regions
// CHECK: step 5 op 'builtin.module' after all regions
// -----
// Walk is skipped after visiting all regions of "foo".
func.func @main(%arg0: f32) -> f32 {
%v1 = "foo"() ({
"bar0"() : () -> ()
}, {
"bar1"() : () -> ()
}) {skip_after_all = true} : () -> f32
%v2 = arith.addf %v1, %arg0 : f32
return %v2 : f32
}
// CHECK: step 0 op 'builtin.module' before all regions
// CHECK: step 1 op 'func.func' before all regions
// CHECK: step 2 op 'foo' before all regions
// CHECK: step 3 op 'bar0' before all regions
// CHECK: step 4 op 'foo' before region #1
// CHECK: step 5 op 'bar1' before all regions
// CHECK: step 6 op 'arith.addf' before all regions
// CHECK: step 7 op 'func.return' before all regions
// CHECK: step 8 op 'func.func' after all regions
// CHECK: step 9 op 'builtin.module' after all regions
// -----
// Walk is skipped after visiting first region of "foo".
func.func @main(%arg0: f32) -> f32 {
%v1 = "foo"() ({
"bar0"() : () -> ()
}, {
"bar1"() : () -> ()
}) {skip_after_region = 0} : () -> f32
%v2 = arith.addf %v1, %arg0 : f32
return %v2 : f32
}
// CHECK: step 0 op 'builtin.module' before all regions
// CHECK: step 1 op 'func.func' before all regions
// CHECK: step 2 op 'foo' before all regions
// CHECK: step 3 op 'bar0' before all regions
// CHECK: step 4 op 'arith.addf' before all regions
// CHECK: step 5 op 'func.return' before all regions
// CHECK: step 6 op 'func.func' after all regions
// CHECK: step 7 op 'builtin.module' after all regions
|