rewrite.mlir 1.3 KB
Newer Older
Y
Yan Chunwei 已提交
1 2
// CHECK-LABEL: @main
func @main() -> tensor<?xf32> {
3 4 5
  %a = "pd.feed"() {name="input0"} : () -> tensor<?xf32>
  %b = "pd.feed"() {name="input1"} : () -> tensor<?xf32>
  %bias = "pd.feed"() {name="input2"} : () -> tensor<?xf32>
Y
Yan Chunwei 已提交
6

7 8 9 10
  %b1 = "pd.feed"() {name="input3"} : () -> tensor<?xf32>
  %b2 = "pd.feed"() {name="input4"} : () -> tensor<?xf32>
  %bias1 = "pd.feed"() {name="input5"} : () -> tensor<?xf32>
  %bias2 = "pd.feed"() {name="input6"} : () -> tensor<?xf32>
Y
Yan Chunwei 已提交
11

12 13 14
  %c = "pd.matmul"(%a, %b) {transpose_y=false} : (tensor<?xf32>, tensor<?xf32>) -> tensor<?xf32>
  %d = "pd.elementwise_add"(%c, %bias) {axis=1:i32} : (tensor<?xf32>, tensor<?xf32>) -> tensor<?xf32>
  %e = "pd.relu6"(%d) {} : (tensor<?xf32>) -> tensor<?xf32>
Y
Yan Chunwei 已提交
15

16 17 18
  %c1 = "pd.matmul"(%e, %b1) {transpose_x=false, transpose_y=false} : (tensor<?xf32>, tensor<?xf32>) -> tensor<?xf32>
  %d1 = "pd.elementwise_add"(%c1, %bias1) {axis=1:i32} : (tensor<?xf32>, tensor<?xf32>) -> tensor<?xf32>
  %e1 = "pd.relu"(%d1) {} : (tensor<?xf32>) -> tensor<?xf32>
Y
Yan Chunwei 已提交
19

20 21 22
  %c2 = "pd.matmul"(%e1, %b2) {transpose_x=true, transpose_y=false} : (tensor<?xf32>, tensor<?xf32>) -> tensor<?xf32>
  %d2 = "pd.elementwise_add"(%c2, %bias2) {axis=1:i32} : (tensor<?xf32>, tensor<?xf32>) -> tensor<?xf32>
  %e2 = "pd.relu"(%d2) {} : (tensor<?xf32>) -> tensor<?xf32>
Y
Yan Chunwei 已提交
23 24
  infrt.return %e2 : tensor<?xf32>
}