llvm/mlir/test/Dialect
Hanhan Wang 96e9b6c9dc Revert "[mlir] Rewrite canonicalization of collapse(expand) and expand(collapse)."
This reverts commit 64f659bee6.

An invalid tensor.expand_shape op is generated with the commit. To repro:

$ mlir-opt -canonicalize a.mlir

```
func @foo(%0: tensor<1x1xf32>, %1: tensor<1x1xf32>, %2: tensor<1x1xf32>) -> tensor<1x1xf32> {
  %cst = arith.constant 0.000000e+00 : f32
  %3 = linalg.init_tensor [8, 1] : tensor<8x1xf32>
  %4 = linalg.fill ins(%cst : f32) outs(%3 : tensor<8x1xf32>) -> tensor<8x1xf32>
  %5 = tensor.collapse_shape %0 [] : tensor<1x1xf32> into tensor<f32>
  %6 = tensor.insert_slice %5 into %4[0, 0] [1, 1] [1, 1] : tensor<f32> into tensor<8x1xf32>
  %7 = linalg.init_tensor [8, 1] : tensor<8x1xf32>
  %8 = linalg.fill ins(%cst : f32) outs(%7 : tensor<8x1xf32>) -> tensor<8x1xf32>
  %9 = tensor.collapse_shape %2 [] : tensor<1x1xf32> into tensor<f32>
  %10 = tensor.insert_slice %9 into %8[0, 0] [1, 1] [1, 1] : tensor<f32> into tensor<8x1xf32>
  %11 = tensor.collapse_shape %6 [[0, 1]] : tensor<8x1xf32> into tensor<8xf32>
  %12 = linalg.init_tensor [8] : tensor<8xf32>
  %13 = linalg.generic {indexing_maps = [affine_map<(d0) -> (d0)>, affine_map<(d0) -> (d0)>], iterator_types = ["parallel"]} ins(%11 : tensor<8xf32>) outs(%12 : tensor<8xf32>) {
  ^bb0(%arg3: f32, %arg4: f32):
    linalg.yield %arg3 : f32
  } -> tensor<8xf32>
  %14 = tensor.expand_shape %13 [[0, 1, 2, 3]] : tensor<8xf32> into tensor<1x1x8x1xf32>
  %15 = tensor.collapse_shape %1 [] : tensor<1x1xf32> into tensor<f32>
  %16 = linalg.init_tensor [] : tensor<f32>
  %17 = linalg.generic {indexing_maps = [affine_map<() -> ()>, affine_map<() -> ()>], iterator_types = []} ins(%15 : tensor<f32>) outs(%16 : tensor<f32>) {
  ^bb0(%arg3: f32, %arg4: f32):
    linalg.yield %arg3 : f32
  } -> tensor<f32>
  %18 = tensor.expand_shape %17 [] : tensor<f32> into tensor<1x1x1x1xf32>
  %19 = tensor.collapse_shape %10 [[0, 1]] : tensor<8x1xf32> into tensor<8xf32>
  %20 = linalg.init_tensor [8] : tensor<8xf32>
  %21 = linalg.generic {indexing_maps = [affine_map<(d0) -> (d0)>, affine_map<(d0) -> (d0)>], iterator_types = ["parallel"]} ins(%19 : tensor<8xf32>) outs(%20 : tensor<8xf32>) {
  ^bb0(%arg3: f32, %arg4: f32):
    linalg.yield %arg3 : f32
  } -> tensor<8xf32>
  %22 = tensor.expand_shape %21 [[0, 1, 2, 3]] : tensor<8xf32> into tensor<1x1x8x1xf32>
  %23 = linalg.mmt4d {comment = "f32*f32->f32, aarch64, matrix*vector"} ins(%14, %18 : tensor<1x1x8x1xf32>, tensor<1x1x1x1xf32>) outs(%22 : tensor<1x1x8x1xf32>) -> tensor<1x1x8x1xf32>
  %24 = tensor.collapse_shape %23 [[0, 1, 2, 3]] : tensor<1x1x8x1xf32> into tensor<8xf32>
  %25 = linalg.init_tensor [8] : tensor<8xf32>
  %26 = linalg.generic {indexing_maps = [affine_map<(d0) -> (d0)>, affine_map<(d0) -> (d0)>], iterator_types = ["parallel"]} ins(%24 : tensor<8xf32>) outs(%25 : tensor<8xf32>) {
  ^bb0(%arg3: f32, %arg4: f32):
    linalg.yield %arg3 : f32
  } -> tensor<8xf32>
  %27 = tensor.expand_shape %26 [[0, 1]] : tensor<8xf32> into tensor<8x1xf32>
  %28 = tensor.extract_slice %27[0, 0] [1, 1] [1, 1] : tensor<8x1xf32> to tensor<f32>
  %29 = tensor.expand_shape %28 [] : tensor<f32> into tensor<1x1xf32>
  return %29 : tensor<1x1xf32>
}
```

Differential Revision: https://reviews.llvm.org/D123161
2022-04-05 15:05:41 -07:00
..
Affine Update affine.load folding hook to fold global splat constant loads 2022-03-26 06:44:03 +05:30
AMX
Arithmetic [mlir][Arith] Make integer max/min commutative. 2022-03-23 10:17:36 +08:00
ArmNeon
ArmSVE [mlir][NFC] Rename StandardToLLVM to FuncToLLVM 2022-03-07 11:25:23 -08:00
Async Revert "[GreedPatternRewriter] Preprocess constants while building worklist when not processing top down" 2022-04-01 06:16:55 +00:00
Bufferization [mlir][bufferize] Deallocate returned buffers with BufferDeallocation 2022-03-16 23:13:34 +09:00
Builtin
Complex
ControlFlow [mlir] Move the Builtin FuncOp to the Func dialect 2022-03-16 17:07:03 -07:00
DLTI [mlir] Data layout for integer and float types 2022-03-02 14:56:49 +01:00
EmitC
Func [mlir][NFC] Rename the old Standard dialect test directory to Func 2022-03-01 13:48:34 -08:00
GPU [mlir][gpu] Relax restriction on mma load/store op 2022-03-25 04:03:40 +00:00
Linalg [mlir][linalg] Move linalg.fill folding into linalg.generic pattern from canonicalization to elementwise fusion 2022-04-05 20:13:03 +00:00
LLVMIR [mlir][NVVM] Add support for nvvm mma.sync ops 2022-03-25 17:28:05 +00:00
Math [mlir][Math] Add more constant folder for Math ops. 2022-03-22 10:23:15 +08:00
MemRef Revert "[mlir] Rewrite canonicalization of collapse(expand) and expand(collapse)." 2022-04-05 15:05:41 -07:00
OpenACC
OpenMP [mlir][OpenMP] Added ReductionClauseInterface 2022-03-28 14:24:28 +05:30
PDL [mlir:PDL] Remove the ConstantParams support from native Constraints/Rewrites 2022-03-19 13:28:24 -07:00
PDLInterp
Quant [mlir] Move the Builtin FuncOp to the Func dialect 2022-03-16 17:07:03 -07:00
SCF [mlir][affine] Add affine.min / affine.max canonicalization. 2022-03-22 07:17:19 +00:00
Shape [mlir] Move the Builtin FuncOp to the Func dialect 2022-03-16 17:07:03 -07:00
SparseTensor [mlir][sparse] Moving delete coo into codegen instead of runtime library 2022-04-01 11:08:52 -07:00
SPIRV [mlir] Move the Builtin FuncOp to the Func dialect 2022-03-16 17:07:03 -07:00
Tensor Revert "[mlir] Rewrite canonicalization of collapse(expand) and expand(collapse)." 2022-04-05 15:05:41 -07:00
Tosa [mlir][tosa] : adding folder and canonicalizer for select 2022-03-25 16:50:29 +00:00
Vector [mlir][Vector] Add constant folder for extractelement. 2022-04-02 11:10:42 +08:00
X86Vector
traits.mlir