/Workspace/buddy-mlir/llvm/build/bin/mlir-opt conv2d_call.mlir -linalg-tile="tile-sizes=2,2"
#map0 = affine_map<(d0)[s0] -> (2, -d0 + s0)>
#map1 = affine_map<(d0, d1)[s0, s1] -> (d0 * s1 + s0 + d1)>
#map2 = affine_map<(d0)[s0, s1] -> (s0 + 1, -d0 + s0 + s1 - 1)>
func @conv_2d_(%arg0: memref<?x?xf32>, %arg1: memref<?x?xf32>, %arg2: memref<?x?xf32>) {
%c2 = arith.constant 2 : index
%c0 = arith.constant 0 : index
%c1 = arith.constant 1 : index
%0 = memref.dim %arg1, %c0 : memref<?x?xf32> //FH
%1 = memref.dim %arg1, %c1 : memref<?x?xf32> //FW
%2 = memref.dim %arg2, %c0 : memref<?x?xf32> //OH
%3 = memref.dim %arg2, %c1 : memref<?x?xf32> //OW
scf.for %arg3 = %c0 to %2 step %c2 { //oh+2
scf.for %arg4 = %c0 to %3 step %c2 { //ow+2
%4 = affine.min #map2(%arg3)[%0, %2] // FH+1, FH+OH-fh-1
%5 = affine.min #map2(%arg4)[%1, %3] // FW+1, FW+OW-fw-1
// img[oh:oh+FH,ow:ow+FW]
%6 = memref.subview %arg0[%arg3, %arg4] [%4, %5] [1, 1] : memref<?x?xf32> to memref<?x?xf32, #map1>
%7 = affine.min #map0(%arg3)[%2] //2, OH - oh
%8 = affine.min #map0(%arg4)[%3] //2, OW - ow
// out[ow:ow+2,oh:oh+2]
%9 = memref.subview %arg2[%arg3, %arg4] [%7, %8] [1, 1] : memref<?x?xf32> to memref<?x?xf32, #map1>
linalg.conv_2d ins(%6, %arg1 : memref<?x?xf32, #map1>, memref<?x?xf32>) outs(%9 : memref<?x?xf32, #map1>)
}
}
return
}