Skip to content

[CPU] linalg.pack op is not fused in forall distribution #20723

Closed

Description

@voonter

What happened?

I'm having an issue with simple combination of MaxPool and Gemm layers. The input MLIR looks like this:

module {
  func.func @tf2onnx(%arg0: !torch.vtensor<[8,64,1,256],f32>) -> !torch.vtensor<[8,64],f32> attributes {torch.onnx_meta.ir_version = 10 : si64, torch.onnx_meta.opset_version = 13 : si64, torch.onnx_meta.opset_versions = {ai.onnx.ml = 2 : si64}, torch.onnx_meta.producer_name = "tf2onnx", torch.onnx_meta.producer_version = "1.16.1 15c810"} {
    %0 = torch.operator "onnx.Constant"() {torch.onnx.value = dense_resource<Input1> : tensor<64x64xf32>} : () -> !torch.vtensor<[64,64],f32> 
    %1 = torch.operator "onnx.Constant"() {torch.onnx.value = dense_resource<Input2> : tensor<64xf32>} : () -> !torch.vtensor<[64],f32> 
    %none = torch.constant.none
    %2 = torch.operator "onnx.MaxPool"(%arg0) {torch.onnx.kernel_shape = [1 : si64, 256 : si64], torch.onnx.strides = [1 : si64, 256 : si64]} : (!torch.vtensor<[8,64,1,256],f32>) -> !torch.vtensor<[8,64,1,1],f32> 
    %3 = torch.operator "onnx.Flatten"(%2) : (!torch.vtensor<[8,64,1,1],f32>) -> !torch.vtensor<[8,64],f32> 
    %4 = torch.operator "onnx.Gemm"(%3, %0, %1) {torch.onnx.alpha = 1.000000e+00 : f32, torch.onnx.beta = 1.000000e+00 : f32, torch.onnx.transA = 0 : si64, torch.onnx.transB = 0 : si64} : (!torch.vtensor<[8,64],f32>, !torch.vtensor<[64,64],f32>, !torch.vtensor<[64],f32>) -> !torch.vtensor<[8,64],f32> 
    return %4 : !torch.vtensor<[8,64],f32>
  }
}

{-#
  dialect_resources: {
    builtin: {
      Input1: "0x0800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
      Input2: "0x0800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
    }
  }
#-}

And it produces the following error in VerifyWorkgroupDistributionPass:

debug_dump/maxpool_gemm_onnx.9.executable-configurations.mlir:33:19: error: 'vector.store' op write affecting operations on global resources are restricted to workgroup distributed contexts.
          %pack = linalg.pack %7 outer_dims_perm = [0, 1, 2, 3] inner_dims_pos = [0, 1] inner_tiles = [8, 1] into %3 : tensor<8x64x1x1xf32> -> tensor<1x64x1x1x8x1xf32>
                  ^
debug_dump/maxpool_gemm_onnx.9.executable-configurations.mlir:33:19: note: see current operation: "vector.store"(%68, %76, %32, %arg0, %32, %32, %32) <{nontemporal = false}> : (vector<8xf32>, memref<1x64x1x1x8xf32, strided<[512, 8, 8, 8, 1]>, #hal.descriptor_type<storage_buffer>>, index, index, index, index, index) -> ()
debug_dump/maxpool_gemm_onnx.9.executable-configurations.mlir:22:9: error: 'func.func' op failed on workgroup distribution verification
        func.func @tf2onnx$async_dispatch_0_pooling_nchw_max_8x64x1x1x1x256_f32_pack() attributes {translation_info = #translation} {
        ^
debug_dump/maxpool_gemm_onnx.9.executable-configurations.mlir:22:9: note: see current operation: 
"func.func"() <{function_type = () -> (), sym_name = "tf2onnx$async_dispatch_0_pooling_nchw_max_8x64x1x1x1x256_f32_pack"}> ({

I'm attaching a file with ir-print-ir-after-all dump starting from the executable-configurations.
compilation_dump.txt

Steps to reproduce your issue

Compilation command:

iree-compile --iree-hal-target-device=local --iree-hal-local-target-device-backends=llvm-cpu --iree-llvmcpu-target-cpu=host maxpool_gemm_onnx.mlir -o maxpool_gemm_onnx.vmfb

Debug dump command:

iree-compile --compile-from=executable-configurations --iree-hal-target-device=local --iree-hal-local-target-device-backends=llvm-cpu --iree-llvmcpu-target-cpu=host maxpool_gemm_onnx.9.executable-configurations.mlir -o maxpool_gemm_onnx.vmfb --mlir-disable-threading --mlir-print-ir-after-all > compilation_dump.txt 2>&1

What component(s) does this issue relate to?

Compiler

Version information

tag: iree-3.4.0rc20250417

Additional context

No response

Activity

  1. added
    bug 🐞
    on May 5, 2025
  2. added
    support
    integrations/onnx
    on May 7, 2025
  3. qedawkins commented on May 7, 2025

    @qedawkins
    Contributor

    This is a case where workgroup distribution failed to fuse in a pack:

    // -----// IR Dump After TileAndDistributeToWorkgroupsUsingForallOpPass (iree-codegen-tile-and-distribute-to-workgroups-using-forall-op) //----- //
    func.func @tf2onnx$async_dispatch_0_pooling_nchw_max_8x64x1x1x1x256_f32_pack() attributes {translation_info = #iree_codegen.translation_info<pipeline = CPUConvTileAndDecomposeExpert>} {
      %cst = arith.constant 0xFF800000 : f32
      %c0 = arith.constant 0 : index
      %0 = hal.interface.binding.subspan layout(<bindings = [#hal.pipeline.binding<storage_buffer, "ReadOnly|Indirect">, #hal.pipeline.binding<storage_buffer, Indirect>], flags = Indirect>) binding(0) alignment(64) offset(%c0) flags("ReadOnly|Indirect") : !flow.dispatch.tensor<readonly:tensor<8x64x1x256xf32>>
      %1 = hal.interface.binding.subspan layout(<bindings = [#hal.pipeline.binding<storage_buffer, "ReadOnly|Indirect">, #hal.pipeline.binding<storage_buffer, Indirect>], flags = Indirect>) binding(1) alignment(64) offset(%c0) flags(Indirect) : !flow.dispatch.tensor<writeonly:tensor<1x64x1x1x8x1xf32>>
      %2 = flow.dispatch.tensor.load %0, offsets = [0, 0, 0, 0], sizes = [8, 64, 1, 256], strides = [1, 1, 1, 1] : !flow.dispatch.tensor<readonly:tensor<8x64x1x256xf32>> -> tensor<8x64x1x256xf32>
      %3 = tensor.empty() : tensor<1x64x1x1x8x1xf32>
      %4 = tensor.empty() : tensor<8x64x1x1xf32>
      %5 = tensor.empty() : tensor<1x256xf32>
      %6 = scf.forall (%arg0, %arg1) = (0, 0) to (8, 64) step (1, 32) shared_outs(%arg2 = %4) -> (tensor<8x64x1x1xf32>) {
        %extracted_slice = tensor.extract_slice %2[%arg0, %arg1, 0, 0] [1, 32, 1, 256] [1, 1, 1, 1] : tensor<8x64x1x256xf32> to tensor<1x32x1x256xf32>
        %extracted_slice_0 = tensor.extract_slice %arg2[%arg0, %arg1, 0, 0] [1, 32, 1, 1] [1, 1, 1, 1] : tensor<8x64x1x1xf32> to tensor<1x32x1x1xf32>
        %7 = linalg.fill ins(%cst : f32) outs(%extracted_slice_0 : tensor<1x32x1x1xf32>) -> tensor<1x32x1x1xf32>
        %8 = linalg.pooling_nchw_max {dilations = dense<1> : vector<2xi64>, lowering_config = #iree_codegen.lowering_config<tile_sizes = [[1, 32, 0, 0, 0, 0], [1, 8, 1, 1, 0, 0], [0, 0, 0, 0, 1, 8], [0, 0, 0, 0, 0, 0]]>, strides = dense<[1, 256]> : vector<2xi64>} ins(%extracted_slice, %5 : tensor<1x32x1x256xf32>, tensor<1x256xf32>) outs(%7 : tensor<1x32x1x1xf32>) -> tensor<1x32x1x1xf32>
        scf.forall.in_parallel {
          tensor.parallel_insert_slice %8 into %arg2[%arg0, %arg1, 0, 0] [1, 32, 1, 1] [1, 1, 1, 1] : tensor<1x32x1x1xf32> into tensor<8x64x1x1xf32>
        }
      } {mapping = [#iree_codegen.workgroup_mapping<y>, #iree_codegen.workgroup_mapping<x>]}
      %pack = linalg.pack %6 outer_dims_perm = [0, 1, 2, 3] inner_dims_pos = [0, 1] inner_tiles = [8, 1] into %3 : tensor<8x64x1x1xf32> -> tensor<1x64x1x1x8x1xf32>
      flow.dispatch.tensor.store %pack, %1, offsets = [0, 0, 0, 0, 0, 0], sizes = [1, 64, 1, 1, 8, 1], strides = [1, 1, 1, 1, 1, 1] : tensor<1x64x1x1x8x1xf32> -> !flow.dispatch.tensor<writeonly:tensor<1x64x1x1x8x1xf32>>
      return
    }
    

    That pack later materializes as a stack allocation that fails when we verify distribution. There is no recourse if the fusion fails so the solution is to support it somehow. General support for this kind of fusion will happen hopefully soon, but keeps getting pushed back. In the shorter term, the particular flavor of tile sizes chosen here look supportable though. We can potentially do it through improvements to the tiling interface of pack: https://github.com/llvm/llvm-project/blob/854b9e931703dd1b9d8a2b0fe8da787f9e26058d/mlir/lib/Dialect/Linalg/Transforms/TilingInterfaceImpl.cpp#L599

  4. egebeysel commented on May 19, 2025

    @egebeysel
    Contributor

    This is a case where workgroup distribution failed to fuse in a pack:

    Question here: what would be the reason to end up with such a dispatch where the pack op doesn't have a lowering config? Because AFAIK, if it had one, then the forall tiling would've tiled that one and fuse the generic into it rather than what happened here.

  5. egebeysel commented on May 19, 2025

    @egebeysel
    Contributor

    This is a case where workgroup distribution failed to fuse in a pack:

    Question here: what would be the reason to end up with such a dispatch where the pack op doesn't have a lowering config? Because AFAIK, if it had one, then the forall tiling would've tiled that one and fuse the generic into it rather than what happened here.

    Just confirmed that if the pack op had a suitable lowering config, the fusion would've happened:

    func.func @tf2onnx$async_dispatch_0_pooling_nchw_max_8x64x1x1x1x256_f32_pack() attributes {translation_info = #iree_codegen.translation_info<pipeline = CPUConvTileAndDecomposeExpert>} {
      %cst = arith.constant 0xFF800000 : f32
      %c0 = arith.constant 0 : index
      %0 = hal.interface.binding.subspan layout(<bindings = [#hal.pipeline.binding<storage_buffer, "ReadOnly|Indirect">, #hal.pipeline.binding<storage_buffer, Indirect>], flags = Indirect>) binding(0) alignment(64) offset(%c0) flags("ReadOnly|Indirect") : !iree_tensor_ext.dispatch.tensor<readonly:tensor<8x64x1x256xf32>>
      %1 = hal.interface.binding.subspan layout(<bindings = [#hal.pipeline.binding<storage_buffer, "ReadOnly|Indirect">, #hal.pipeline.binding<storage_buffer, Indirect>], flags = Indirect>) binding(1) alignment(64) offset(%c0) flags(Indirect) : !iree_tensor_ext.dispatch.tensor<writeonly:tensor<1x64x1x1x8x1xf32>>
      %2 = iree_tensor_ext.dispatch.tensor.load %0, offsets = [0, 0, 0, 0], sizes = [8, 64, 1, 256], strides = [1, 1, 1, 1] : !iree_tensor_ext.dispatch.tensor<readonly:tensor<8x64x1x256xf32>> -> tensor<8x64x1x256xf32>
      %3 = tensor.empty() : tensor<1x64x1x1x8x1xf32>
      %4 = tensor.empty() : tensor<8x64x1x1xf32>
      %5 = tensor.empty() : tensor<1x256xf32>
      %6 = linalg.fill ins(%cst : f32) outs(%4 : tensor<8x64x1x1xf32>) -> tensor<8x64x1x1xf32>
      %7 = linalg.pooling_nchw_max {dilations = dense<1> : vector<2xi64>, lowering_config = #iree_codegen.lowering_config<tile_sizes = [[1, 32, 0, 0, 0, 0], [1, 8, 1, 1, 0, 0], [0, 0, 0, 0, 1, 8], [0, 0, 0, 0, 0, 0]]>, strides = dense<[1, 256]> : vector<2xi64>} ins(%2, %5 : tensor<8x64x1x256xf32>, tensor<1x256xf32>) outs(%6 : tensor<8x64x1x1xf32>) -> tensor<8x64x1x1xf32>
      %pack = linalg.pack %7 outer_dims_perm = [0, 1, 2, 3] inner_dims_pos = [0, 1] inner_tiles = [8, 1] into %3 {lowering_config = #iree_codegen.lowering_config<tile_sizes = [[8, 32, 0, 0], [8, 8, 1, 1], [0, 0, 0, 0], [0, 0, 0, 0]]>}: tensor<8x64x1x1xf32> -> tensor<1x64x1x1x8x1xf32>
      iree_tensor_ext.dispatch.tensor.store %pack, %1, offsets = [0, 0, 0, 0, 0, 0], sizes = [1, 64, 1, 1, 8, 1], strides = [1, 1, 1, 1, 1, 1] : tensor<1x64x1x1x8x1xf32> -> !iree_tensor_ext.dispatch.tensor<writeonly:tensor<1x64x1x1x8x1xf32>>
      return
    }

    Running the wg-level distribution pass: iree-opt --pass-pipeline="builtin.module(func.func(iree-codegen-tile-and-distribute-to-workgroups-using-forall-op))" repro.mlir, one gets both ops in the same forall loop. Not sure if the lowering config that I manually added to the pack op is entirely correct, but I would expect the distribution and vector-parallel dims should be OK.

  6. changed the title [-]A simple MaxPool and Gemm example is failing at the VerifyWorkgroupDistributionPass.[/-] [+][CPU] linalg.pack op is not fused in forall distribution[/+] on May 19, 2025
  7. self-assigned this
    on May 19, 2025
  8. egebeysel commented on May 20, 2025

    @egebeysel
    Contributor

    Hey @hanhanW, I'd like to help on this one. AFAICS, this specific issue has 2 (actually 3 with the fallback option not existing after fusion fails on the wg-level) problems:

    1. The pack op over here does not have a lowering config. I think I could investigate why we end up in such case and come up with something for that one. The fusion succeeds if we have a suitable one set on the pack op.

    2. Generally speaking, I guess the consumer fusion could be improved to also handle cases where we have some op -> pack and where producer fusion is able to fuse the other op but consumer fusion isn't. I've already posted some examples on the other issue. I guess regardless of the previous discussion on pack ops maybe having precedence over element-wise ops on root op selection, it would be a better starting point to investigate to what extent the consumer fusion can be improved to handle these cases, since we can also have the pack ops ending up in the same dispatch with other non-element-wise ops.

    Let me know if these sound reasonable to you and/or if you have something else in mind.

  9. hanhanW commented on May 20, 2025

    @hanhanW
    Contributor

    The root cause is that the consumer fusion is not completed in the pack op TilingInterface implementation

            // Currently fusing `packOp` as consumer only expects perfect tiling
            // scenario because even if without padding semantic, the `packOp` may
            // also yield incomplete tiles. E.g. tensor<30xf32> -> tensor<5x6xf32>,
            // where the `tileSize` from operand of `packOp` is 5, which is not
            // exactly divided by `innerTile`(=6) of `packOp`. As the result:
            // 1. the first slice is extracted from (0) to (4) and inserted into
            // (0,0)~(0,4) at first row.
            // 2. the second slice is extracted from (5) to (9) and SHOULD BE
            // respectively inserted into two rows with different length, including
            // first row: (0,5) and second row (1,0)~(1,3). It is hard to coordinate
            // them, thus adding below constraint to bypass them temporarily. In
            // another word, we can only support tiling with consumer if the tile
            // size for the producer is a multiple of the inner tile size for the
            // packed dimensions at this moment.
            if (failed(cstSize) || !cstInnerSize || *cstSize % *cstInnerSize != 0) {
              return failure();
            }

    I roughly reviewed the code long time ago, but I don't remember details now. Maybe you can help implement it: llvm/llvm-project#103715

    I'll need to refresh my memory to provide further suggestion. The rough idea is that it is an inverse version of unpack producer fusion. We might need to adjust slices and insert them to corresponding position. If multiple insert_slice ops is needed, we might hit the limitation of scf.forall, and we can add the support for scf.for first. (There might no issues in scf.forall, I just don't remember all the details atm.)

    I don't really follow the comment in the code, but I may miss something for how it works e2e. I haven't checked the fusion code for a while. I'd appreciate it if you can pick up from here, and we can chat more. IMO, we need to complete the tiling implementation, even it leads to inefficient code. It is more about completeness, and the issue won't bite us again in the future.

  10. hanhanW commented on May 20, 2025

    @hanhanW
    Contributor

    Here is the snippet that I've been playing with the code today. Just in case if it helps: https://gist.github.com/hanhanW/4678117dc4767c1568b758caf43e0063

    Run: iree-opt --iree-transform-dialect-interpreter -canonicalize -cse ~/repro.mlir.

    There is a bug in transform.iree.fuse_consumer, and I'm preparing a fix.

  11. hanhanW commented on May 20, 2025

    @hanhanW
    Contributor

    There is a bug in transform.iree.fuse_consumer, and I'm preparing a fix.

    Here is the fix: #20869

  12. egebeysel commented on May 22, 2025

    @egebeysel
    Contributor

    Btw. thanks for the pointers! I'm currently looking at these - especially the unpack counterpart that you implemented - trying to get a better picture of how it is and how the missing part could be implemented, and would bother you further if I have questions :) Thanks in advance!

  13. hanhanW commented on Jun 6, 2025

    @hanhanW
    Contributor

    I promised to share my idea, but I failed. I think we have good observation on discord, so I'm mirroring the context to the issue.

    From @egebeysel :

    Hi folks! I apologize for the rather long question in advance and please correct me if I'm misinterpreting something. We were having some cases where the consumer fusion of the pack ops were not happening, and therefore I was trying to complete the tiling implementation of the pack operation for the consumer fusion case, since it currently only supports if the input tile sizes are divisible by the inner tile sizes, see here.

    It is supposed to be inverse to the producer fusion case of the unpack operation, and in a way it is. The calculation of where result sizes and offsets is analogous to the calculation of the source size and offsets.

    Taking the example from above with the pack [30] into [5x6], and input tile size = 5, one can calculate that the first tile should be going to the positions (0, 0) - (0, 4), the second one to (0,5) - (1,3) etc.

    On the inverse case, the producer fusion of unpack can overpropagate its input buffer, i.e. read more elements than it needs to calculate the result tile size = 5. For example, to calculate the second tile of unpack [5x6] to [30], one could read a [2x6]slice of the input from the first two outer dims, unpack that and extract the [5] output from the correct positions.

    With the consumer pack op pack [30] into [5x6] , one can calculate the offsets and sizes to allocate a big enough input (and output) buffer, insert the [5]input to the right position on the input buffer, e.g. positions (5-9)for the second case from above with an input buffer of shape [12] and pack that into a [2x6]output with all 5 elements in the right positions. Now at this point, I'm having a hard time understanding how one might construct a valid output for the tiled implementation from here. The unpack case used over-utilized the input buffer, where for the inverse we have an under-utilized output, with no way of getting any consumable [Nx6]slice from the overall output buffer [5x6], no matter where (and I guess how) we insert the result buffer of [2x6] in our hands (although we can use a sequence of insert slice ops to place them into the correct positions in the untiled result buffer, that doesn't give us valid results for the tiled implementation I believe). I guess this is a similar situation to fusing pack op as a producer with tiled inner dims like here.

    I feel like I might be missing something fundamental over here, so any pointers would actually be much appreciated.

    Also, @qedawkins mentioned that it might not be possible to add support for the fusion for this case with the current state of scf.forall + TilingInterface, were you maybe referring to this limitation or am I misinterpreting something here?

    From Hanhan:

    Thanks for digging into this. I now remember more details. I think I might know what’s happening, and it may not be supported. The tile sizes of pack op is defined in unpacked domain, which means that the tile sizes are always scaled to be aligned with inner tile sizes. It seems that this case is not defined in consumer fusion. A potential solution is adjusting tile sizes when there are pack ops. I feel that we want to revisit and revamp my earlier TileSizeGenerator ideas, I can try to find it, clean it up a bit and share with you next week.

    ====

    I think the immediate next step is to adjust the tile sizes that makes it align with packing config, like unpack ops. The code is too complicated at the moment, so it is not easy to make the change.

    // The transform dialect codegen has differnet logics and codegen flow.
    // Ignore the tile sizes adjustment.
    auto pipeline = getTranslationInfo(entryPointFn).getPassPipeline().getValue();
    if (pipeline != DispatchLoweringPassPipeline::TransformDialectCodegen) {
    if (failed(adjustTileSizesForUnPackOp(entryPointFn, rootOperation))) {
    return failure();
    }

  14. egebeysel commented on Jun 25, 2025

    @egebeysel
    Contributor

    Hey , sorry I was off for a while and missed the last comment. I'd be down to discuss the tile size generator idea. I guess this would be even more important once one tries to fuse longer sequences of operations than the current setting. So at least coming up with the requirements and/or ideas and listing them here (or somewhere else in a separate issue) would make sense I believe.

  15. hanhanW commented on Jun 25, 2025

    @hanhanW
    Contributor

    MapScatter Approach

    After talking to @MaheshRavishankar today (and maybe @Max191 in the other meeting recently), we have a more robust fix. It may not be performant, but it prevents such error in the future. Maintaining the tile size selection logic is not trivial as there could be other new input patterns, so we need a decent fallback solution.

    The idea is about using MapScatter op when the fusion is not happening. We can have a pass that performs early bufferization and converts the pack/unpack/relayout ops to map_scatter ops right after distribution; we fuse the map_scatter into the forall op. The rest compilation remains the same.

    We don't apply the pass before distribution because we'd lose the opportunity of transpose optimization. It is hard to recover such information from MapScatter op.

    This work is independent of the tile size generator; maybe @Max191 can pick it up, as you are the author of the MapScatter op.

    TileSizesGenerator

    For tile size generator, I'm putting a rough idea below; someone can help implement it.

    Goals (i.e., what we want to resolve)

    1. Decouple tile sizes selection logics and pipeline lowering logics.
      a. Developers can easily set tile sizes for each level. They don’t need to split the list for parallel loops and reduction loops; they don’t need to fully understand the pipeline lowering flow.
      b. We do not want to spread splitParallelAndReductionTiles methods/logics everywhere.
      c. We don’t need to spread setting non vector level scalable flags to false everywhere.
    2. Better handling for multi lowering config.
      a. Figure out what dims are shared with root op, and what are not.
      b. Have a priority list about setting tile sizes from the rest of compute ops.
      c. Serialize the lowering_config for all the ops in one shot. I.e., do not set lowering config on root op and reset it after adjustments.
    3. Give more hints to ops during tile size selection.
      a. Ops can know how tile sizes will be scaled in advance.

    Proposal Ideas

    TileSizesGenerator is a class which holds the following information.

    • It collects the total number of iteration domains. Some of the dimensions are shared between all the ops, and some of them are only used by an op.
    • It can map each iteration domain of an op to the maintained dimension.
    • It does not need to know the information about parallel loops and reduction loops.
    • It holds 1-3 (distribution, cache, vector) lists about tile sizes. It can set the scalability flag at vector tile sizes level.
    • Each tile size can have a set of callback functions, e.g.,
      • Convolution/Pooling ops require some tile sizes (at vector level) being ones, so they can be decomposed to lower rank op and make vectorization happen.
      • Some tile sizes might need to be aligned with unpack’s inner tile sizes to prevent stack allocation.
      • Some tile sizes should be adjusted with the pack's inner tile sizes. Otherwise they will be larger than expected when doing TileAndFuse.
    • Given an op, it is able to generate the corresponding lowering_config and set it to the op. This includes splitting the tile sizes for parallel loops (i.e., fusion) and reduction loops (i.e., tiling only).

    The callback functions are driven by existing use cases. They can be something else like Policy or Requirement struct, e.g., multiple_of_value.

    This class was designed long time ago, but it is suitable for the case. Because it is mostly a helper for mapping iteration space.

  16. hanhanW commented on Jun 25, 2025

    @hanhanW
    Contributor

    RE map_scattor approach, we'd need #21135 for tensor-based vectorization. It can happen later, as we need it being functional as the first step.

  17. egebeysel commented on Jul 3, 2025

    @egebeysel
    Contributor

    @hanhanW I'll be glad if you could ping me if/when you're working on this. I'll also be interested to work on it and/or contribute at one point but I don't have the time just now 👍

    Also, I guess getting the TileSizeGenerator or at least as a first step adjusting tile sizes for pack (and possibly unpack) ops would also be useful if you wanted to extend this PR to non-mmt4d dispatches.

  18. hanhanW commented on Jul 7, 2025

    @hanhanW
    Contributor

    @hanhanW I'll be glad if you could ping me if/when you're working on this. I'll also be interested to work on it and/or contribute at one point but I don't have the time just now 👍

    Yes, I'll cc you in the PRs. :)

    Also, I guess getting the TileSizeGenerator or at least as a first step adjusting tile sizes for pack (and possibly unpack) ops would also be useful if you wanted to extend this PR to non-mmt4d dispatches.

    I'm okay with starting with TileSizeGenerator if someone has cycles. If it is not an urgent fix, I'd go with the robust fallback approach since it should only take me like O(days). To me, playing with tile size adjustment could be a pain and tech debt atm, since we might re-write the logic and they are too complicated atm.

  19. hanhanW commented on Jul 21, 2025

    @hanhanW
    Contributor

    There are some issues that I need to triage, e.g., additional stack buffers. And there are other work like vectorization. But I verified that #21444 fixes the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug 🐞integrations/onnxsupport

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions