2020-05-13 10:21:36 +08:00
|
|
|
// RUN: mlir-opt %s -test-linalg-transform-patterns=test-matmul-to-vector-patterns-tile-1d | FileCheck %s
|
|
|
|
// RUN: mlir-opt %s -test-linalg-transform-patterns=test-matmul-to-vector-patterns-tile-2d | FileCheck %s
|
2020-07-10 22:21:45 +08:00
|
|
|
// RUN: mlir-opt %s -test-linalg-transform-patterns=test-contraction-to-vector-patterns | FileCheck %s --check-prefix=VECTOR-CONTRACTION
|
2020-05-12 04:05:39 +08:00
|
|
|
|
|
|
|
func @matmul(%A: memref<1584x1584xf32, offset: 0, strides: [1584, 1]>,
|
|
|
|
%B: memref<1584x1584xf32, offset: 0, strides: [1584, 1]>,
|
|
|
|
%C: memref<1584x1584xf32, offset: 0, strides: [1584, 1]>) {
|
[mlir][Linalg] Retire C++ MatmulOp in favor of a linalg-ods-gen'd op.
Summary:
This revision replaces MatmulOp, now that DRR rules have been dropped.
This revision also fixes minor parsing bugs and a plugs a few holes to get e2e paths working (e.g. library call emission).
During the replacement the i32 version had to be dropped because only the EDSC operators +, *, etc support type inference.
Deciding on a type-polymorphic behavior, and implementing it, is left for future work.
Reviewers: aartbik
Subscribers: mehdi_amini, rriddle, jpienaar, shauheen, antiagainst, arpith-jacob, mgester, lucyrfox, aartbik, liufengdb, stephenneuendorffer, Joonsoo, grosul1, frgossen, Kayjukh, jurahul, msifontes
Tags: #mlir
Differential Revision: https://reviews.llvm.org/D81935
2020-06-16 21:14:42 +08:00
|
|
|
linalg.matmul %A, %B, %C {__internal_linalg_transform__ = "START"} :
|
|
|
|
(memref<1584x1584xf32, offset: 0, strides: [1584, 1]>,
|
|
|
|
memref<1584x1584xf32, offset: 0, strides: [1584, 1]>,
|
|
|
|
memref<1584x1584xf32, offset: 0, strides: [1584, 1]>)
|
2020-05-12 04:05:39 +08:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// CHECK-LABEL:func @matmul
|
|
|
|
// CHECK: vector.broadcast {{.*}} : f32 to vector<8x16xf32>
|
|
|
|
// CHECK: store {{.*}}[] : memref<vector<8x16xf32>>
|
|
|
|
//
|
|
|
|
// CHECK: vector.broadcast {{.*}} : f32 to vector<16x12xf32>
|
|
|
|
// CHECK: store {{.*}}[] : memref<vector<16x12xf32>>
|
|
|
|
//
|
|
|
|
// CHECK: vector.broadcast {{.*}} : f32 to vector<8x12xf32>
|
|
|
|
// CHECK: store {{.*}}[] : memref<vector<8x12xf32>>
|
|
|
|
//
|
|
|
|
// CHECK: linalg.copy
|
|
|
|
// CHECK: linalg.copy
|
|
|
|
// CHECK: linalg.copy
|
|
|
|
//
|
|
|
|
// CHECK: vector.contract
|
|
|
|
// CHECK-SAME: iterator_types = ["parallel", "parallel", "reduction"]
|
|
|
|
// CHECK-SAME: : vector<8x16xf32>, vector<16x12xf32> into vector<8x12xf32>
|
|
|
|
//
|
|
|
|
// CHECK: linalg.copy
|
2020-07-10 22:21:45 +08:00
|
|
|
|
|
|
|
// VECTOR-CONTRACTION-LABEL: contraction_dot
|
|
|
|
func @contraction_dot(%A: memref<1584xf32>, %B: memref<1584xf32>, %C: memref<f32>) {
|
|
|
|
// VECTOR-CONTRACTION: vector.contract
|
|
|
|
// VECTOR-CONTRACTION-SAME: vector<1584xf32>, vector<1584xf32> into f32
|
2020-07-28 18:29:54 +08:00
|
|
|
linalg.dot %A, %B, %C : (memref<1584xf32>, memref<1584xf32>, memref<f32>)
|
2020-07-10 22:21:45 +08:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// VECTOR-CONTRACTION-LABEL: contraction_matvec
|
|
|
|
func @contraction_matvec(%A: memref<1584x1584xf32>, %B: memref<1584xf32>, %C: memref<1584xf32>) {
|
|
|
|
// VECTOR-CONTRACTION: vector.contract
|
|
|
|
// VECTOR-CONTRACTION-SAME: vector<1584x1584xf32>, vector<1584xf32> into vector<1584xf32>
|
|
|
|
linalg.matvec %A, %B, %C :
|
|
|
|
(memref<1584x1584xf32>, memref<1584xf32>, memref<1584xf32>)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// VECTOR-CONTRACTION-LABEL: contraction_matmul
|
|
|
|
func @contraction_matmul(%A: memref<1584x1584xf32>, %B: memref<1584x1584xf32>, %C: memref<1584x1584xf32>) {
|
|
|
|
// VECTOR-CONTRACTION: vector.contract
|
|
|
|
// VECTOR-CONTRACTION-SAME: vector<1584x1584xf32>, vector<1584x1584xf32> into vector<1584x1584xf32>
|
|
|
|
linalg.matmul %A, %B, %C :
|
|
|
|
(memref<1584x1584xf32>, memref<1584x1584xf32>, memref<1584x1584xf32>)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// VECTOR-CONTRACTION-LABEL: contraction_batch_matmul
|
|
|
|
func @contraction_batch_matmul(%A: memref<1584x1584x1584xf32>, %B: memref<1584x1584x1584xf32>, %C: memref<1584x1584x1584xf32>) {
|
|
|
|
// VECTOR-CONTRACTION: vector.contract
|
|
|
|
// VECTOR-CONTRACTION-SAME: vector<1584x1584x1584xf32>, vector<1584x1584x1584xf32> into vector<1584x1584x1584xf32>
|
|
|
|
linalg.batch_matmul %A, %B, %C :
|
|
|
|
(memref<1584x1584x1584xf32>, memref<1584x1584x1584xf32>, memref<1584x1584x1584xf32>)
|
|
|
|
return
|
|
|
|
}
|