[all-commits] [llvm/llvm-project] da944e: [mlir][tensor] Add shape inference support for `te...

Aaron St George via All-commits all-commits at lists.llvm.org
Fri May 16 15:07:03 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: da944e009955982927759c2f1fd47d43b236cc51
      https://github.com/llvm/llvm-project/commit/da944e009955982927759c2f1fd47d43b236cc51
  Author: Aaron St George <aaronstgeorge at gmail.com>
  Date:   2025-05-16 (Fri, 16 May 2025)

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

  Log Message:
  -----------
  [mlir][tensor] Add shape inference support for `tensor.concat` op. (#140168)

## description
`tensor.concat` requires operands and the result to match on all
dimensions except the concatenation dimension. If one operand is already
static in those dimensions, the other operands and result type may
safely be refined to that same static shape. This PR adds
canonicalization patterns to refine `tensor.concat` types and propagate
static shapes to other canonicalization patterns through casts.

## example
```mlir
%2 = tensor.concat dim(0) %0, %1: (tensor<?x12xi32>, tensor<?x?xi32>) ->tensor<?x12xi32>
```
becomes:
 ```mlir
%cast = tensor.cast %1 : tensor<?x?xi32> to tensor<?x12xi32>
%2 = tensor.concat dim(0) %0, %cast : (tensor<?x12xi32>,
tensor<?x12xi32>) -> tensor<?x12xi32>
 ```

---------

Co-authored-by: Ian Wood <ianwood2024 at u.northwestern.edu>



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