[Mlir-commits] [mlir] [mlir][tosa] Fix bf16 reduction accumulator widening (PR #192045)

Luke Hutton llvmlistbot at llvm.org
Tue Apr 14 07:18:08 PDT 2026


================
@@ -1172,9 +1172,11 @@ static LogicalResult reduceMatchAndRewriteHelper(OpTy op, uint64_t axis,
   Value input = op->getOperand(0);
 
   // Figure out the accType if needed
-  bool widenAccTy = std::is_same_v<OpTy, tosa::ReduceSumOp> &&
-                    isa<FloatType>(elementTy) &&
-                    cast<FloatType>(elementTy).isBF16();
+  const bool needsFp32AccTy =
+      isa<FloatType>(elementTy) && cast<FloatType>(elementTy).isBF16();
+  const bool widenAccTy = (std::is_same_v<OpTy, tosa::ReduceSumOp> ||
+                           std::is_same_v<OpTy, tosa::ReduceProductOp>) &&
----------------
lhutton1 wrote:

The spec pseudo-code seems to suggest REDUCE_PRODUCT uses an acc type of bf16? (see https://www.mlplatform.org/tosa/tosa_spec_1_0_1.html#_reduce_product), is this an intentional deviation?

https://github.com/llvm/llvm-project/pull/192045


More information about the Mlir-commits mailing list