[Mlir-commits] [mlir] [mlir][tosa] Fix Map for Bias Broadcast (PR #89059)
Jakub Kuderski
llvmlistbot at llvm.org
Mon Apr 22 11:05:22 PDT 2024
================
@@ -101,9 +101,18 @@ static mlir::Value linalgBroadcastAndMaybeExtSI(PatternRewriter &rewriter,
// The source tensor is broadcast to all the outer dimensions of the
// result tensor.
SmallVector<AffineExpr> sourceDims;
- for (auto dim : llvm::seq<int64_t>(0, sourceRank)) {
- auto expr = rewriter.getAffineDimExpr(dim + resultRank - sourceRank);
- sourceDims.push_back(expr);
+ // In the case of a rank one source tensor with a single element TOSA
+ // specifies that the value be broadcast meaning we need an edge case for a
+ // constant map.
+ assert(sourceTy.hasStaticShape() &&
+ "Dynamic broadcasting shapes not supported!");
+ if (1 == sourceRank && 1 == sourceTy.getDimSize(0)) {
----------------
kuhar wrote:
nit: this comparison style looks a bit unusual, llvm puts constants on the right
```suggestion
if (sourceRank == 1 && sourceTy.getDimSize(0) == 1) {
```
https://github.com/llvm/llvm-project/pull/89059
More information about the Mlir-commits
mailing list