173
|
1 // RUN: mlir-linalg-ods-gen %s -gen-ods-decl=1 | FileCheck %s --check-prefix=ODS
|
|
2 // RUN: mlir-linalg-ods-gen %s -gen-impl=1 | FileCheck %s --check-prefix=IMPL
|
|
3
|
|
4 // ODS-LABEL: def Test1Op : LinalgNamedStructured_Op<"test1", [
|
|
5 // ODS-NEXT: NInputs<2>
|
|
6 // ODS-NEXT: NOutputs<1>
|
|
7 // ODS-NEXT: NamedStructuredOpTraits
|
|
8 // ODS-NEXT: SingleBlockImplicitTerminator<"YieldOp">
|
|
9 //
|
|
10 // IMPL-LABEL: SmallVector<StringRef, 8> Test1Op::referenceIterators
|
|
11 // IMPL: { {{.*}}Parallel{{.*}}, {{.*}}Reduction{{.*}} }
|
|
12 //
|
|
13 // IMPL: SmallVector<AffineMap, 8> Test1Op::referenceIndexingMaps
|
|
14 // IMPL: AffineMap::get(2, 0, {d0, d1}, context),
|
|
15 // IMPL-NEXT: AffineMap::get(2, 0, {d1}, context),
|
|
16 // IMPL-NEXT: AffineMap::get(2, 0, {d0}, context) };
|
|
17 //
|
|
18 // IMPL: void Test1Op::regionBuilder(Block &block) {
|
|
19 // IMPL: Value [[a:.*]](args[0]), [[b:.*]](args[1]), [[c:.*]](args[2]);
|
|
20 // IMPL: Value [[d:.*]] = std_mulf([[a]], [[b]]);
|
|
21 // IMPL: Value [[e:.*]] = std_addf([[c]], [[d]]);
|
|
22 // IMPL: (linalg_yield(ValueRange{ [[e]] }));
|
|
23 //
|
|
24 ods_def<Test1Op> :
|
|
25 def test1(A: f32(M, K), B: f32(K)) -> (C: f32(M)) {
|
|
26 C(m) = std_addf<k>(std_mulf(A(m, k), B(k)));
|
|
27 }
|
|
28
|
|
29 // ODS-LABEL: def Test2Op : LinalgNamedStructured_Op<"test2", [
|
|
30 // ODS-NEXT: NInputs<2>
|
|
31 // ODS-NEXT: NOutputs<1>
|
|
32 // ODS-NEXT: NamedStructuredOpTraits
|
|
33 // ODS-NEXT: SingleBlockImplicitTerminator<"YieldOp">
|
|
34 //
|
|
35 // IMPL-LABEL: SmallVector<StringRef, 8> Test2Op::referenceIterators
|
|
36 // IMPL: { {{.*}}Parallel{{.*}}, {{.*}}Parallel{{.*}}, {{.*}}Reduction{{.*}} }
|
|
37 //
|
|
38 // IMPL: SmallVector<AffineMap, 8> Test2Op::referenceIndexingMaps
|
|
39 // IMPL: AffineMap::get(3, 0, {d0, d2}, context),
|
|
40 // IMPL-NEXT: AffineMap::get(3, 0, {d2, d1}, context),
|
|
41 // IMPL-NEXT: AffineMap::get(3, 0, {d0, d1}, context) };
|
|
42 //
|
|
43 // IMPL: Test2Op::regionBuilder(Block &block) {
|
|
44 // IMPL: Value [[a:.*]](args[0]), [[b:.*]](args[1]), [[c:.*]](args[2]);
|
|
45 // IMPL: Value [[d:.*]] = std_mulf([[a]], [[b]]);
|
|
46 // IMPL: Value [[e:.*]] = std_addf([[c]], [[d]]);
|
|
47 // IMPL: (linalg_yield(ValueRange{ [[e]] }));
|
|
48 //
|
|
49 ods_def<Test2Op> :
|
|
50 def test2(A: f32(M, K), B: f32(K, N)) -> (C: f32(M, N)) {
|
|
51 C(m, n) = std_addf<k>(std_mulf(A(m, k), B(k, n)));
|
|
52 }
|
|
53
|
|
54 // ODS-LABEL: def Test3Op : LinalgNamedStructured_Op<"test3", [
|
|
55 // ODS-NEXT: NInputs<2>
|
|
56 // ODS-NEXT: NOutputs<1>
|
|
57 // ODS-NEXT: NamedStructuredOpTraits
|
|
58 // ODS-NEXT: SingleBlockImplicitTerminator<"YieldOp">
|
|
59 //
|
|
60 // IMPL-LABEL: SmallVector<StringRef, 8> Test3Op::referenceIterators
|
|
61 // IMPL: { {{.*}}Parallel{{.*}}, {{.*}}Parallel{{.*}}, {{.*}}Reduction{{.*}} }
|
|
62 //
|
|
63 // IMPL: SmallVector<AffineMap, 8> Test3Op::referenceIndexingMaps
|
|
64 // IMPL: AffineMap::get(4, 0, {d0, d1, d3}, context),
|
|
65 // IMPL-NEXT: AffineMap::get(4, 0, {d3, d2}, context),
|
|
66 // IMPL-NEXT: AffineMap::get(4, 0, {d0, d1, d2}, context) };
|
|
67 //
|
|
68 // IMPL: Test3Op::regionBuilder(Block &block) {
|
|
69 // IMPL: Value [[a:.*]](args[0]), [[b:.*]](args[1]), [[c:.*]](args[2]);
|
|
70 // IMPL: Value [[d:.*]] = std_mulf([[a]], [[b]]);
|
|
71 // IMPL: Value [[e:.*]] = std_addf([[c]], [[d]]);
|
|
72 // IMPL: (linalg_yield(ValueRange{ [[e]] }));
|
|
73 //
|
|
74 ods_def<Test3Op> :
|
|
75 def test3(A: f32(Batch, M, K), B: f32(K, N)) -> (C: f32(Batch, M, N)) {
|
|
76 C(b, m, n) = std_addf<k>(std_mulf(A(b, m, k), B(k, n)));
|
|
77 }
|