[all-commits] [llvm/llvm-project] 1e1881: [MLIR] fix shape.broadcast canonicalize with all e...

Chenhui Huang via All-commits all-commits at lists.llvm.org
Fri Dec 20 02:32:33 PST 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 1e18815fdc13bb1f8b0b87acd8abf62b5cf70d53
      https://github.com/llvm/llvm-project/commit/1e18815fdc13bb1f8b0b87acd8abf62b5cf70d53
  Author: Chenhui Huang <huangchenhui.yellow at bytedance.com>
  Date:   2024-12-20 (Fri, 20 Dec 2024)

  Changed paths:
    M mlir/lib/Dialect/Shape/IR/Shape.cpp
    M mlir/test/Dialect/Shape/canonicalize.mlir

  Log Message:
  -----------
  [MLIR] fix shape.broadcast canonicalize with all empty shape operands (#118941)

Example: all the operands of `shape.broadcast` are empty tensors.
```
func.func @all_empty(%arg0: tensor<f32>) -> tensor<0xindex> {
  %1 = shape.shape_of %arg0 : tensor<f32> -> tensor<0xindex>
  %2 = shape.const_shape [] : tensor<0xindex>
  %3 = shape.broadcast %1, %2, %1 : tensor<0xindex>, tensor<0xindex>, tensor<0xindex> -> tensor<0xindex>
  return %3 : tensor<0xindex>
}
```

One can reproduce crash when canonicalize with *down-top* order, cmd
like this:
`mlir-opt -split-input-file -allow-unregistered-dialect
-canonicalize="test-convergence top-down=0" %s`

The root cause is when all operands are empty tensor,
`RemoveEmptyShapeOperandsPattern` would filter out all operands.

Co-authored-by: Kai Sasaki <lewuathe at gmail.com>



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list