MLIR "--convert-linalg-to-affine" pass file outputs unchanged

Hi~ I want to lower the generated linalg dialect mlir from torch-mlir frontend to affine loop representation. However, after running the input command mlir-opt --convert-linalg-to-affine compiled_torch2.2.mlir the output file remains unchanged. I suspect that I might be missing some options.:sob: given that unfamiliar with linalg to affine pipeline, I would appreciate that If someone could point out critical transformation path Preformatted text :innocent:
Below code snippet illustrate the input matrix multiplication

import torch
import torch_mlir

class MatMulModule(torch.nn.Module):
    def forward(self, a, b):
        return torch.matmul(a, b)


input_a = torch.ones(3, 3)
input_b = torch.ones(3, 3) * 2


compiled = torch_mlir.compile(MatMulModule(), (input_a, input_b), output_type=torch_mlir.OutputType.LINALG_ON_TENSORS)


with open("compiled_torch_test", "w") as f:
    f.write(str(compiled))

print(compiled)

Hi, could you please share compiled_torch2.2.mlir? It is difficult to say what is going on without looking at the IR.

No Problem~ Thanks for your reply!!

module attributes {torch.debug_module_name = "MatMulModule"} {
  ml_program.global private mutable @global_seed(dense<0> : tensor<i64>) : tensor<i64>
  func.func @forward(%arg0: tensor<3x3xf32>, %arg1: tensor<3x3xf32>) -> tensor<3x3xf32> {
    %cst = arith.constant 0.000000e+00 : f32
    %0 = tensor.empty() : tensor<3x3xf32>
    %1 = linalg.fill ins(%cst : f32) outs(%0 : tensor<3x3xf32>) -> tensor<3x3xf32>
    %2 = linalg.matmul ins(%arg0, %arg1 : tensor<3x3xf32>, tensor<3x3xf32>) outs(%1 : tensor<3x3xf32>) -> tensor<3x3xf32>
    return %2 : tensor<3x3xf32>
  }
}

Thanks. I think you miss the bufferization step. Try mlir-opt file.mlir -empty-tensor-to-alloc-tensor -one-shot-bufferize -convert-linalg-to-affine-loops.

OK, I see~ Thanks again for your hints :smiling_face_with_three_hearts: