Force CpuExecutor validating user-provided model output operands.
- For operands with OperandLifeTime::MODEL_OUTPUT, the dimensions,
type, and other meta-data must match the output Shape calculated
from the operation preparation step.
- Fix the ill-defined tests caught by the added validation.
- Incidental changes: generated more tests from tests specs.
Bug: 67390841
Test: NeuralNetworksTests pass
Change-Id: I40d35db0f7a868feae773dbf7e12cf4bf5f5e275
diff --git a/common/OperationsUtils.cpp b/common/OperationsUtils.cpp
index 537581a..d5beafc 100644
--- a/common/OperationsUtils.cpp
+++ b/common/OperationsUtils.cpp
@@ -505,7 +505,7 @@
outputShape->type = valueShape.type;
outputShape->dimensions = { lookups, columns };
for (uint32_t i = 2; i < getNumberOfDimensions(valueShape); i++) {
- outputShape->dimensions[i] = getSizeOfDimension(valueShape, i);
+ outputShape->dimensions.push_back(getSizeOfDimension(valueShape, i));
}
outputShape->offset = valueShape.offset;
outputShape->scale = valueShape.scale;
@@ -528,7 +528,7 @@
outputShape->type = valueShape.type;
outputShape->dimensions = { lookups };
for (uint32_t i = 1; i < getNumberOfDimensions(valueShape); i++) {
- outputShape->dimensions[i] = getSizeOfDimension(valueShape, i);
+ outputShape->dimensions.push_back(getSizeOfDimension(valueShape, i));
}
outputShape->offset = valueShape.offset;
outputShape->scale = valueShape.scale;