2019-06-25 05:35:21 +08:00
|
|
|
// RUN: mlir-opt %s -split-input-file -verify-diagnostics | FileCheck %s
|
2019-05-25 07:17:52 +08:00
|
|
|
|
2019-08-29 02:25:19 +08:00
|
|
|
// CHECK: succeededSameOperandsElementType
|
2019-10-06 01:05:40 +08:00
|
|
|
func @succeededSameOperandsElementType(%t10x10 : tensor<10x10xf32>, %t1f: tensor<1xf32>, %v1: vector<1xf32>, %t1i: tensor<1xi32>, %sf: f32) {
|
2019-10-10 17:31:21 +08:00
|
|
|
"test.same_operand_element_type"(%t1f, %t1f) : (tensor<1xf32>, tensor<1xf32>) -> tensor<1xi32>
|
|
|
|
"test.same_operand_element_type"(%t1f, %t10x10) : (tensor<1xf32>, tensor<10x10xf32>) -> tensor<1xi32>
|
|
|
|
"test.same_operand_element_type"(%t10x10, %v1) : (tensor<10x10xf32>, vector<1xf32>) -> tensor<1xi32>
|
|
|
|
"test.same_operand_element_type"(%v1, %t1f) : (vector<1xf32>, tensor<1xf32>) -> tensor<1xi32>
|
|
|
|
"test.same_operand_element_type"(%v1, %t1f) : (vector<1xf32>, tensor<1xf32>) -> tensor<121xi32>
|
|
|
|
"test.same_operand_element_type"(%sf, %sf) : (f32, f32) -> i32
|
|
|
|
"test.same_operand_element_type"(%sf, %t1f) : (f32, tensor<1xf32>) -> tensor<121xi32>
|
|
|
|
"test.same_operand_element_type"(%sf, %v1) : (f32, vector<1xf32>) -> tensor<121xi32>
|
|
|
|
"test.same_operand_element_type"(%sf, %t10x10) : (f32, tensor<10x10xf32>) -> tensor<121xi32>
|
2019-08-29 02:25:19 +08:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
2019-10-06 01:00:11 +08:00
|
|
|
func @failedSameOperandElementType(%t1f: tensor<1xf32>, %t1i: tensor<1xi32>) {
|
2019-08-29 02:25:19 +08:00
|
|
|
// expected-error@+1 {{requires the same element type for all operands}}
|
2019-10-10 17:31:21 +08:00
|
|
|
"test.same_operand_element_type"(%t1f, %t1i) : (tensor<1xf32>, tensor<1xi32>) -> tensor<1xf32>
|
2019-10-06 01:00:11 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
|
|
|
func @failedSameOperandAndResultElementType_no_operands() {
|
|
|
|
// expected-error@+1 {{expected 1 or more operands}}
|
2019-10-10 17:31:21 +08:00
|
|
|
"test.same_operand_element_type"() : () -> tensor<1xf32>
|
2019-08-29 02:25:19 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
2019-10-06 01:05:40 +08:00
|
|
|
func @failedSameOperandElementType_scalar_type_mismatch(%si: i32, %sf: f32) {
|
|
|
|
// expected-error@+1 {{requires the same element type for all operands}}
|
2019-10-10 17:31:21 +08:00
|
|
|
"test.same_operand_element_type"(%sf, %si) : (f32, i32) -> tensor<1xf32>
|
2019-10-06 01:05:40 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
2019-05-25 07:17:52 +08:00
|
|
|
// CHECK: succeededSameOperandAndResultElementType
|
2019-10-06 01:05:40 +08:00
|
|
|
func @succeededSameOperandAndResultElementType(%t10x10 : tensor<10x10xf32>, %t1f: tensor<1xf32>, %v1: vector<1xf32>, %t1i: tensor<1xi32>, %sf: f32) {
|
2019-10-10 17:31:21 +08:00
|
|
|
"test.same_operand_and_result_element_type"(%t1f, %t1f) : (tensor<1xf32>, tensor<1xf32>) -> tensor<1xf32>
|
|
|
|
"test.same_operand_and_result_element_type"(%t1f, %t10x10) : (tensor<1xf32>, tensor<10x10xf32>) -> tensor<1xf32>
|
|
|
|
"test.same_operand_and_result_element_type"(%t10x10, %v1) : (tensor<10x10xf32>, vector<1xf32>) -> tensor<1xf32>
|
|
|
|
"test.same_operand_and_result_element_type"(%v1, %t1f) : (vector<1xf32>, tensor<1xf32>) -> tensor<1xf32>
|
|
|
|
"test.same_operand_and_result_element_type"(%v1, %t1f) : (vector<1xf32>, tensor<1xf32>) -> tensor<121xf32>
|
|
|
|
"test.same_operand_and_result_element_type"(%sf, %sf) : (f32, f32) -> f32
|
|
|
|
"test.same_operand_and_result_element_type"(%sf, %t1f) : (f32, tensor<1xf32>) -> tensor<121xf32>
|
|
|
|
"test.same_operand_and_result_element_type"(%sf, %v1) : (f32, vector<1xf32>) -> tensor<121xf32>
|
|
|
|
"test.same_operand_and_result_element_type"(%sf, %t10x10) : (f32, tensor<10x10xf32>) -> tensor<121xf32>
|
2019-05-25 07:17:52 +08:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
2019-10-06 01:00:11 +08:00
|
|
|
func @failedSameOperandAndResultElementType_operand_result_mismatch(%t1f: tensor<1xf32>) {
|
2019-05-25 07:17:52 +08:00
|
|
|
// expected-error@+1 {{requires the same element type for all operands and results}}
|
2019-10-10 17:31:21 +08:00
|
|
|
"test.same_operand_and_result_element_type"(%t1f, %t1f) : (tensor<1xf32>, tensor<1xf32>) -> tensor<1xi32>
|
2019-05-25 07:17:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
2019-10-06 01:00:11 +08:00
|
|
|
func @failedSameOperandAndResultElementType_operand_mismatch(%t1f: tensor<1xf32>, %t1i: tensor<1xi32>) {
|
2019-05-25 07:17:52 +08:00
|
|
|
// expected-error@+1 {{requires the same element type for all operands and results}}
|
2019-10-10 17:31:21 +08:00
|
|
|
"test.same_operand_and_result_element_type"(%t1f, %t1i) : (tensor<1xf32>, tensor<1xi32>) -> tensor<1xf32>
|
2019-05-25 07:17:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
2019-10-06 01:05:40 +08:00
|
|
|
func @failedSameOperandAndResultElementType_result_mismatch(%t1f: tensor<1xf32>) {
|
|
|
|
// expected-error@+1 {{requires the same element type for all operands and results}}
|
|
|
|
%0:2 = "test.same_operand_and_result_element_type"(%t1f) : (tensor<1xf32>) -> (tensor<1xf32>, tensor<1xi32>)
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
2019-10-06 01:00:11 +08:00
|
|
|
func @failedSameOperandAndResultElementType_no_operands() {
|
2019-10-01 15:56:38 +08:00
|
|
|
// expected-error@+1 {{expected 1 or more operands}}
|
2019-10-10 17:31:21 +08:00
|
|
|
"test.same_operand_and_result_element_type"() : () -> tensor<1xf32>
|
2019-10-01 15:56:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
2019-10-06 01:00:11 +08:00
|
|
|
func @failedSameOperandAndResultElementType_no_results(%t1f: tensor<1xf32>) {
|
2019-10-01 15:56:38 +08:00
|
|
|
// expected-error@+1 {{expected 1 or more results}}
|
2019-10-06 01:00:11 +08:00
|
|
|
"test.same_operand_and_result_element_type"(%t1f) : (tensor<1xf32>) -> ()
|
2019-10-01 15:56:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
2019-08-29 02:25:19 +08:00
|
|
|
// CHECK: succeededSameOperandShape
|
2019-10-10 17:31:21 +08:00
|
|
|
func @succeededSameOperandShape(%t10x10 : tensor<10x10xf32>, %t1: tensor<1xf32>, %m10x10 : memref<10x10xi32>, %tr: tensor<*xf32>) {
|
|
|
|
"test.same_operand_shape"(%t1, %t1) : (tensor<1xf32>, tensor<1xf32>) -> ()
|
|
|
|
"test.same_operand_shape"(%t10x10, %t10x10) : (tensor<10x10xf32>, tensor<10x10xf32>) -> ()
|
|
|
|
"test.same_operand_shape"(%t1, %tr) : (tensor<1xf32>, tensor<*xf32>) -> ()
|
|
|
|
"test.same_operand_shape"(%t10x10, %m10x10) : (tensor<10x10xf32>, memref<10x10xi32>) -> ()
|
2019-08-29 02:25:19 +08:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
2019-10-06 01:00:11 +08:00
|
|
|
func @failedSameOperandShape_operand_mismatch(%t10x10 : tensor<10x10xf32>, %t1: tensor<1xf32>) {
|
2019-08-29 02:25:19 +08:00
|
|
|
// expected-error@+1 {{requires the same shape for all operands}}
|
2019-10-10 17:31:21 +08:00
|
|
|
"test.same_operand_shape"(%t1, %t10x10) : (tensor<1xf32>, tensor<10x10xf32>) -> ()
|
2019-08-29 02:25:19 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
2019-10-06 01:00:11 +08:00
|
|
|
func @failedSameOperandShape_no_operands() {
|
2019-10-01 15:56:38 +08:00
|
|
|
// expected-error@+1 {{expected 1 or more operands}}
|
2019-10-10 17:31:21 +08:00
|
|
|
"test.same_operand_shape"() : () -> ()
|
2019-10-01 15:56:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
2019-05-25 07:17:52 +08:00
|
|
|
// CHECK: succeededSameOperandAndResultShape
|
2019-10-09 10:36:37 +08:00
|
|
|
func @succeededSameOperandAndResultShape(%t10x10 : tensor<10x10xf32>, %t1: tensor<1xf32>, %tr: tensor<*xf32>, %t1d: tensor<?xf32>) {
|
2019-10-10 17:31:21 +08:00
|
|
|
"test.same_operand_and_result_shape"(%t1, %t1) : (tensor<1xf32>, tensor<1xf32>) -> tensor<1xf32>
|
|
|
|
"test.same_operand_and_result_shape"(%t10x10, %t10x10) : (tensor<10x10xf32>, tensor<10x10xf32>) -> tensor<10x10xf32>
|
|
|
|
"test.same_operand_and_result_shape"(%t1, %tr) : (tensor<1xf32>, tensor<*xf32>) -> tensor<1xf32>
|
|
|
|
"test.same_operand_and_result_shape"(%t1, %t1d) : (tensor<1xf32>, tensor<?xf32>) -> tensor<1xf32>
|
|
|
|
"test.same_operand_and_result_shape"(%t1, %t1d) : (tensor<1xf32>, tensor<?xf32>) -> memref<1xf32>
|
|
|
|
|
2019-05-25 07:17:52 +08:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
2019-10-06 01:00:11 +08:00
|
|
|
func @failedSameOperandAndResultShape_operand_result_mismatch(%t10x10 : tensor<10x10xf32>, %t1: tensor<1xf32>) {
|
2019-05-25 07:17:52 +08:00
|
|
|
// expected-error@+1 {{requires the same shape for all operands and results}}
|
2019-10-10 17:31:21 +08:00
|
|
|
"test.same_operand_and_result_shape"(%t1, %t10x10) : (tensor<1xf32>, tensor<10x10xf32>) -> tensor<10x10xf32>
|
2019-05-25 07:17:52 +08:00
|
|
|
}
|
2019-07-30 01:45:17 +08:00
|
|
|
|
|
|
|
// -----
|
|
|
|
|
2019-10-06 01:00:11 +08:00
|
|
|
func @failedSameOperandAndResultShape_no_operands() {
|
2019-10-01 15:56:38 +08:00
|
|
|
// expected-error@+1 {{expected 1 or more operands}}
|
2019-10-10 17:31:21 +08:00
|
|
|
"test.same_operand_and_result_shape"() : () -> (tensor<1xf32>)
|
2019-10-01 15:56:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
2019-10-06 01:00:11 +08:00
|
|
|
func @failedSameOperandAndResultShape_no_operands(%t1: tensor<1xf32>) {
|
2019-10-01 15:56:38 +08:00
|
|
|
// expected-error@+1 {{expected 1 or more results}}
|
|
|
|
"test.same_operand_and_result_shape"(%t1) : (tensor<1xf32>) -> ()
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
2019-10-09 10:36:37 +08:00
|
|
|
// CHECK: succeededSameOperandAndResultType
|
2019-10-10 17:31:21 +08:00
|
|
|
func @succeededSameOperandAndResultType(%t10x10 : tensor<10x10xf32>, %t1: tensor<1xf32>, %tr: tensor<*xf32>, %t1d: tensor<?xf32>, %i32 : i32) {
|
|
|
|
"test.same_operand_and_result_type"(%t1, %t1) : (tensor<1xf32>, tensor<1xf32>) -> tensor<1xf32>
|
|
|
|
"test.same_operand_and_result_type"(%t10x10, %t10x10) : (tensor<10x10xf32>, tensor<10x10xf32>) -> tensor<10x10xf32>
|
|
|
|
"test.same_operand_and_result_type"(%t1, %tr) : (tensor<1xf32>, tensor<*xf32>) -> tensor<1xf32>
|
|
|
|
"test.same_operand_and_result_type"(%t1, %t1d) : (tensor<1xf32>, tensor<?xf32>) -> tensor<1xf32>
|
|
|
|
"test.same_operand_and_result_type"(%i32, %i32) : (i32, i32) -> i32
|
2019-10-09 10:36:37 +08:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
|
|
|
func @failedSameOperandAndResultType_operand_result_mismatch(%t10 : tensor<10xf32>, %t20 : tensor<20xf32>) {
|
|
|
|
// expected-error@+1 {{requires the same type for all operands and results}}
|
2019-10-10 17:31:21 +08:00
|
|
|
"test.same_operand_and_result_type"(%t10, %t20) : (tensor<10xf32>, tensor<20xf32>) -> tensor<10xf32>
|
2019-10-09 10:36:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
2019-10-06 01:00:11 +08:00
|
|
|
func @failedHasParent_wrong_parent() {
|
2019-07-30 01:45:17 +08:00
|
|
|
"some.op"() ({
|
|
|
|
// expected-error@+1 {{'test.child' op expects parent op 'test.parent'}}
|
|
|
|
"test.child"() : () -> ()
|
|
|
|
}) : () -> ()
|
|
|
|
}
|
|
|
|
|
2019-07-30 02:21:55 +08:00
|
|
|
// -----
|
|
|
|
|
2019-10-06 01:00:11 +08:00
|
|
|
func @failedSingleBlockImplicitTerminator_empty_block() {
|
2019-07-30 02:21:55 +08:00
|
|
|
// expected-error@+1 {{'test.SingleBlockImplicitTerminator' op expects a non-empty block}}
|
|
|
|
"test.SingleBlockImplicitTerminator"() ({
|
|
|
|
^entry:
|
|
|
|
}) : () -> ()
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
2019-10-06 01:00:11 +08:00
|
|
|
func @failedSingleBlockImplicitTerminator_too_many_blocks() {
|
2019-07-30 02:21:55 +08:00
|
|
|
// expected-error@+1 {{'test.SingleBlockImplicitTerminator' op expects region #0 to have 0 or 1 block}}
|
|
|
|
"test.SingleBlockImplicitTerminator"() ({
|
|
|
|
^entry:
|
|
|
|
"test.finish" () : () -> ()
|
|
|
|
^other:
|
|
|
|
"test.finish" () : () -> ()
|
|
|
|
}) : () -> ()
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
2019-10-06 01:00:11 +08:00
|
|
|
func @failedSingleBlockImplicitTerminator_missing_terminator() {
|
2019-07-30 02:21:55 +08:00
|
|
|
// expected-error@+2 {{'test.SingleBlockImplicitTerminator' op expects regions to end with 'test.finish'}}
|
|
|
|
// expected-note@+1 {{in custom textual format, the absence of terminator implies 'test.finish'}}
|
|
|
|
"test.SingleBlockImplicitTerminator"() ({
|
|
|
|
^entry:
|
|
|
|
"test.non_existent_op"() : () -> ()
|
|
|
|
}) : () -> ()
|
|
|
|
}
|
|
|
|
|
2019-11-01 00:49:16 +08:00
|
|
|
// -----
|
|
|
|
|
|
|
|
// Test that operation with the SymbolTable Trait define a new symbol scope.
|
|
|
|
"test.symbol_scope"() ({
|
|
|
|
func @foo() {
|
|
|
|
}
|
|
|
|
"test.finish" () : () -> ()
|
|
|
|
}) : () -> ()
|
|
|
|
func @foo() {
|
|
|
|
}
|