Fix validateRequest with unknown rank in model.

This CL also re-enables TestUnspecifiedDimensions, which will trigger
the bug in validateRequest when sample driver is deployed.

Bug: 141294076
Fixes: 155228680
Test: NNT_static with sample driver
Change-Id: I268eb67bda8933be180bd58b604ee76b72577697
Merged-In: I268eb67bda8933be180bd58b604ee76b72577697
(cherry picked from commit 342c939b13b6227de2fb2f7bdc8662fc720c6d8a)
diff --git a/common/ValidateHal.cpp b/common/ValidateHal.cpp
index f0415df..5668ff5 100644
--- a/common/ValidateHal.cpp
+++ b/common/ValidateHal.cpp
@@ -770,11 +770,12 @@
                 return false;
             }
             // If the argument specified a dimension, validate it.
-            uint32_t rank = requestArgument.dimensions.size();
-            if (rank == 0) {
+            uint32_t modelRank = operand.dimensions.size();
+            uint32_t requestRank = requestArgument.dimensions.size();
+            if (requestRank == 0) {
                 if (!allowUnspecified) {
                     // Validate that all the dimensions are specified in the model.
-                    for (size_t i = 0; i < operand.dimensions.size(); i++) {
+                    for (size_t i = 0; i < modelRank; i++) {
                         if (operand.dimensions[i] == 0) {
                             LOG(ERROR) << "Model has dimension " << i
                                        << " set to 0 but the request does specify the dimension.";
@@ -783,15 +784,14 @@
                     }
                 }
             } else {
-                if (rank != operand.dimensions.size()) {
+                if (modelRank != 0 && requestRank != modelRank) {
                     LOG(ERROR) << "Request " << type << " " << requestArgumentIndex
-                               << " has number of dimensions (" << rank
-                               << ") different than the model's (" << operand.dimensions.size()
-                               << ")";
+                               << " has number of dimensions (" << requestRank
+                               << ") different than the model's (" << modelRank << ")";
                     return false;
                 }
-                for (size_t i = 0; i < rank; i++) {
-                    if (requestArgument.dimensions[i] != operand.dimensions[i] &&
+                for (size_t i = 0; i < requestRank; i++) {
+                    if (modelRank != 0 && requestArgument.dimensions[i] != operand.dimensions[i] &&
                         operand.dimensions[i] != 0) {
                         LOG(ERROR)
                                 << "Request " << type << " " << requestArgumentIndex