xref: /llvm-project/mlir/test/Dialect/Linalg/fill-interface-invalid.mlir (revision 92d38adb83f4e4e8257d092adeffba9132aa4830)
1// RUN: mlir-opt -split-input-file -verify-diagnostics %s
2
3func.func @test_fill_op_not_linalg_op(%arg0 : f32, %arg1 : tensor<?xf32>)
4     -> tensor<?xf32> {
5  // expected-error @+1 {{expected a LinalgOp}}
6  %0 = "test.fill_op_not_linalg_op"(%arg0, %arg1)
7      : (f32, tensor<?xf32>) -> tensor<?xf32>
8  return %0 : tensor<?xf32>
9}
10
11// -----
12
13#map0 = affine_map<(d0) -> ()>
14#map1 = affine_map<(d0) -> (d0)>
15func.func @test_fill_op_wrong_num_operands(%arg0 : f32, %arg1 : tensor<?xf32>)
16     -> tensor<?xf32> {
17  // expected-error @+1 {{expected op with 1 input and 1 output}}
18  %0 = test.linalg_fill_op {
19      indexing_maps = [#map0, #map0, #map1],
20      iterator_types = ["parallel"]}
21      ins(%arg0, %arg0 : f32, f32) outs(%arg1 : tensor<?xf32>) {
22      ^bb0(%arg2 : f32, %arg3 : f32, %arg4 : f32):
23         linalg.yield  %arg2 : f32
24      } -> tensor<?xf32>
25  return %0 : tensor<?xf32>
26}
27
28// -----
29
30#map1 = affine_map<(d0) -> (d0)>
31func.func @test_fill_op_non_scalar_input(%arg0 : tensor<?xf32>,
32    %arg1 : tensor<?xf32>) -> tensor<?xf32> {
33  // expected-error @+1 {{expected op with scalar input}}
34  %0 = test.linalg_fill_op {
35      indexing_maps = [#map1, #map1],
36      iterator_types = ["parallel"]}
37      ins(%arg0 : tensor<?xf32>) outs(%arg1 : tensor<?xf32>) {
38      ^bb0(%arg2 : f32, %arg3 : f32):
39         linalg.yield  %arg2 : f32
40      } -> tensor<?xf32>
41  return %0 : tensor<?xf32>
42}
43