1
- // RUN: mlir-opt -mlir-print-debuginfo -canonicalize="test-convergence" %s | FileCheck %s
1
+ // RUN: mlir-opt -split-input-file - mlir-print-debuginfo -canonicalize="test-convergence" %s | FileCheck %s
2
2
3
3
// CHECK-LABEL: @clamp_twice_is_single_clamp
4
4
func.func @clamp_twice_is_single_clamp (%arg0: tensor <4 xi8 >) -> tensor <4 xi8 > {
@@ -11,4 +11,36 @@ func.func @clamp_twice_is_single_clamp(%arg0: tensor<4xi8>) -> tensor<4xi8> {
11
11
return %1 : tensor <4 xi8 >
12
12
}
13
13
#loc0 = loc (" Clamp_A" )
14
- #loc1 = loc (" Clamp_B" )
14
+ #loc1 = loc (" Clamp_B" )
15
+
16
+ // -----
17
+
18
+ // CHECK-LABEL: @canonicalize_optimize_sqrt_reciprocal
19
+ func.func @canonicalize_optimize_sqrt_reciprocal_with_debinfo (%arg0: tensor <1 x5 x1 x1 xf32 >) -> tensor <1 x5 x1 x1 xf32 > {
20
+ // CHECK: %[[RSQRT:.*]] = tosa.rsqrt %arg{{.*}} : (tensor<1x5x1x1xf32>) -> tensor<1x5x1x1xf32> loc([[LOC:.*]])
21
+ // CHECK-DAG: #[[A:.*]] = loc("Pow_A")
22
+ // CHECK-DAG: #[[B:.*]] = loc("Reciprocal_B")
23
+ // CHECK-DAG: [[LOC]] = loc(fused[#[[A]], #[[B]]])
24
+ %0 = " tosa.const" () <{value = dense <5.000000e-01 > : tensor <1 x1 x1 x1 xf32 >}> : () -> tensor <1 x1 x1 x1 xf32 >
25
+ %1 = tosa.pow %arg0 , %0 : (tensor <1 x5 x1 x1 xf32 >, tensor <1 x1 x1 x1 xf32 >) -> tensor <1 x5 x1 x1 xf32 > loc (#loc0 )
26
+ %2 = tosa.reciprocal %1 : (tensor <1 x5 x1 x1 xf32 >) -> tensor <1 x5 x1 x1 xf32 > loc (#loc1 )
27
+ return %2 : tensor <1 x5 x1 x1 xf32 >
28
+ }
29
+ #loc0 = loc (" Pow_A" )
30
+ #loc1 = loc (" Reciprocal_B" )
31
+
32
+ // -----
33
+
34
+ // CHECK-LABEL: @canonicalize_optimize_sqrt_reciprocal
35
+ func.func @canonicalize_optimize_sqrt_reciprocal_bf16 (%arg0: tensor <1 x5 x1 x1 xbf16 >) -> tensor <1 x5 x1 x1 xbf16 > {
36
+ // CHECK: %[[RSQRT:.*]] = tosa.rsqrt %arg{{.*}} : (tensor<1x5x1x1xbf16>) -> tensor<1x5x1x1xbf16> loc([[LOC:.*]])
37
+ // CHECK-DAG: #[[A:.*]] = loc("Pow_B")
38
+ // CHECK-DAG: #[[B:.*]] = loc("Reciprocal_C")
39
+ // CHECK-DAG: [[LOC]] = loc(fused[#[[A]], #[[B]]])
40
+ %0 = " tosa.const" () <{value = dense <5.000000e-01 > : tensor <1 x1 x1 x1 xbf16 >}> : () -> tensor <1 x1 x1 x1 xbf16 >
41
+ %1 = tosa.pow %arg0 , %0 : (tensor <1 x5 x1 x1 xbf16 >, tensor <1 x1 x1 x1 xbf16 >) -> tensor <1 x5 x1 x1 xbf16 > loc (#loc0 )
42
+ %2 = tosa.reciprocal %1 : (tensor <1 x5 x1 x1 xbf16 >) -> tensor <1 x5 x1 x1 xbf16 > loc (#loc1 )
43
+ return %2 : tensor <1 x5 x1 x1 xbf16 >
44
+ }
45
+ #loc0 = loc (" Pow_B" )
46
+ #loc1 = loc (" Reciprocal_C" )
0 commit comments