summaryrefslogtreecommitdiff
path: root/nn/runtime/test/TestGenerated.cpp
diff options
context:
space:
mode:
authorMiao Wang <miaowang@google.com>2018-03-20 11:40:37 -0700
committerMiao Wang <miaowang@google.com>2018-04-04 17:37:27 -0700
commit29fea0ce47a782c4edc2172034a93a2479844780 (patch)
tree520fab91051ff957e5d4a2a7d930029132cf9f15 /nn/runtime/test/TestGenerated.cpp
parent68b32d482cfb320be614b3aa68f57cc9f2e78a5b (diff)
downloadml-29fea0ce47a782c4edc2172034a93a2479844780.tar.gz
Enforce validations for ANeuralNetworksExecution_setInput/Output
- Optional output / input must have both nullptr as buffer and 0 as length. - If newType is NULL, the operand dimensions must be fully specified. And ModelArgumentInfo.dimensions will be the same as the operand dimensions. - For non-optional input / output, user provided length must match the operand size. Bug: 75980924 Test: mm Test: NeuralNetworksTests Merged-In: Iaa8f8193c8a6911afd0990fcf0659d0050de833b Change-Id: Iaa8f8193c8a6911afd0990fcf0659d0050de833b (cherry picked from commit 43d018d1a66872031568857fa369024c9640a085)
Diffstat (limited to 'nn/runtime/test/TestGenerated.cpp')
-rw-r--r--nn/runtime/test/TestGenerated.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/nn/runtime/test/TestGenerated.cpp b/nn/runtime/test/TestGenerated.cpp
index 5e6158f9d..e584044c6 100644
--- a/nn/runtime/test/TestGenerated.cpp
+++ b/nn/runtime/test/TestGenerated.cpp
@@ -94,14 +94,16 @@ static void execute(std::function<void(Model*)> createModel,
// Set all inputs
for_all(inputs, [&execution](int idx, const void* p, size_t s) {
- ASSERT_EQ(Result::NO_ERROR, execution.setInput(idx, p, s));
+ const void* buffer = s == 0 ? nullptr : p;
+ ASSERT_EQ(Result::NO_ERROR, execution.setInput(idx, buffer, s));
});
MixedTyped test;
// Go through all typed outputs
resize_accordingly(golden, test);
for_all(test, [&execution](int idx, void* p, size_t s) {
- ASSERT_EQ(Result::NO_ERROR, execution.setOutput(idx, p, s));
+ void* buffer = s == 0 ? nullptr : p;
+ ASSERT_EQ(Result::NO_ERROR, execution.setOutput(idx, buffer, s));
});
Result r = execution.compute();