1+ # RUN: %PYTHON %s | FileCheck %s
2+
13# Simply demonstrates applying a schedule to a payload.
24# To do so generates a basic payload and a basic schedule, purely as an example.
35
@@ -24,16 +26,23 @@ def example_payload() -> Module:
2426 with InsertionPoint (payload .body ):
2527 matrixType = RankedTensorType .get ([16 , 16 ], F32Type .get ())
2628
29+ # NB: Do the CHECKing on the transformed output:
30+ # CHECK-LABEL: result of applying schedule to payload
31+ # CHECK: func.func @fold_add_on_two_matmuls
32+ # CHECK-SAME: (%[[MATRIX_A:.*]]: {{.*}}, %[[MATRIX_B:.*]]: {{.*}}, %[[WEIGHTS:.*]]: {{.*}})
2733 @func .func (matrixType , matrixType , matrixType )
2834 def fold_add_on_two_matmuls (matrixA , matrixB , weights ):
2935 empty = tensor .empty (matrixType .shape , matrixType .element_type )
3036 c0 = arith .constant (F32Type .get (), 0.0 )
37+ # CHECK: %[[ZERO_INIT:.*]] = linalg.fill
3138 zero_init = linalg .fill (c0 , outs = [empty ])
39+ # CHECK: %[[A_X_WEIGHTS:.*]] = linalg.matmul ins(%[[MATRIX_A]], %[[WEIGHTS]]{{.*}}) outs(%[[ZERO_INIT]]
3240 A_x_weights = linalg .matmul (matrixA , weights , outs = [zero_init ])
33- empty2 = tensor . empty ( matrixType . shape , matrixType . element_type )
34- zero_init2 = linalg .fill ( c0 , outs = [empty2 ])
35- B_x_weights = linalg .matmul ( matrixB , weights , outs = [ zero_init2 ])
41+ # CHECK: %[[RES:.*]] = linalg.matmul ins(%[[MATRIX_B]], %[[WEIGHTS]]{{.*}}) outs(%[[A_X_WEIGHTS]]
42+ B_x_weights = linalg .matmul ( matrixB , weights , outs = [zero_init ])
43+ # CHECK-NOT: linalg.add
3644 added = linalg .add (A_x_weights , B_x_weights , outs = [empty ])
45+ # CHECK: return %[[RES]]
3746 return added
3847
3948 print (payload )
0 commit comments