forked from OSchip/llvm-project
75 lines
3.1 KiB
Plaintext
75 lines
3.1 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 : LinalgStructuredBase_Op<"test1", [
|
|
// ODS-NEXT: NamedStructuredOpTrait
|
|
// ODS-NEXT: AttrSizedOperandSegments
|
|
// ODS-NEXT: SingleBlockImplicitTerminator<"YieldOp">
|
|
//
|
|
// IMPL-LABEL: ArrayAttr Test1Op::iterator_types() {
|
|
// IMPL: { {{.*}}Parallel{{.*}}, {{.*}}Reduction{{.*}} }
|
|
//
|
|
// IMPL: ArrayAttr Test1Op::indexing_maps() {
|
|
// 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 : LinalgStructuredBase_Op<"test2", [
|
|
// ODS-NEXT: NamedStructuredOpTrait
|
|
// ODS-NEXT: AttrSizedOperandSegments
|
|
// ODS-NEXT: SingleBlockImplicitTerminator<"YieldOp">
|
|
//
|
|
// IMPL-LABEL: ArrayAttr Test2Op::iterator_types() {
|
|
// IMPL: { {{.*}}Parallel{{.*}}, {{.*}}Parallel{{.*}}, {{.*}}Reduction{{.*}} }
|
|
//
|
|
// IMPL: ArrayAttr Test2Op::indexing_maps() {
|
|
// 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 : LinalgStructuredBase_Op<"test3", [
|
|
// ODS-NEXT: NamedStructuredOpTrait
|
|
// ODS-NEXT: AttrSizedOperandSegments
|
|
// ODS-NEXT: SingleBlockImplicitTerminator<"YieldOp">
|
|
//
|
|
// IMPL-LABEL: ArrayAttr Test3Op::iterator_types() {
|
|
// IMPL: { {{.*}}Parallel{{.*}}, {{.*}}Parallel{{.*}}, {{.*}}Reduction{{.*}} }
|
|
//
|
|
// IMPL: ArrayAttr Test3Op::indexing_maps() {
|
|
// 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)));
|
|
}
|