Stella Laurenzo | 44c4187 | 2022-01-19 19:39:08 -0800 | [diff] [blame] | 1 | // RUN: iree-dialects-opt -split-input-file -verify-diagnostics %s |
| 2 | |
| 3 | func @sort_invalid_dimension(%arg0: tensor<128xi32>) -> tensor<128xi32> { |
| 4 | // expected-error @+1 {{dimension must be within (0, 1]}} |
| 5 | %0 = iree_linalg_ext.sort dimension(1) |
| 6 | outs(%arg0 : tensor<128xi32>) { |
| 7 | ^bb0(%arg1: i32, %arg2: i32): // no predecessors |
| 8 | %1 = arith.cmpi sgt, %arg1, %arg2 : i32 |
| 9 | iree_linalg_ext.yield %1 : i1 |
| 10 | } -> tensor<128xi32> |
| 11 | return %0 : tensor<128xi32> |
| 12 | } |
| 13 | |
| 14 | // ----- |
| 15 | |
Stella Laurenzo | 44c4187 | 2022-01-19 19:39:08 -0800 | [diff] [blame] | 16 | func @sort_mismatch_rank(%arg0: tensor<?x?xi32>, %arg1: tensor<?xf32>) |
| 17 | -> (tensor<?x?xi32>, tensor<?xf32>) { |
| 18 | // expected-error @+1 {{expected operand 1 to be rank 2, same as other operands}} |
| 19 | %0:2 = iree_linalg_ext.sort dimension(0) |
| 20 | outs(%arg0, %arg1 : tensor<?x?xi32>, tensor<?xf32>) { |
| 21 | ^bb0(%arg2: i32, %arg3: i32, %arg4 : f32, %arg5 : f32): // no predecessors |
| 22 | %1 = arith.cmpf ogt, %arg4, %arg5 : f32 |
| 23 | iree_linalg_ext.yield %1 : i1 |
| 24 | } -> tensor<?x?xi32>, tensor<?xf32> |
| 25 | return %0#0, %0#1 : tensor<?x?xi32>, tensor<?xf32> |
| 26 | } |
| 27 | |
| 28 | // ----- |
| 29 | |
| 30 | func @sort_mismatch_shape(%arg0: tensor<?xi32>, %arg1: tensor<42xf32>) |
| 31 | -> (tensor<?xi32>, tensor<42xf32>) { |
| 32 | // expected-error @+1 {{expected operand 1 to have same shape as other operands}} |
| 33 | %0:2 = iree_linalg_ext.sort dimension(0) |
| 34 | outs(%arg0, %arg1 : tensor<?xi32>, tensor<42xf32>) { |
| 35 | ^bb0(%arg2: i32, %arg3: i32, %arg4 : f32, %arg5 : f32): // no predecessors |
| 36 | %1 = arith.cmpf ogt, %arg4, %arg5 : f32 |
| 37 | iree_linalg_ext.yield %1 : i1 |
| 38 | } -> tensor<?xi32>, tensor<42xf32> |
| 39 | return %0#0, %0#1 : tensor<?xi32>, tensor<42xf32> |
| 40 | } |
| 41 | |
| 42 | // ----- |
| 43 | |
| 44 | func @scatter_mixed_tensor_memref( |
| 45 | %update : memref<?x?xf32>, %indices : tensor<?x1xi32>, |
| 46 | %original : tensor<?x?xf32>) -> tensor<?x?xf32> { |
| 47 | // expected-error @+1 {{expected inputs and outputs to be RankedTensorType or scalar}} |
Han-Chung Wang | c817078 | 2022-02-18 13:28:58 -0800 | [diff] [blame] | 48 | %0 = iree_linalg_ext.scatter unique_indices(true) |
Stella Laurenzo | 44c4187 | 2022-01-19 19:39:08 -0800 | [diff] [blame] | 49 | ins(%update, %indices : memref<?x?xf32>, tensor<?x1xi32>) |
| 50 | outs(%original : tensor<?x?xf32>) { |
| 51 | ^bb0(%arg1: f32, %arg2: f32): |
| 52 | %1 = arith.addf %arg1, %arg2 : f32 |
| 53 | iree_linalg_ext.yield %1 : f32 |
| 54 | } -> tensor<?x?xf32> |
| 55 | return %0 : tensor<?x?xf32> |
| 56 | } |
| 57 | |
| 58 | // ----- |
| 59 | |
| 60 | func @scatter_mixed_tensor_memref( |
| 61 | %update : tensor<?x?xf32>, %indices : memref<?x1xi32>, |
| 62 | %original : tensor<?x?xf32>) -> tensor<?x?xf32> { |
| 63 | // expected-error @+1 {{expected inputs and outputs to be RankedTensorType or scalar}} |
Han-Chung Wang | c817078 | 2022-02-18 13:28:58 -0800 | [diff] [blame] | 64 | %0 = iree_linalg_ext.scatter unique_indices(true) |
Stella Laurenzo | 44c4187 | 2022-01-19 19:39:08 -0800 | [diff] [blame] | 65 | ins(%update, %indices : tensor<?x?xf32>, memref<?x1xi32>) |
| 66 | outs(%original : tensor<?x?xf32>) { |
| 67 | ^bb0(%arg1: f32, %arg2: f32): |
| 68 | %1 = arith.addf %arg1, %arg2 : f32 |
| 69 | iree_linalg_ext.yield %1 : f32 |
| 70 | } -> tensor<?x?xf32> |
| 71 | return %0 : tensor<?x?xf32> |
| 72 | } |
| 73 | |
| 74 | // ----- |
| 75 | |
| 76 | func @scatter_extra_outputs( |
| 77 | %update : tensor<?x?xf32>, %indices : tensor<?x1xi32>, |
| 78 | %original : tensor<?x?xf32>) -> (tensor<?x?xf32>, tensor<?x?xf32>) { |
| 79 | // expected-error @+1 {{expected number of outputs to be same as the number of results}} |
Han-Chung Wang | c817078 | 2022-02-18 13:28:58 -0800 | [diff] [blame] | 80 | %0, %1 = iree_linalg_ext.scatter unique_indices(true) |
Stella Laurenzo | 44c4187 | 2022-01-19 19:39:08 -0800 | [diff] [blame] | 81 | ins(%update, %indices : tensor<?x?xf32>, tensor<?x1xi32>) |
| 82 | outs(%original : tensor<?x?xf32>) { |
| 83 | ^bb0(%arg1: f32, %arg2: f32): |
| 84 | %1 = arith.addf %arg1, %arg2 : f32 |
| 85 | iree_linalg_ext.yield %1 : f32 |
| 86 | } -> tensor<?x?xf32>, tensor<?x?xf32> |
| 87 | return %0, %1 : tensor<?x?xf32>, tensor<?x?xf32> |
| 88 | } |
| 89 | |
| 90 | // ----- |
| 91 | |
| 92 | func @scatter_mixed_tensor_memref( |
| 93 | %update : tensor<?x?xf32>, %indices : tensor<?x1xi32>, |
| 94 | %original : memref<?x?xf32>) -> tensor<?x?xf32> { |
| 95 | // expected-error @+1 {{expected inputs and outputs to be RankedTensorType or scalar}} |
Han-Chung Wang | c817078 | 2022-02-18 13:28:58 -0800 | [diff] [blame] | 96 | %0 = iree_linalg_ext.scatter unique_indices(true) |
Stella Laurenzo | 44c4187 | 2022-01-19 19:39:08 -0800 | [diff] [blame] | 97 | ins(%update, %indices : tensor<?x?xf32>, tensor<?x1xi32>) |
| 98 | outs(%original : memref<?x?xf32>) { |
| 99 | ^bb0(%arg1: f32, %arg2: f32): |
| 100 | %1 = arith.addf %arg1, %arg2 : f32 |
| 101 | iree_linalg_ext.yield %1 : f32 |
| 102 | } -> tensor<?x?xf32> |
| 103 | return %0 : tensor<?x?xf32> |
| 104 | } |
| 105 | |
| 106 | // ----- |
| 107 | |
MaheshRavishankar | f488f17 | 2022-03-18 18:19:02 -0700 | [diff] [blame^] | 108 | func @scatter_output_type_mismatch( |
Stella Laurenzo | 44c4187 | 2022-01-19 19:39:08 -0800 | [diff] [blame] | 109 | %update : tensor<?x?xf32>, %indices : tensor<?x1xi32>, |
MaheshRavishankar | f488f17 | 2022-03-18 18:19:02 -0700 | [diff] [blame^] | 110 | %original : tensor<?x?xf32>) -> tensor<4x?xf32> { |
| 111 | // expected-error @+1 {{expected type of `outs` operand #0 'tensor<?x?xf32>' to be same as result type 'tensor<4x?xf32>'}} |
Han-Chung Wang | c817078 | 2022-02-18 13:28:58 -0800 | [diff] [blame] | 112 | %0 = iree_linalg_ext.scatter unique_indices(true) |
Stella Laurenzo | 44c4187 | 2022-01-19 19:39:08 -0800 | [diff] [blame] | 113 | ins(%update, %indices : tensor<?x?xf32>, tensor<?x1xi32>) |
| 114 | outs(%original : tensor<?x?xf32>) { |
| 115 | ^bb0(%arg1: f32, %arg2: f32): |
| 116 | %1 = arith.addf %arg1, %arg2 : f32 |
| 117 | iree_linalg_ext.yield %1 : f32 |
MaheshRavishankar | f488f17 | 2022-03-18 18:19:02 -0700 | [diff] [blame^] | 118 | } -> tensor<4x?xf32> |
| 119 | return %0 : tensor<4x?xf32> |
Stella Laurenzo | 44c4187 | 2022-01-19 19:39:08 -0800 | [diff] [blame] | 120 | } |
| 121 | |
| 122 | // ----- |
| 123 | |
| 124 | func @scatter_mixed_tensor_memref( |
| 125 | %update : memref<?x?xf32>, %indices : tensor<?x1xi32>, |
| 126 | %original : memref<?x?xf32>) { |
| 127 | // expected-error @+1 {{expected inputs and outputs to be MemRefType or scalar}} |
Han-Chung Wang | c817078 | 2022-02-18 13:28:58 -0800 | [diff] [blame] | 128 | iree_linalg_ext.scatter unique_indices(true) |
Stella Laurenzo | 44c4187 | 2022-01-19 19:39:08 -0800 | [diff] [blame] | 129 | ins(%update, %indices : memref<?x?xf32>, tensor<?x1xi32>) |
| 130 | outs(%original : memref<?x?xf32>) { |
| 131 | ^bb0(%arg1: f32, %arg2: f32): |
| 132 | %1 = arith.addf %arg1, %arg2 : f32 |
| 133 | iree_linalg_ext.yield %1 : f32 |
| 134 | } |
| 135 | return |
| 136 | } |
| 137 | |
| 138 | // ----- |
| 139 | |
| 140 | func @scatter_mixed_tensor_memref( |
| 141 | %update : memref<?x?xf32>, %indices : memref<?x1xi32>, |
| 142 | %original : tensor<?x?xf32>) { |
| 143 | // expected-error @+1 {{expected inputs and outputs to be MemRefType or scalar}} |
Han-Chung Wang | c817078 | 2022-02-18 13:28:58 -0800 | [diff] [blame] | 144 | iree_linalg_ext.scatter unique_indices(true) |
Stella Laurenzo | 44c4187 | 2022-01-19 19:39:08 -0800 | [diff] [blame] | 145 | ins(%update, %indices : memref<?x?xf32>, memref<?x1xi32>) |
| 146 | outs(%original : tensor<?x?xf32>) { |
| 147 | ^bb0(%arg1: f32, %arg2: f32): |
| 148 | %1 = arith.addf %arg1, %arg2 : f32 |
| 149 | iree_linalg_ext.yield %1 : f32 |
| 150 | } |
| 151 | return |
| 152 | } |
| 153 | |
| 154 | // ----- |
| 155 | |
| 156 | func @scatter_dim_mismatch( |
| 157 | %update : tensor<?x?xf32>, %indices : tensor<48x1xi32>, |
| 158 | %original : tensor<?x?xf32>) -> tensor<?x?xf32> { |
| 159 | // expected-error @+1 {{mismatch in shape of indices and update value at dim#0}} |
Han-Chung Wang | c817078 | 2022-02-18 13:28:58 -0800 | [diff] [blame] | 160 | %0 = iree_linalg_ext.scatter unique_indices(true) |
Stella Laurenzo | 44c4187 | 2022-01-19 19:39:08 -0800 | [diff] [blame] | 161 | ins(%update, %indices : tensor<?x?xf32>, tensor<48x1xi32>) |
| 162 | outs(%original : tensor<?x?xf32>) { |
| 163 | ^bb0(%arg1: f32, %arg2: f32): |
| 164 | %1 = arith.addf %arg1, %arg2 : f32 |
| 165 | iree_linalg_ext.yield %1 : f32 |
| 166 | } -> tensor<?x?xf32> |
| 167 | return %0 : tensor<?x?xf32> |
| 168 | } |
| 169 | |
| 170 | // ----- |
| 171 | |
| 172 | func @scatter_dim_mismatch( |
| 173 | %update : tensor<64x?xf32>, %indices : tensor<48x1xi32>, |
| 174 | %original : tensor<?x?xf32>) -> tensor<?x?xf32> { |
| 175 | // expected-error @+1 {{mismatch in shape of indices and update value at dim#0}} |
Han-Chung Wang | c817078 | 2022-02-18 13:28:58 -0800 | [diff] [blame] | 176 | %0 = iree_linalg_ext.scatter unique_indices(true) |
Stella Laurenzo | 44c4187 | 2022-01-19 19:39:08 -0800 | [diff] [blame] | 177 | ins(%update, %indices : tensor<64x?xf32>, tensor<48x1xi32>) |
| 178 | outs(%original : tensor<?x?xf32>) { |
| 179 | ^bb0(%arg1: f32, %arg2: f32): |
| 180 | %1 = arith.addf %arg1, %arg2 : f32 |
| 181 | iree_linalg_ext.yield %1 : f32 |
| 182 | } -> tensor<?x?xf32> |
| 183 | return %0 : tensor<?x?xf32> |
| 184 | } |
| 185 | |
| 186 | // ----- |
| 187 | |
| 188 | func @scatter_dim_mismatch( |
Han-Chung Wang | c817078 | 2022-02-18 13:28:58 -0800 | [diff] [blame] | 189 | %update : tensor<?x?x?x?xf32>, %indices : tensor<?x1xi32>, |
Stella Laurenzo | 44c4187 | 2022-01-19 19:39:08 -0800 | [diff] [blame] | 190 | %original : tensor<?x?xf32>) -> tensor<?x?xf32> { |
Han-Chung Wang | c817078 | 2022-02-18 13:28:58 -0800 | [diff] [blame] | 191 | // expected-error @+1 {{op update value rank exceeds the rank of the original value}} |
| 192 | %0 = iree_linalg_ext.scatter unique_indices(true) |
| 193 | ins(%update, %indices : tensor<?x?x?x?xf32>, tensor<?x1xi32>) |
Stella Laurenzo | 44c4187 | 2022-01-19 19:39:08 -0800 | [diff] [blame] | 194 | outs(%original : tensor<?x?xf32>) { |
| 195 | ^bb0(%arg1: f32, %arg2: f32): |
| 196 | %1 = arith.addf %arg1, %arg2 : f32 |
| 197 | iree_linalg_ext.yield %1 : f32 |
| 198 | } -> tensor<?x?xf32> |
| 199 | return %0 : tensor<?x?xf32> |
| 200 | } |
| 201 | |
| 202 | // ----- |
| 203 | |
| 204 | func @scatter_dim_mismatch( |
| 205 | %update : tensor<?x4xf32>, %indices : tensor<?x1xi32>, |
| 206 | %original : tensor<?x?xf32>) -> tensor<?x?xf32> { |
| 207 | // expected-error @+1 {{mismatch in shape of update value dim#1 and original value at dim#1}} |
Han-Chung Wang | c817078 | 2022-02-18 13:28:58 -0800 | [diff] [blame] | 208 | %0 = iree_linalg_ext.scatter unique_indices(true) |
Stella Laurenzo | 44c4187 | 2022-01-19 19:39:08 -0800 | [diff] [blame] | 209 | ins(%update, %indices : tensor<?x4xf32>, tensor<?x1xi32>) |
| 210 | outs(%original : tensor<?x?xf32>) { |
| 211 | ^bb0(%arg1: f32, %arg2: f32): |
| 212 | %1 = arith.addf %arg1, %arg2 : f32 |
| 213 | iree_linalg_ext.yield %1 : f32 |
| 214 | } -> tensor<?x?xf32> |
| 215 | return %0 : tensor<?x?xf32> |
| 216 | } |
| 217 | |
| 218 | // ----- |
| 219 | |
| 220 | func @scatter_region_type_mismatch( |
| 221 | %update : tensor<?x?xi32>, %indices : tensor<?x1xi32>, |
| 222 | %original : tensor<?x?xi32>) -> tensor<?x?xi32> { |
| 223 | // expected-error @+1 {{expected region to have scalar argument of integer or float types}} |
Han-Chung Wang | c817078 | 2022-02-18 13:28:58 -0800 | [diff] [blame] | 224 | %0 = iree_linalg_ext.scatter unique_indices(true) |
Stella Laurenzo | 44c4187 | 2022-01-19 19:39:08 -0800 | [diff] [blame] | 225 | ins(%update, %indices : tensor<?x?xi32>, tensor<?x1xi32>) |
| 226 | outs(%original : tensor<?x?xi32>) { |
| 227 | ^bb0(%arg1: index, %arg2: index): |
| 228 | %1 = arith.addi %arg1, %arg2 : index |
| 229 | %2 = arith.index_cast %1 : index to i32 |
| 230 | iree_linalg_ext.yield %2 : i32 |
| 231 | } -> tensor<?x?xi32> |
| 232 | return %0 : tensor<?x?xi32> |
| 233 | } |
| 234 | |
| 235 | // ----- |
| 236 | |
| 237 | func @scatter_region_type_mismatch( |
| 238 | %update : tensor<?x?xi32>, %indices : tensor<?x1xi32>, |
| 239 | %original : tensor<?x?xi32>) -> tensor<?x?xi32> { |
| 240 | // expected-error @+1 {{mismatch in argument 0 of region 'i64' and element type of update value 'i32'}} |
Han-Chung Wang | c817078 | 2022-02-18 13:28:58 -0800 | [diff] [blame] | 241 | %0 = iree_linalg_ext.scatter unique_indices(true) |
Stella Laurenzo | 44c4187 | 2022-01-19 19:39:08 -0800 | [diff] [blame] | 242 | ins(%update, %indices : tensor<?x?xi32>, tensor<?x1xi32>) |
| 243 | outs(%original : tensor<?x?xi32>) { |
| 244 | ^bb0(%arg1: i64, %arg2: i32): |
| 245 | %1 = arith.trunci %arg1 : i64 to i32 |
| 246 | %2 = arith.addi %1, %arg2 : i32 |
| 247 | iree_linalg_ext.yield %2 : i32 |
| 248 | } -> tensor<?x?xi32> |
| 249 | return %0 : tensor<?x?xi32> |
| 250 | } |
| 251 | |
| 252 | // ----- |
| 253 | |
| 254 | func @scatter_region_type_mismatch( |
| 255 | %update : tensor<?x?xi32>, %indices : tensor<?x1xi32>, |
| 256 | %original : tensor<?x?xi32>) -> tensor<?x?xi32> { |
| 257 | // expected-error @+1 {{mismatch in argument 1 of region 'i64' and element type of original value 'i32'}} |
Han-Chung Wang | c817078 | 2022-02-18 13:28:58 -0800 | [diff] [blame] | 258 | %0 = iree_linalg_ext.scatter unique_indices(true) |
Stella Laurenzo | 44c4187 | 2022-01-19 19:39:08 -0800 | [diff] [blame] | 259 | ins(%update, %indices : tensor<?x?xi32>, tensor<?x1xi32>) |
| 260 | outs(%original : tensor<?x?xi32>) { |
| 261 | ^bb0(%arg1: i32, %arg2: i64): |
| 262 | %1 = arith.trunci %arg2 : i64 to i32 |
| 263 | %2 = arith.addi %1, %arg1 : i32 |
| 264 | iree_linalg_ext.yield %2 : i32 |
| 265 | } -> tensor<?x?xi32> |
| 266 | return %0 : tensor<?x?xi32> |
| 267 | } |
| 268 | |
| 269 | // ----- |
| 270 | |
| 271 | func @scatter_region_type_mismatch( |
| 272 | %update : tensor<?x?xi32>, %indices : tensor<?x1xi32>, |
| 273 | %original : tensor<?x?xi64>) -> tensor<?x?xi64> { |
| 274 | // expected-error @+1 {{mismatch in region argument types 'i32' and 'i64'}} |
Han-Chung Wang | c817078 | 2022-02-18 13:28:58 -0800 | [diff] [blame] | 275 | %0 = iree_linalg_ext.scatter unique_indices(true) |
Stella Laurenzo | 44c4187 | 2022-01-19 19:39:08 -0800 | [diff] [blame] | 276 | ins(%update, %indices : tensor<?x?xi32>, tensor<?x1xi32>) |
| 277 | outs(%original : tensor<?x?xi64>) { |
| 278 | ^bb0(%arg1: i32, %arg2: i64): |
| 279 | %1 = arith.extsi %arg1 : i32 to i64 |
| 280 | %2 = arith.addi %1, %arg2 : i64 |
| 281 | iree_linalg_ext.yield %2 : i64 |
| 282 | } -> tensor<?x?xi64> |
| 283 | return %0 : tensor<?x?xi64> |
| 284 | } |
| 285 | |
| 286 | // ----- |
| 287 | |
| 288 | func @scatter_region_type_mismatch( |
| 289 | %update : tensor<?x?xi64>, %indices : tensor<?x1xi32>, |
| 290 | %original : tensor<?x?xi64>) -> tensor<?x?xi64> { |
| 291 | // expected-error @+1 {{expected region to have two arguments}} |
Han-Chung Wang | c817078 | 2022-02-18 13:28:58 -0800 | [diff] [blame] | 292 | %0 = iree_linalg_ext.scatter unique_indices(true) |
Stella Laurenzo | 44c4187 | 2022-01-19 19:39:08 -0800 | [diff] [blame] | 293 | ins(%update, %indices : tensor<?x?xi64>, tensor<?x1xi32>) |
| 294 | outs(%original : tensor<?x?xi64>) { |
| 295 | ^bb0(%arg1: i64, %arg2: i64, %arg3 : i64): |
| 296 | %1 = arith.addi %arg1, %arg2 : i64 |
| 297 | iree_linalg_ext.yield %1 : i64 |
| 298 | } -> tensor<?x?xi64> |
| 299 | return %0 : tensor<?x?xi64> |
| 300 | } |
| 301 | |
| 302 | |
| 303 | // ----- |
| 304 | |
| 305 | func @scatter_yield_mismatch( |
| 306 | %update : tensor<?x?xi64>, %indices : tensor<?x1xi32>, |
| 307 | %original : tensor<?x?xi64>) -> tensor<?x?xi64> { |
Han-Chung Wang | c817078 | 2022-02-18 13:28:58 -0800 | [diff] [blame] | 308 | %0 = iree_linalg_ext.scatter unique_indices(true) |
Stella Laurenzo | 44c4187 | 2022-01-19 19:39:08 -0800 | [diff] [blame] | 309 | ins(%update, %indices : tensor<?x?xi64>, tensor<?x1xi32>) |
| 310 | outs(%original : tensor<?x?xi64>) { |
| 311 | ^bb0(%arg1: i64, %arg2: i64): |
| 312 | %1 = arith.addi %arg1, %arg2 : i64 |
| 313 | %2 = arith.trunci %1 : i64 to i32 |
| 314 | // expected-error @+1 {{mismatch in type of yielded value 'i32' and argument of the region 'i64'}} |
| 315 | iree_linalg_ext.yield %2 : i32 |
| 316 | } -> tensor<?x?xi64> |
| 317 | return %0 : tensor<?x?xi64> |
| 318 | } |
| 319 | |
| 320 | // ----- |
| 321 | |
| 322 | func @scatter_yield_mismatch( |
| 323 | %update : tensor<?x?xi64>, %indices : tensor<?x1xi32>, |
| 324 | %original : tensor<?x?xi64>) -> tensor<?x?xi64> { |
Han-Chung Wang | c817078 | 2022-02-18 13:28:58 -0800 | [diff] [blame] | 325 | %0 = iree_linalg_ext.scatter unique_indices(true) |
Stella Laurenzo | 44c4187 | 2022-01-19 19:39:08 -0800 | [diff] [blame] | 326 | ins(%update, %indices : tensor<?x?xi64>, tensor<?x1xi32>) |
| 327 | outs(%original : tensor<?x?xi64>) { |
| 328 | ^bb0(%arg1: i64, %arg2: i64): |
| 329 | %1 = arith.addi %arg1, %arg2 : i64 |
| 330 | %2 = arith.trunci %1 : i64 to i32 |
| 331 | // expected-error @+1 {{expected region to yield a single value}} |
| 332 | iree_linalg_ext.yield %1, %2 : i64, i32 |
| 333 | } -> tensor<?x?xi64> |
| 334 | return %0 : tensor<?x?xi64> |
| 335 | } |
| 336 | |
| 337 | // ----- |
| 338 | |
| 339 | func @scatter_index_depth_dynamic( |
| 340 | %update : tensor<?x?xi64>, %indices : tensor<?x?xi32>, |
| 341 | %original : tensor<?x?xi64>) -> tensor<?x?xi64> { |
| 342 | // expected-error @+1 {{expected index depth is static}} |
Han-Chung Wang | c817078 | 2022-02-18 13:28:58 -0800 | [diff] [blame] | 343 | %0 = iree_linalg_ext.scatter unique_indices(true) |
Stella Laurenzo | 44c4187 | 2022-01-19 19:39:08 -0800 | [diff] [blame] | 344 | ins(%update, %indices : tensor<?x?xi64>, tensor<?x?xi32>) |
| 345 | outs(%original : tensor<?x?xi64>) { |
| 346 | ^bb0(%arg1: i64, %arg2: i64): |
| 347 | %1 = arith.addi %arg1, %arg2 : i64 |
| 348 | %2 = arith.trunci %1 : i64 to i32 |
| 349 | iree_linalg_ext.yield %1, %2 : i64, i32 |
| 350 | } -> tensor<?x?xi64> |
| 351 | return %0 : tensor<?x?xi64> |
| 352 | } |
| 353 | |
| 354 | // ----- |
| 355 | |
| 356 | func @scatter_original_rank_mismatch( |
Han-Chung Wang | c817078 | 2022-02-18 13:28:58 -0800 | [diff] [blame] | 357 | %update : tensor<?xi64>, %indices : tensor<?x1xi32>, |
Stella Laurenzo | 44c4187 | 2022-01-19 19:39:08 -0800 | [diff] [blame] | 358 | %original : tensor<?x?xi64>) -> tensor<?x?xi64> { |
Han-Chung Wang | c817078 | 2022-02-18 13:28:58 -0800 | [diff] [blame] | 359 | // expected-error @+1 {{op index depth and update value does not cover rank of original value}} |
| 360 | %0 = iree_linalg_ext.scatter unique_indices(true) |
| 361 | ins(%update, %indices : tensor<?xi64>, tensor<?x1xi32>) |
Stella Laurenzo | 44c4187 | 2022-01-19 19:39:08 -0800 | [diff] [blame] | 362 | outs(%original : tensor<?x?xi64>) { |
| 363 | ^bb0(%arg1: i64, %arg2: i64): |
| 364 | %1 = arith.addi %arg1, %arg2 : i64 |
| 365 | %2 = arith.trunci %1 : i64 to i32 |
| 366 | iree_linalg_ext.yield %1, %2 : i64, i32 |
| 367 | } -> tensor<?x?xi64> |
| 368 | return %0 : tensor<?x?xi64> |
| 369 | } |
| 370 | |
| 371 | // ----- |
| 372 | |
| 373 | func @reverse_diff_element_type(%arg0: tensor<3x5xi32>) -> tensor<3x5xf32> { |
| 374 | %init = linalg.init_tensor [3, 5] : tensor<3x5xf32> |
| 375 | // expected-error @+1 {{expected input/output element types to be identical}} |
| 376 | %0 = iree_linalg_ext.reverse |
| 377 | dimensions(dense<0> : tensor<1xi64>) |
| 378 | ins(%arg0 : tensor<3x5xi32>) |
| 379 | outs(%init : tensor<3x5xf32>) : tensor<3x5xf32> |
| 380 | return %0 : tensor<3x5xf32> |
| 381 | } |
| 382 | |
| 383 | // ----- |
| 384 | |
| 385 | func @reverse_diff_shape(%arg0: tensor<3x5xi32>) -> tensor<3x6xi32> { |
| 386 | %init = linalg.init_tensor [3, 6] : tensor<3x6xi32> |
| 387 | // expected-error @+1 {{incompatible input/output shapes}} |
| 388 | %0 = iree_linalg_ext.reverse |
| 389 | dimensions(dense<0> : tensor<1xi64>) |
| 390 | ins(%arg0 : tensor<3x5xi32>) |
| 391 | outs(%init : tensor<3x6xi32>) : tensor<3x6xi32> |
| 392 | return %0 : tensor<3x6xi32> |
| 393 | } |
| 394 | |
| 395 | // ----- |
| 396 | |
| 397 | func @reverse_dup_dims(%arg0: tensor<3x5xi32>) -> tensor<3x5xi32> { |
| 398 | %init = linalg.init_tensor [3, 5] : tensor<3x5xi32> |
| 399 | // expected-error @+1 {{expected dimensions numbers are all unique}} |
| 400 | %0 = iree_linalg_ext.reverse |
| 401 | dimensions(dense<[0, 0]> : tensor<2xi64>) |
| 402 | ins(%arg0 : tensor<3x5xi32>) |
| 403 | outs(%init : tensor<3x5xi32>) : tensor<3x5xi32> |
| 404 | return %0 : tensor<3x5xi32> |
| 405 | } |
MaheshRavishankar | f488f17 | 2022-03-18 18:19:02 -0700 | [diff] [blame^] | 406 | |
| 407 | // ----- |
| 408 | |
| 409 | func @not_enough_results() -> () { |
| 410 | %num_threads = arith.constant 100 : index |
| 411 | // expected-error@+1 {{'iree_linalg_ext.in_parallel' op produces 1 results, but its terminator yields 0 values}} |
| 412 | %result = iree_linalg_ext.in_parallel %num_threads -> tensor<100xf32> { |
| 413 | ^bb0(%thread_idx : index): |
| 414 | iree_linalg_ext.perform_concurrently {} |
| 415 | } |
| 416 | } |
| 417 | |
| 418 | // ----- |
| 419 | |
| 420 | func @too_many_results(%1 : tensor<1xf32>, %out : tensor<100xf32>) -> () { |
| 421 | %num_threads = arith.constant 100 : index |
| 422 | // expected-error@+1 {{'iree_linalg_ext.in_parallel' op produces 1 results, but its terminator yields 2 values}} |
| 423 | %result = iree_linalg_ext.in_parallel %num_threads -> tensor<100xf32> { |
| 424 | ^bb0(%thread_idx : index): |
| 425 | %0 = arith.constant 1 : index |
| 426 | iree_linalg_ext.perform_concurrently { |
| 427 | iree_linalg_ext.parallel_insert_slice %1 into %out[%thread_idx][%0][%0] : |
| 428 | tensor<1xf32> into tensor<100xf32> |
| 429 | iree_linalg_ext.parallel_insert_slice %1 into %out[%thread_idx][%0][%0] : |
| 430 | tensor<1xf32> into tensor<100xf32> |
| 431 | } |
| 432 | } |
| 433 | } |
| 434 | |
| 435 | // ----- |
| 436 | |
| 437 | func @type_mismatch(%1 : tensor<1xf32>, %out : tensor<200xf32>) -> () { |
| 438 | %num_threads = arith.constant 100 : index |
| 439 | // expected-error@+1 {{'iree_linalg_ext.in_parallel' op type mismatch between 0th result of in_parallel ('tensor<200xf32>') and 0th result yielded by its terminator ('tensor<100xf32>')}} |
| 440 | %result = iree_linalg_ext.in_parallel %num_threads -> tensor<100xf32> { |
| 441 | ^bb0(%thread_idx : index): |
| 442 | %0 = arith.constant 1 : index |
| 443 | iree_linalg_ext.perform_concurrently { |
| 444 | iree_linalg_ext.parallel_insert_slice %1 into %out[%thread_idx][%0][%0] : |
| 445 | tensor<1xf32> into tensor<200xf32> |
| 446 | } |
| 447 | } |
| 448 | } |