diff --git a/ethosu/regor/compiler/graphir_optimiser.cpp b/ethosu/regor/compiler/graphir_optimiser.cpp index 893efbfb3a0274e125cff32fd7937010c5d221a3..220e6f31c5dac77491042ea62c8503ee87b1691d 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