Fix null ptr dereference in REDUCE_* cpu implementation

When asked to reduce across all dimensions, reduce would produce a
zero-sized tensor without dimensions and cause segmentation fault in the
implementation.

The change fixes the bug by making the op output a tensor of size [1] in
this case.

Also, updated the bug to clarify this behaviour.

Bug: 155508675
Test: NNTest_static
Change-Id: Ie98d8fa2e508255fd50f6bd8184dc323ba90fac8
Merged-In: Ie98d8fa2e508255fd50f6bd8184dc323ba90fac8
(cherry picked from commit 62160e554e7abf4a29be003dd5938c65d70f649a)
diff --git a/common/operations/Reduce.cpp b/common/operations/Reduce.cpp
index d11b762..220a4dc 100644
--- a/common/operations/Reduce.cpp
+++ b/common/operations/Reduce.cpp
@@ -155,6 +155,11 @@
         }
     }
 
+    // Handle the case when all dimensions are removed
+    if (outputShape.dimensions.empty()) {
+        outputShape.dimensions.push_back(1);
+    }
+
     return context->setOutputShape(kOutputTensor, outputShape);
 }