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

retinanet_resnet50_fpn_vaiq_int8 model support #199

Open
AmosLewis opened this issue Apr 22, 2024 · 3 comments
Open

retinanet_resnet50_fpn_vaiq_int8 model support #199

AmosLewis opened this issue Apr 22, 2024 · 3 comments
Assignees
Labels

Comments

@AmosLewis
Copy link
Collaborator

Failed op:

Before fixing expand op, we cannot get any other fail op signature information. The following cmd is blocked by expand.

torch-mlir-opt -convert-torch-onnx-to-torch retinanet_resnet50_fpn_vaiq_int8.default.torch-onnx.mlir > retinanet_resnet50_fpn_vaiq_int8.default.onnx.torch.mlir 
retinanet_resnet50_fpn_vaiq_int8.default.torch-onnx.mlir:1067:13: error: failed to legalize operation 'torch.operator' that was explicitly marked illegal
    %1063 = torch.operator "onnx.Pad"(%895, %1062, %none) {torch.onnx.mode = "constant"} : (!torch.vtensor<[?,?,?],f32>, !torch.vtensor<[?],si64>, !torch.none) -> !torch.vtensor<[?,?,?],f32> 
            ^
retinanet_resnet50_fpn_vaiq_int8.default.torch-onnx.mlir:1067:13: note: see current operation: %3130 = "torch.operator"(%2516, %3129, %0) <{name = "onnx.Pad"}> {torch.onnx.mode = "constant"} : (!torch.vtensor<[?,?,?],f32>, !torch.vtensor<[?],si64>, !torch.none) -> !torch.vtensor<[?,?,?],f32>
@PhaneeshB
Copy link
Contributor

PhaneeshB commented Apr 23, 2024

After this lands llvm/torch-mlir#3214

Next set of missing OPs :

    %1468 = torch.operator "onnx.Resize"(%1373, %none, %none, %1467) {torch.onnx.coordinate_transformation_mode = "half_pixel", torch.onnx.cubic_coeff_a = -7.500000e-01 : f32, torch.onnx.mode = "linear", torch.onnx.nearest_mode = "floor"} : (!torch.vtensor<[1,3,224,224],f32>, !torch.none, !torch.none, !torch.vtensor<[4],si64>) -> !torch.vtensor<[?,?,?,?],f32> 
    %6440 = torch.operator "onnx.Resize"(%6336, %none, %none, %6439) {torch.onnx.coordinate_transformation_mode = "asymmetric", torch.onnx.cubic_coeff_a = -7.500000e-01 : f32, torch.onnx.mode = "nearest", torch.onnx.nearest_mode = "floor"} : (!torch.vtensor<[1,256,?,?],f32>, !torch.none, !torch.none, !torch.vtensor<[4],si64>) -> !torch.vtensor<[?,?,?,?],f32> 
    %6569 = torch.operator "onnx.Resize"(%6465, %none, %none, %6568) {torch.onnx.coordinate_transformation_mode = "asymmetric", torch.onnx.cubic_coeff_a = -7.500000e-01 : f32, torch.onnx.mode = "nearest", torch.onnx.nearest_mode = "floor"} : (!torch.vtensor<[?,256,?,?],f32>, !torch.none, !torch.none, !torch.vtensor<[4],si64>) -> !torch.vtensor<[?,?,?,?],f32> 
    %13899 = torch.operator "onnx.If"(%13898) : (!torch.vtensor<[],i1>) -> !torch.vtensor<[?],si64> {...}
      %14077 = torch.operator "onnx.NonMaxSuppression"(%14070, %14074, %14075, %14076) : (!torch.vtensor<[1,?,?],f32>, !torch.vtensor<[1,1,?],f32>, !torch.vtensor<[1],si64>, !torch.vtensor<[1],f32>) -> !torch.vtensor<[?,3],si64> 

@vivekkhandelwal1
Copy link
Contributor

Hi @renxida, still getting the error for Onnx.If:

retinanet_resnet50_fpn_vaiq_int8.default.torch-onnx.mlir:6276:13: error: failed to legalize operation 'torch.operator' that was explicitly marked illegal
    %6272 = torch.operator "onnx.If"(%6271) : (!torch.vtensor<[],i1>) -> !torch.vtensor<[?],si64> {

@AmosLewis
Copy link
Collaborator Author

After Integrate torch-mlir@ec6d7aa onnx.resize op iree-org/iree#17358:
Still onnx.if failed.

retinanet_resnet50_fpn_vaiq_int8.default.torch-onnx.mlir:6276:13: error: failed to legalize operation 'torch.operator' that was explicitly marked illegal
    %6272 = torch.operator "onnx.If"(%6271) : (!torch.vtensor<[],i1>) -> !torch.vtensor<[?],si64> {
            ^
retinanet_resnet50_fpn_vaiq_int8.default.torch-onnx.mlir:6276:13: note: see current operation: 
%23747 = "torch.operator"(%23746) <{name = "onnx.If"}> ({
  %23822 = "torch.operator"(%23713) <{name = "onnx.ReduceMax"}> {torch.onnx.keepdims = 0 : si64} : (!torch.vtensor<[?,?],f32>) -> !torch.vtensor<[],f32>
  %23823 = "torch.operator"(%23721) <{name = "onnx.Cast"}> {torch.onnx.to = 1 : si64} : (!torch.vtensor<[?],si64>) -> !torch.vtensor<[?],f32>
  %23824 = "torch.operator"() <{name = "onnx.Constant"}> {torch.onnx.value = dense_resource<__3571> : tensor<f32>} : () -> !torch.vtensor<[],f32>
  %23825 = "torch.operator"(%23822, %23824) <{name = "onnx.Add"}> : (!torch.vtensor<[],f32>, !torch.vtensor<[],f32>) -> !torch.vtensor<[],f32>
  %23826 = "torch.operator"(%23823, %23825) <{name = "onnx.Mul"}> : (!torch.vtensor<[?],f32>, !torch.vtensor<[],f32>) -> !torch.vtensor<[?],f32>
  %23827 = "torch.operator"() <{name = "onnx.Constant"}> {torch.onnx.value = dense_resource<__3572> : tensor<1xsi64>} : () -> !torch.vtensor<[1],si64>
  %23828 = "torch.operator"(%23826, %23827) <{name = "onnx.Unsqueeze"}> : (!torch.vtensor<[?],f32>, !torch.vtensor<[1],si64>) -> !torch.vtensor<[?,1],f32>
  %23829 = "torch.operator"(%23713, %23828) <{name = "onnx.Add"}> : (!torch.vtensor<[?,?],f32>, !torch.vtensor<[?,1],f32>) -> !torch.vtensor<[?,?],f32>
  %23830 = "torch.operator"() <{name = "onnx.Constant"}> {torch.onnx.value = dense_resource<__3573> : tensor<1xsi64>} : () -> !torch.vtensor<[1],si64>
  %23831 = "torch.operator"(%23829, %23830) <{name = "onnx.Unsqueeze"}> : (!torch.vtensor<[?,?],f32>, !torch.vtensor<[1],si64>) -> !torch.vtensor<[1,?,?],f32>
  %23832 = "torch.operator"() <{name = "onnx.Constant"}> {torch.onnx.value = dense_resource<__3574> : tensor<1xsi64>} : () -> !torch.vtensor<[1],si64>
  %23833 = "torch.operator"(%23717, %23832) <{name = "onnx.Unsqueeze"}> : (!torch.vtensor<[?],f32>, !torch.vtensor<[1],si64>) -> !torch.vtensor<[1,?],f32>
  %23834 = "torch.operator"() <{name = "onnx.Constant"}> {torch.onnx.value = dense_resource<__3575> : tensor<1xsi64>} : () -> !torch.vtensor<[1],si64>
  %23835 = "torch.operator"(%23833, %23834) <{name = "onnx.Unsqueeze"}> : (!torch.vtensor<[1,?],f32>, !torch.vtensor<[1],si64>) -> !torch.vtensor<[1,1,?],f32>
  %23836 = "torch.operator"() <{name = "onnx.Constant"}> {torch.onnx.value = dense_resource<__3576> : tensor<1xsi64>} : () -> !torch.vtensor<[1],si64>
  %23837 = "torch.operator"() <{name = "onnx.Constant"}> {torch.onnx.value = dense_resource<__3577> : tensor<1xf32>} : () -> !torch.vtensor<[1],f32>
  %23838 = "torch.operator"(%23831, %23835, %23836, %23837) <{name = "onnx.NonMaxSuppression"}> : (!torch.vtensor<[1,?,?],f32>, !torch.vtensor<[1,1,?],f32>, !torch.vtensor<[1],si64>, !torch.vtensor<[1],f32>) -> !torch.vtensor<[?,3],si64>
  %23839 = "torch.operator"() <{name = "onnx.Constant"}> {torch.onnx.value = dense_resource<__3578> : tensor<1xsi64>} : () -> !torch.vtensor<[1],si64>
  %23840 = "torch.operator"(%23838, %23839) <{name = "onnx.Gather"}> {torch.onnx.axis = 1 : si64} : (!torch.vtensor<[?,3],si64>, !torch.vtensor<[1],si64>) -> !torch.vtensor<[?,1],si64>
  %23841 = "torch.operator"() <{name = "onnx.Constant"}> {torch.onnx.value = dense_resource<__3579> : tensor<1xsi64>} : () -> !torch.vtensor<[1],si64>
  %23842 = "torch.operator"(%23840, %23841) <{name = "onnx.Squeeze"}> : (!torch.vtensor<[?,1],si64>, !torch.vtensor<[1],si64>) -> !torch.vtensor<[?],si64>
  "torch.operator_terminator"(%23842) : (!torch.vtensor<[?],si64>) -> ()
}, {
  %23821 = "torch.operator"() <{name = "onnx.Constant"}> {torch.onnx.value = dense_resource<__3580> : tensor<0xsi64>} : () -> !torch.vtensor<[0],si64>
  "torch.operator_terminator"(%23821) : (!torch.vtensor<[0],si64>) -> ()
}) : (!torch.vtensor<[],i1>) -> !torch.vtensor<[?],si64>

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

No branches or pull requests

4 participants