1 // RUN: mlir-opt -allow-unregistered-dialect %s -split-input-file -verify-diagnostics
3 func.func @illegaltype(i) // expected-error {{expected non-function type}}
7 func.func @illegaltype() {
8 %0 = arith.constant dense<0> : <vector 4 x f32> : vector<4 x f32> // expected-error {{expected non-function type}}
13 func.func @nestedtensor(tensor<tensor<i8>>) -> () // expected-error {{invalid tensor element type}}
17 // expected-error@+1 {{invalid dimension}}
18 #large_dim = tensor<9223372036854775808xf32>
22 func.func @illegalmemrefelementtype(memref<?xtensor<i8>>) -> () // expected-error {{invalid memref element type}}
26 func.func @illegalunrankedmemrefelementtype(memref<*xtensor<i8>>) -> () // expected-error {{invalid memref element type}}
29 // Test no map in memref type.
30 func.func @memrefs(memref<2x4xi8, >) // expected-error {{expected list element}}
33 // Test non-existent map in memref type.
34 func.func @memrefs(memref<2x4xi8, #map7>) // expected-error {{undefined symbol alias id 'map7'}}
37 // Test unsupported memory space.
38 func.func @memrefs(memref<2x4xi8, i8>) // expected-error {{unsupported memory space Attribute}}
41 // Test non-existent map in map composition of memref type.
42 #map0 = affine_map<(d0, d1) -> (d0, d1)>
44 func.func @memrefs(memref<2x4xi8, #map0, #map8>) // expected-error {{undefined symbol alias id 'map8'}}
47 // Test multiple memory space error.
48 #map0 = affine_map<(d0, d1) -> (d0, d1)>
49 func.func @memrefs(memref<2x4xi8, #map0, 1, 2>) // expected-error {{multiple memory spaces specified in memref type}}
52 // Test affine map after memory space.
53 #map0 = affine_map<(d0, d1) -> (d0, d1)>
54 #map1 = affine_map<(d0, d1) -> (d0, d1)>
56 func.func @memrefs(memref<2x4xi8, #map0, 1, #map1>) // expected-error {{expected memory space to be last in memref type}}
59 // Test dimension mismatch between memref and layout map.
60 // The error must be emitted even for the trivial identity layout maps that are
61 // dropped in type creation.
62 #map0 = affine_map<(d0, d1) -> (d0, d1)>
63 func.func @memrefs(memref<42xi8, #map0>) // expected-error {{memref layout mismatch between rank and affine map: 1 != 2}}
67 // expected-error @below {{expected '<' after 'strided'}}
68 func.func private @memref_unfinished_strided() -> memref<?x?xf32, strided>
72 // expected-error @below {{expected '['}}
73 func.func private @memref_unfinished_strided() -> memref<?x?xf32, strided<>>
77 // expected-error @below {{expected a 64-bit signed integer or '?'}}
78 func.func private @memref_unfinished_stride_list() -> memref<?x?xf32, strided<[>>
82 // expected-error @below {{expected 'offset' after comma}}
83 func.func private @memref_missing_offset() -> memref<?x?xf32, strided<[], >>
87 // expected-error @below {{expected ':' after 'offset'}}
88 func.func private @memref_missing_offset_colon() -> memref<?x?xf32, strided<[], offset>>
92 // expected-error @below {{expected a 64-bit signed integer or '?'}}
93 func.func private @memref_missing_offset_value() -> memref<?x?xf32, strided<[], offset: >>
97 // expected-error @below {{expected '>'}}
98 func.func private @memref_incorrect_strided_ending() -> memref<?x?xf32, strided<[], offset: 32)>
102 // expected-error @below {{strides must not be zero}}
103 func.func private @memref_zero_stride() -> memref<?x?xf32, strided<[0, 0]>>
107 // expected-error @below {{expected the number of strides to match the rank}}
108 func.func private @memref_strided_rank_mismatch() -> memref<?x?xf32, strided<[1]>>
112 func.func @tensor_encoding_mismatch(%arg0: tensor<8xi32, "enc">) -> (tensor<8xi32>) { // expected-note {{prior use here}}
113 return %arg0: tensor<8xi32> // expected-error {{use of value '%arg0' expects different type than prior uses: 'tensor<8xi32>' vs 'tensor<8xi32, "enc">'}}
118 func.func @illegaltype(i21312312323120) // expected-error {{invalid integer width}}
122 // Test no nested vector.
123 // expected-error@+1 {{failed to verify 'elementType': integer or index or floating-point}}
124 func.func @vectors(vector<1 x vector<1xi32>>, vector<2x4xf32>)
128 // expected-error @+1 {{vector types must have positive constant sizes but got 0}}
129 func.func @zero_vector_type() -> vector<0xi32>
133 // expected-error @+1 {{vector types must have positive constant sizes but got 1, 0}}
134 func.func @zero_in_vector_type() -> vector<1x0xi32>
138 // expected-error @+1 {{expected non-function type}}
139 func.func @negative_vector_size() -> vector<-1xi32>
143 // expected-error @+1 {{expected non-function type}}
144 func.func @negative_in_vector_size() -> vector<1x-1xi32>
148 // expected-error @+1 {{expected non-function type}}
149 func.func @negative_memref_size() -> memref<-1xi32>
153 // expected-error @+1 {{expected non-function type}}
154 func.func @negative_in_memref_size() -> memref<1x-1xi32>
158 // expected-error @+1 {{expected non-function type}}
159 func.func @negative_tensor_size() -> tensor<-1xi32>
163 // expected-error @+1 {{expected non-function type}}
164 func.func @negative_in_tensor_size() -> tensor<1x-1xi32>
168 // expected-error @+1 {{invalid element type for complex}}
169 func.func @bad_complex(complex<memref<2x4xi8>>)
173 // expected-error @+1 {{expected '<' in complex type}}
174 func.func @bad_complex(complex memref<2x4xi8>>)
178 // expected-error @+1 {{expected '>' in complex type}}
179 func.func @bad_complex(complex<i32)