diff options
author | Andrzej Warzynski <andrzej.warzynski@arm.com> | 2022-12-30 15:22:22 +0000 |
---|---|---|
committer | Andrzej Warzynski <andrzej.warzynski@arm.com> | 2023-01-12 16:34:11 +0000 |
commit | a63853e6acc594d33b2fd96036e804d9e4a53f76 (patch) | |
tree | e9a0baab774c301b804eec908055bdc5c91ec198 /clang/lib/Frontend/InitPreprocessor.cpp | |
parent | b2b4d95827b7db1a1cd92e2789f306f499b74b40 (diff) | |
download | llvm-a63853e6acc594d33b2fd96036e804d9e4a53f76.zip llvm-a63853e6acc594d33b2fd96036e804d9e4a53f76.tar.gz llvm-a63853e6acc594d33b2fd96036e804d9e4a53f76.tar.bz2 |
[mlir] Broadcast scalars when vectorising tensor.extract
When vectorizing tensor.extract embedded within linalg.generic, the
default option is to rewrite it as vector.gather. When doing so, we need
to make sure that the corresponding indices are vectorized accordingly.
However, the Linalg vectorizer will not vectorize constants like in the
following example. This is fixed by simply broadcasting %c0 and %c1.
```
func.func @example(%arg0: tensor<3x3xf32>, %arg2: tensor<1x1x3xf32>) -> tensor<1x1x3xf32> {
%c0 = arith.constant 1 : index
%c1 = arith.constant 2 : index
%1 = linalg.generic {
(...)
} outs(...) {
^bb0(...):
%2 = tensor.extract %arg0[%c0, %c1] : tensor<3x3xf32>
linalg.yield %2 : f32
} -> tensor<1x1x3xf32>
return %1 : tensor<1x1x3xf32>
}
```
This patch makes sure that in the case above (and other similar cases),
the vectorizer broadcasts %c0 and %c1.
Differential Revision: https://reviews.llvm.org/D140781
Diffstat (limited to 'clang/lib/Frontend/InitPreprocessor.cpp')
0 files changed, 0 insertions, 0 deletions