2021-10-08 10:07:03 +08:00
|
|
|
// RUN: torch-mlir-opt -torch-verify-tosa-backend-contract -split-input-file -verify-diagnostics -allow-unregistered-dialect %s | FileCheck %s
|
|
|
|
|
2022-05-17 03:54:35 +08:00
|
|
|
// CHECK: func.func @tanh
|
|
|
|
func.func @tanh(%arg0: tensor<?x?xf32>) -> tensor<?x?xf32> {
|
2023-09-13 06:09:57 +08:00
|
|
|
%0 = tosa.tanh %arg0 : (tensor<?x?xf32>) -> tensor<?x?xf32>
|
2021-10-08 10:07:03 +08:00
|
|
|
return %0 : tensor<?x?xf32>
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
|
|
|
// Basic check of error reporting.
|
|
|
|
|
|
|
|
// expected-error@+1 {{Module does not conform to the TOSA backend contract.}}
|
|
|
|
module {
|
2022-05-17 03:54:35 +08:00
|
|
|
func.func @disallowed() {
|
2021-10-08 10:07:03 +08:00
|
|
|
// expected-error@+1 {{failed to legalize operation 'unknown_dialect.unknown_op'}}
|
|
|
|
"unknown_dialect.unknown_op"() : () -> ()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
|
|
|
// TODO: Improve these errors to give more exact reporting.
|
|
|
|
//
|
|
|
|
// The reporting we inherit from dialect conversion is not precise.
|
|
|
|
// For example, here we want it to explicitly call out that
|
|
|
|
// `!torch.tensor` is the problem here, which suggests
|
|
|
|
// that type inference didn't succeed, or insufficient type information
|
|
|
|
// was available.
|
|
|
|
//
|
|
|
|
// Ultimately, the output of this pass needs to be conveyed to the user
|
|
|
|
// in an understandable way, such as suggesting a particular place where
|
|
|
|
// a shape annotation is needed.
|
|
|
|
|
|
|
|
// expected-error@+1 {{Module does not conform to the TOSA backend contract.}}
|
|
|
|
module {
|
2022-05-17 03:54:35 +08:00
|
|
|
func.func @disallowed(%arg0: !torch.tensor) -> !torch.tensor {
|
2022-03-16 18:44:23 +08:00
|
|
|
// expected-error@+1 {{failed to legalize operation 'func.return'}}
|
2021-10-08 10:07:03 +08:00
|
|
|
return %arg0 : !torch.tensor
|
|
|
|
}
|
|
|
|
}
|