From 0369930b962f911ffbe8437503d931393e444519 Mon Sep 17 00:00:00 2001 From: Rickard Bolin Date: Mon, 17 Feb 2025 17:08:23 +0000 Subject: [PATCH] MLBEDSW-10451: Fix 1D and 2D Reduce_Sum Incorrect shape used to calculate sizes when reshaping to 3D Change-Id: Ie8ddf8f7397ea68a1e4bcb0361b99a18b1235112 Signed-off-by: Rickard Bolin --- ethosu/regor/compiler/graphir_optimiser.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ethosu/regor/compiler/graphir_optimiser.cpp b/ethosu/regor/compiler/graphir_optimiser.cpp index 893efbfb..220e6f31 100644 --- a/ethosu/regor/compiler/graphir_optimiser.cpp +++ b/ethosu/regor/compiler/graphir_optimiser.cpp @@ -1426,7 +1426,8 @@ Operation *GraphIrOptimiser::RewriteReduceSum(Graph *const graph, Operation *con // 2. 1x1 Conv2D (1x1x1xC weights): HxWxC -> HxWx1. // Reshape to 4D shape (NHWC) where C dimension is the dimension to reduce - const Shape ifmShape3D = ReshapeTo3D(Shape::PadAxes(ifmConn->shape, 3, 1), {ifmConn->shape.Size() - 2, 1, 1}); + Shape paddedIfmShape = Shape::PadAxes(ifmConn->shape, 3, 1); + const Shape ifmShape3D = ReshapeTo3D(paddedIfmShape, {paddedIfmShape.Size() - 2, 1, 1}); const Shape ifmShape4D = Shape::PadAxes(ifmShape3D, 4, 1); // Create an identity 1x1x1xC weights tensor -- GitLab