diff options
author | Rafael Ubal <rubal@mathworks.com> | 2024-08-16 11:10:48 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-16 11:10:48 -0400 |
commit | ef6e7affbb7b0eb4976c1019c788bcadfc34ecd6 (patch) | |
tree | a5032abc5ce63e60d32e93ca47c8c3f499d2e95e /clang/lib/AST/ExprConstant.cpp | |
parent | 99696b35bc8a0054e0b0c1a26e8dd5049fa8c41b (diff) | |
download | llvm-ef6e7affbb7b0eb4976c1019c788bcadfc34ecd6.zip llvm-ef6e7affbb7b0eb4976c1019c788bcadfc34ecd6.tar.gz llvm-ef6e7affbb7b0eb4976c1019c788bcadfc34ecd6.tar.bz2 |
[mlir] [tosa] Bug fixes in shape inference pass (#104146)
This change addresses 2 bugs in the TOSA shape inference pass
(`--tosa-infer-shapes`). The included unit test contains a detailed
description of the issues.
- Input IR
```
func.func @main(%arg0: tensor<1x2x8xf32>) {
%0 = tosa.cast %arg0 : (tensor<1x2x8xf32>) -> tensor<?x2x8xf32>
%c0 = arith.constant 0 : index
%dim = tensor.dim %0, %c0 : tensor<?x2x8xf32>
%expanded_0 = tensor.expand_shape %0 [[0], [1, 2], [3]] output_shape [%dim, 1, 4, 8] : tensor<?x2x8xf32> into tensor<?x1x2x8xf32>
%expanded_1 = tensor.expand_shape %0 [[0], [1, 2], [3]] output_shape [%dim, 1, 4, 8] : tensor<?x2x8xf32> into tensor<?x1x2x8xf32>
return
}
```
- Output IR
```
module {
func.func @main(%arg0: tensor<1x2x8xf32>) {
%0 = tosa.cast %arg0 : (tensor<1x2x8xf32>) -> tensor<1x2x8xf32>
// This cast was previously inserted between both 'tensor.expand_shape' ops.
%cast = tensor.cast %0 : tensor<1x2x8xf32> to tensor<?x2x8xf32>
%c0 = arith.constant 0 : index
%dim = tensor.dim %0, %c0 : tensor<1x2x8xf32>
// The operand of the first 'tensor.expand_shape' op was not previously updated
// from '%0' to '%cast' due to an invalidation of the iterator traversing the
// use list of the 'tosa.cast' op.
%expanded_0 = tensor.expand_shape %cast [[0], [1, 2], [3]] output_shape [%dim, 1, 4, 8] : tensor<?x2x8xf32> into tensor<?x1x2x8xf32>
%expanded_1 = tensor.expand_shape %cast [[0], [1, 2], [3]] output_shape [%dim, 1, 4, 8] : tensor<?x2x8xf32> into tensor<?x1x2x8xf32>
return
}
```
Diffstat (limited to 'clang/lib/AST/ExprConstant.cpp')
0 files changed, 0 insertions, 0 deletions