Last active
December 27, 2023 15:30
-
-
Save renxida/8a9f23c20c473a23ca36712e777652b7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// RUN: torch-mlir-opt <%s -split-input-file -verify-diagnostics -convert-torch-onnx-to-torch | |
// FB OPT OPS from https://github.com/llvm/torch-mlir/issues/2689 | |
// ----- | |
func.func @cast_operation(%arg0: !torch.vtensor<[?,?,?,?],si64>) -> !torch.vtensor<[?,?,?,?],f32> attributes {torch.onnx_meta.ir_version = 9 : si64, torch.onnx_meta.opset_version = 18 : si64, torch.onnx_meta.producer_name = "backend-test", torch.onnx_meta.producer_version = ""} { | |
// expected-error @+1 {{failed to legalize operation 'torch.operator'}} | |
%208 = torch.operator "onnx.Cast"(%arg0) { | |
torch.onnx.to = 1 : si64 | |
} : (!torch.vtensor<[?,?,?,?],si64>) -> !torch.vtensor<[?,?,?,?],f32> | |
return %208 : !torch.vtensor<[?,?,?,?],f32> | |
} | |
// ----- | |
func.func @div_operation(%arg0: !torch.vtensor<[1,64,768],f32>, | |
%arg1: !torch.vtensor<[1,64,1],f32>) | |
-> !torch.vtensor<[1,64,768],f32> attributes {torch.onnx_meta.ir_version = 9 : si64, torch.onnx_meta.opset_version = 18 : si64, torch.onnx_meta.producer_name = "backend-test", torch.onnx_meta.producer_version = ""} { | |
%209 = torch.operator "onnx.Div"(%arg0, %arg1) : (!torch.vtensor<[1,64,768],f32>, !torch.vtensor<[1,64,1],f32>) -> !torch.vtensor<[1,64,768],f32> | |
return %209 : !torch.vtensor<[1,64,768],f32> | |
} | |
// ----- | |
func.func @equal_operation(%arg0: !torch.vtensor<[4],si64>, | |
%arg1: !torch.vtensor<[4],si64>) | |
-> !torch.vtensor<[4],i1> attributes {torch.onnx_meta.ir_version = 9 : si64, torch.onnx_meta.opset_version = 18 : si64, torch.onnx_meta.producer_name = "backend-test", torch.onnx_meta.producer_version = ""} { | |
// expected-error @+1 {{failed to legalize operation 'torch.operator'}} | |
%205 = torch.operator "onnx.Equal"(%arg0, %arg1) : (!torch.vtensor<[4],si64>, !torch.vtensor<[4],si64>) -> !torch.vtensor<[4],i1> | |
return %205 : !torch.vtensor<[4],i1> | |
} | |
// ----- | |
func.func @reduce_mean_operation(%arg0: !torch.vtensor<[1,64,768],f32>) | |
-> !torch.vtensor<[1,64,1],f32> attributes {torch.onnx_meta.ir_version = 9 : si64, torch.onnx_meta.opset_version = 18 : si64, torch.onnx_meta.producer_name = "backend-test", torch.onnx_meta.producer_version = ""} { | |
// The ReduceMean operation as provided. | |
// expected-error @+1 {{failed to legalize operation 'torch.operator'}} | |
%211 = torch.operator "onnx.ReduceMean"(%arg0) {torch.onnx.axes = [-1 : si64]} : (!torch.vtensor<[1,64,768],f32>) -> !torch.vtensor<[1,64,1],f32> | |
return %211 : !torch.vtensor<[1,64,1],f32> | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment