I’ve a question about the traversal of op with linalg.matmul. It appears unexpected ops (not in mlir context) when traversing the function to print all ops…
It’s the testcase I used:
func @matmul_tensors(%arg0: tensor<?x?xf32>, %arg1: tensor<?x?xf32>, %arg2: tensor<?x?xf32>)-> tensor<?x?xf32> {
%0 = linalg.matmul ins(%arg0, %arg1: tensor<?x?xf32>, tensor<?x?xf32>)
outs(%arg2: tensor<?x?xf32>)-> tensor<?x?xf32>
return %0 : tensor<?x?xf32>
}
I print all ops using f.walk.
f.walk([&](Operation * op){
op->dump();
});
The print result is as follows:
%1 = arith.mulf %arg3, %arg4 : f32
%2 = arith.addf %arg5, %1 : f32
linalg.yield %2 : f32
%0 = linalg.matmul ins(%arg0, %arg1 : tensor<?x?xf32>, tensor<?x?xf32>) outs(%arg2 : tensor<?x?xf32>) -> tensor<?x?xf32>
return %0 : tensor<?x?xf32>
I guess that first three ops are the implementation part of matrix multiplication due to the linalg.matmul in testcase.
But I wonder about the mechanism of linalg.matmul. Why would the first three lines (not in mlir context) be traversed when I use linalg.matmul.
Thanks.