Files
clang-p2996/mlir/test/Dialect/Linalg/specialize-generic-ops-fail.mlir
Andrzej Warzyński 7e2707ad46 [mlir][nfc] Add a negative test for --linalg-specialize-generic-ops (#127600)
Following on from #126737, adds a negative test that:
* prior to #126737, would incorrectly generated empty output,
* with the fix in-tree, simply outputs the input IR (i.e. the
  specialization "fails").

I've also made minor editorial changes.
2025-02-18 13:57:49 +00:00

32 lines
1.2 KiB
MLIR

// RUN: mlir-opt %s -split-input-file --linalg-specialize-generic-ops | FileCheck %s
#map = affine_map<(d0, d1, d2) -> (d1, d0)>
#map1 = affine_map<(d0, d1, d2) -> (d0, d1, d2)>
// This test checks that linalg.generic does not get incorrectly specialized to transform or broadcast.
// CHECK-LABEL: @transpose_and_broadcast
// CHECK: linalg.generic
func.func @transpose_and_broadcast(%arg0: tensor<7x8xf32>, %arg1: tensor<8x7x9xf32>) -> tensor<8x7x9xf32> {
%res = linalg.generic {
indexing_maps = [#map, #map1], iterator_types = ["parallel", "parallel", "parallel"]
} ins(%arg0 : tensor<7x8xf32>) outs(%arg1 : tensor<8x7x9xf32>) {
^bb0(%in: f32, %out: f32):
linalg.yield %in : f32
} -> tensor<8x7x9xf32>
return %res : tensor<8x7x9xf32>
}
// -----
#map = affine_map<(d0) -> (d0)>
// CHECK-LABEL: @neither_permutation_nor_broadcast
// CHECK: linalg.generic
func.func @neither_permutation_nor_broadcast(%init : tensor<8xi32>) -> tensor<8xi32> {
%res = linalg.generic {
indexing_maps = [#map], iterator_types = ["parallel"]
} outs(%init: tensor<8xi32>) {
^bb0(%out: i32):
linalg.yield %out: i32
} -> tensor<8xi32>
return %res : tensor<8xi32>
}