forked from OSchip/llvm-project
78 lines
3.3 KiB
Plaintext
78 lines
3.3 KiB
Plaintext
// RUN: mlir-linalg-ods-gen %s -gen-ods-decl=1 | FileCheck %s --check-prefix=ODS
|
|
// RUN: mlir-linalg-ods-gen %s -gen-impl=1 | FileCheck %s --check-prefix=IMPL
|
|
|
|
// ODS-LABEL: def Test1Op : LinalgNamedStructured_Op<"test1", [
|
|
// ODS-NEXT: NInputs<2>
|
|
// ODS-NEXT: NOutputs<1>
|
|
// ODS-NEXT: NamedStructuredOpTraits
|
|
// ODS-NEXT: SingleBlockImplicitTerminator<"YieldOp">
|
|
//
|
|
// IMPL-LABEL: SmallVector<StringRef, 8> Test1Op::referenceIterators
|
|
// IMPL: { {{.*}}Parallel{{.*}}, {{.*}}Reduction{{.*}} }
|
|
//
|
|
// IMPL: SmallVector<AffineMap, 8> Test1Op::referenceIndexingMaps
|
|
// IMPL: AffineMap::get(2, 0, {d0, d1}, context),
|
|
// IMPL-NEXT: AffineMap::get(2, 0, {d1}, context),
|
|
// IMPL-NEXT: AffineMap::get(2, 0, {d0}, context) };
|
|
//
|
|
// IMPL: void Test1Op::regionBuilder(Block &block) {
|
|
// IMPL: Value [[a:.*]](args[0]), [[b:.*]](args[1]), [[c:.*]](args[2]);
|
|
// IMPL: Value [[d:.*]] = std_mulf([[a]], [[b]]);
|
|
// IMPL: Value [[e:.*]] = std_addf([[c]], [[d]]);
|
|
// IMPL: (linalg_yield(ValueRange{ [[e]] }));
|
|
//
|
|
ods_def<Test1Op> :
|
|
def test1(A: f32(M, K), B: f32(K)) -> (C: f32(M)) {
|
|
C(m) = std_addf<k>(std_mulf(A(m, k), B(k)));
|
|
}
|
|
|
|
// ODS-LABEL: def Test2Op : LinalgNamedStructured_Op<"test2", [
|
|
// ODS-NEXT: NInputs<2>
|
|
// ODS-NEXT: NOutputs<1>
|
|
// ODS-NEXT: NamedStructuredOpTraits
|
|
// ODS-NEXT: SingleBlockImplicitTerminator<"YieldOp">
|
|
//
|
|
// IMPL-LABEL: SmallVector<StringRef, 8> Test2Op::referenceIterators
|
|
// IMPL: { {{.*}}Parallel{{.*}}, {{.*}}Parallel{{.*}}, {{.*}}Reduction{{.*}} }
|
|
//
|
|
// IMPL: SmallVector<AffineMap, 8> Test2Op::referenceIndexingMaps
|
|
// IMPL: AffineMap::get(3, 0, {d0, d2}, context),
|
|
// IMPL-NEXT: AffineMap::get(3, 0, {d2, d1}, context),
|
|
// IMPL-NEXT: AffineMap::get(3, 0, {d0, d1}, context) };
|
|
//
|
|
// IMPL: Test2Op::regionBuilder(Block &block) {
|
|
// IMPL: Value [[a:.*]](args[0]), [[b:.*]](args[1]), [[c:.*]](args[2]);
|
|
// IMPL: Value [[d:.*]] = std_mulf([[a]], [[b]]);
|
|
// IMPL: Value [[e:.*]] = std_addf([[c]], [[d]]);
|
|
// IMPL: (linalg_yield(ValueRange{ [[e]] }));
|
|
//
|
|
ods_def<Test2Op> :
|
|
def test2(A: f32(M, K), B: f32(K, N)) -> (C: f32(M, N)) {
|
|
C(m, n) = std_addf<k>(std_mulf(A(m, k), B(k, n)));
|
|
}
|
|
|
|
// ODS-LABEL: def Test3Op : LinalgNamedStructured_Op<"test3", [
|
|
// ODS-NEXT: NInputs<2>
|
|
// ODS-NEXT: NOutputs<1>
|
|
// ODS-NEXT: NamedStructuredOpTraits
|
|
// ODS-NEXT: SingleBlockImplicitTerminator<"YieldOp">
|
|
//
|
|
// IMPL-LABEL: SmallVector<StringRef, 8> Test3Op::referenceIterators
|
|
// IMPL: { {{.*}}Parallel{{.*}}, {{.*}}Parallel{{.*}}, {{.*}}Reduction{{.*}} }
|
|
//
|
|
// IMPL: SmallVector<AffineMap, 8> Test3Op::referenceIndexingMaps
|
|
// IMPL: AffineMap::get(4, 0, {d0, d1, d3}, context),
|
|
// IMPL-NEXT: AffineMap::get(4, 0, {d3, d2}, context),
|
|
// IMPL-NEXT: AffineMap::get(4, 0, {d0, d1, d2}, context) };
|
|
//
|
|
// IMPL: Test3Op::regionBuilder(Block &block) {
|
|
// IMPL: Value [[a:.*]](args[0]), [[b:.*]](args[1]), [[c:.*]](args[2]);
|
|
// IMPL: Value [[d:.*]] = std_mulf([[a]], [[b]]);
|
|
// IMPL: Value [[e:.*]] = std_addf([[c]], [[d]]);
|
|
// IMPL: (linalg_yield(ValueRange{ [[e]] }));
|
|
//
|
|
ods_def<Test3Op> :
|
|
def test3(A: f32(Batch, M, K), B: f32(K, N)) -> (C: f32(Batch, M, N)) {
|
|
C(b, m, n) = std_addf<k>(std_mulf(A(b, m, k), B(k, n)));
|
|
}
|