Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

torch.aten._scaled_dot_product_efficient_attention:Failed to legalize operation 'torch.operator' that was explicitly marked illegal #3893

Open
bilu-1 opened this issue Nov 28, 2024 · 0 comments

Comments

@bilu-1
Copy link

bilu-1 commented Nov 28, 2024

The convert cmd:

iree-opt --torch-to-iree --mlir-print-ir-after-all {torch_ir} -o {linalg_ir}

Torch IR:

module {
  func.func @main(%arg0: !torch.vtensor<[1,32,7,128],f32>, %arg1: !torch.vtensor<[1,32,7,128],f32>, %arg2: !torch.vtensor<[1,32,7,128],f32>, %arg3: !torch.vtensor<[1,32,7,7],f32>, %arg4: !torch.int, %arg5: !torch.float, %arg6: !torch.int) -> (!torch.vtensor<[1,32,7,128],f32>, !torch.vtensor<[1,32,32],f32>, !torch.vtensor<[],si64>, !torch.vtensor<[],si64>) {
    %true = torch.constant.bool true
    %float8.000000e-02 = torch.constant.float 8.000000e-02
    %true_0 = torch.constant.bool true
    %none = torch.constant.none
    %0:4 = torch.operator "torch.aten._scaled_dot_product_efficient_attention"(%arg0, %arg1, %arg2, %arg3, %true, %float8.000000e-02, %true_0, %none) : (!torch.vtensor<[1,32,7,128],f32>, !torch.vtensor<[1,32,7,128],f32>, !torch.vtensor<[1,32,7,128],f32>, !torch.vtensor<[1,32,7,7],f32>, !torch.bool, !torch.float, !torch.bool, !torch.none) -> (!torch.vtensor<[1,32,7,128],f32>, !torch.vtensor<[1,32,32],f32>, !torch.vtensor<[],si64>, !torch.vtensor<[],si64>) 
    return %0#0, %0#1, %0#2, %0#3 : !torch.vtensor<[1,32,7,128],f32>, !torch.vtensor<[1,32,32],f32>, !torch.vtensor<[],si64>, !torch.vtensor<[],si64>
  }
}

The error info printed:

/workspace/iree/tests/e2e/dlc_specific/torch-ir/ScaledDotProductEfficientAttention/ScaledDotProductEfficientAttention.mlir:7:12: error: failed to legalize operation 'torch.operator' that was explicitly marked illegal
    %0:4 = torch.operator "torch.aten._scaled_dot_product_efficient_attention"(%arg0, %arg1, %arg2, %arg3, %true, %float8.000000e-02, %true_0, %none) : (!torch.vtensor<[1,32,7,128],f32>, !torch.vtensor<[1,32,7,128],f32>, !torch.vtensor<[1,32,7,128],f32>, !torch.vtensor<[1,32,7,7],f32>, !torch.bool, !torch.float, !torch.bool, !torch.none) -> (!torch.vtensor<[1,32,7,128],f32>, !torch.vtensor<[1,32,32],f32>, !torch.vtensor<[],si64>, !torch.vtensor<[],si64>) 
           ^
/workspace/iree/tests/e2e/dlc_specific/torch-ir/ScaledDotProductEfficientAttention/ScaledDotProductEfficientAttention.mlir:7:12: note: see current operation: %3:4 = "torch.operator"(%arg0, %arg1, %arg2, %arg3, %0, %1, %0, %2) <{name = "torch.aten._scaled_dot_product_efficient_attention"}> : (!torch.vtensor<[1,32,7,128],f32>, !torch.vtensor<[1,32,7,128],f32>, !torch.vtensor<[1,32,7,128],f32>, !torch.vtensor<[1,32,7,7],f32>, !torch.bool, !torch.float, !torch.bool, !torch.none) -> (!torch.vtensor<[1,32,7,128],f32>, !torch.vtensor<[1,32,32],f32>, !torch.vtensor<[],si64>, !torch.vtensor<[],si64>)
// -----// IR Dump After ReduceOpVariants Failed (torch-reduce-op-variants) //----- //
func.func @main(%arg0: !torch.vtensor<[1,32,7,128],f32>, %arg1: !torch.vtensor<[1,32,7,128],f32>, %arg2: !torch.vtensor<[1,32,7,128],f32>, %arg3: !torch.vtensor<[1,32,7,7],f32>, %arg4: !torch.int, %arg5: !torch.float, %arg6: !torch.int) -> (!torch.vtensor<[1,32,7,128],f32>, !torch.vtensor<[1,32,32],f32>, !torch.vtensor<[],si64>, !torch.vtensor<[],si64>) attributes {torch.assume_strict_symbolic_shapes} {
  %true = torch.constant.bool true
  %float8.000000e-02 = torch.constant.float 8.000000e-02
  %none = torch.constant.none
  %0:4 = torch.operator "torch.aten._scaled_dot_product_efficient_attention"(%arg0, %arg1, %arg2, %arg3, %true, %float8.000000e-02, %true, %none) : (!torch.vtensor<[1,32,7,128],f32>, !torch.vtensor<[1,32,7,128],f32>, !torch.vtensor<[1,32,7,128],f32>, !torch.vtensor<[1,32,7,7],f32>, !torch.bool, !torch.float, !torch.bool, !torch.none) -> (!torch.vtensor<[1,32,7,128],f32>, !torch.vtensor<[1,32,32],f32>, !torch.vtensor<[],si64>, !torch.vtensor<[],si64>) 
  return %0#0, %0#1, %0#2, %0#3 : !torch.vtensor<[1,32,7,128],f32>, !torch.vtensor<[1,32,32],f32>, !torch.vtensor<[],si64>, !torch.vtensor<[],si64>
}

At present, it seems that efficient_attention does not support falling. Hope that the support of this op can be considered in the future. Thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant