invalid.mlir
2.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
// RUN: mlir-opt -split-input-file %s -verify-diagnostics
// CHECK-LABEL: test_index_cast_shape_error
func @test_index_cast_shape_error(%arg0 : tensor<index>) -> tensor<2xi64> {
// expected-error @+1 {{requires the same shape for all operands and results}}
%0 = index_cast %arg0 : tensor<index> to tensor<2xi64>
return %0 : tensor<2xi64>
}
// -----
// CHECK-LABEL: test_index_cast_tensor_error
func @test_index_cast_tensor_error(%arg0 : tensor<index>) -> i64 {
// expected-error @+1 {{requires the same shape for all operands and results}}
%0 = index_cast %arg0 : tensor<index> to i64
return %0 : i64
}
// -----
func @dynamic_tensor_from_elements(%m : index)
-> tensor<?x3x?xf32> {
// expected-error @+1 {{must have as many index operands as dynamic extents in the result type}}
%tnsr = dynamic_tensor_from_elements %m {
^bb0(%i : index, %j : index, %k : index):
%elem = constant 8.0 : f32
yield %elem : f32
} : tensor<?x3x?xf32>
return %tnsr : tensor<?x3x?xf32>
}
// -----
func @dynamic_tensor_from_elements(%m : index, %n : index)
-> tensor<?x3x?xf32> {
// expected-error @+1 {{must have one body argument per input dimension}}
%tnsr = dynamic_tensor_from_elements %m, %n {
^bb0(%i : index, %j : index):
%elem = constant 8.0 : f32
yield %elem : f32
} : tensor<?x3x?xf32>
return %tnsr : tensor<?x3x?xf32>
}
// -----
func @dynamic_tensor_from_elements(%m : index, %n : index)
-> tensor<?x3x?xf32> {
// expected-error @+1 {{all body arguments must be index}}
%tnsr = dynamic_tensor_from_elements %m, %n {
^bb0(%i : index, %j : index, %k : i64):
%elem = constant 8.0 : f32
yield %elem : f32
} : tensor<?x3x?xf32>
return %tnsr : tensor<?x3x?xf32>
}
// -----
func @dynamic_tensor_from_elements(%m : index, %n : index)
-> tensor<?x3x?xf32> {
// expected-error @+2 {{op expects regions to end with 'std.yield', found 'std.return'}}
// expected-note @+1 {{in custom textual format, the absence of terminator implies 'std.yield'}}
%tnsr = dynamic_tensor_from_elements %m, %n {
^bb0(%i : index, %j : index, %k : index):
%elem = constant 8.0 : f32
return %elem : f32
} : tensor<?x3x?xf32>
return %tnsr : tensor<?x3x?xf32>
}
// -----
func @dynamic_tensor_from_elements(%m : index, %n : index)
-> tensor<?x3x?xf32> {
// expected-error @+1 {{body must be terminated with a `yield` operation of the tensor element type}}
%tnsr = dynamic_tensor_from_elements %m, %n {
^bb0(%i : index, %j : index, %k : index):
%elem = constant 8 : i32
yield %elem : i32
} : tensor<?x3x?xf32>
return %tnsr : tensor<?x3x?xf32>
}