diff options
author | Michael Butler <butlermichael@google.com> | 2019-11-05 18:28:56 -0800 |
---|---|---|
committer | Michael Butler <butlermichael@google.com> | 2019-11-05 18:28:56 -0800 |
commit | 517df2f0fc362e3f12241760d044ec12cd4784ca (patch) | |
tree | 1e6c4f33000d58ec9dfbc4b542b9c46b76ae1e37 /nn/runtime/test/android_fuzzing | |
parent | 95ded31c2c147b1ecf91257d35c0089b1ebd4851 (diff) | |
download | ml-517df2f0fc362e3f12241760d044ec12cd4784ca.tar.gz |
Add extra validation to libneuralnetworks_fuzzer
Bug: 143985934
Test: mma
Test: libneuralnetworks_fuzzer
Change-Id: I566fe442f99249de7f547e666b0252f6aee28cea
Diffstat (limited to 'nn/runtime/test/android_fuzzing')
-rw-r--r-- | nn/runtime/test/android_fuzzing/FuzzTest.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/nn/runtime/test/android_fuzzing/FuzzTest.cpp b/nn/runtime/test/android_fuzzing/FuzzTest.cpp index fecd2d7f9..40a028877 100644 --- a/nn/runtime/test/android_fuzzing/FuzzTest.cpp +++ b/nn/runtime/test/android_fuzzing/FuzzTest.cpp @@ -65,22 +65,23 @@ std::optional<Model> CreateModel(const TestModel& testModel) { // Nothing to do here. break; } + if (!model.isValid()) return std::nullopt; } // Operations. for (const auto& operation : testModel.operations) { model.addOperation(static_cast<int>(operation.type), operation.inputs, operation.outputs); + if (!model.isValid()) return std::nullopt; } // Inputs and outputs. model.identifyInputsAndOutputs(testModel.inputIndexes, testModel.outputIndexes); + if (!model.isValid()) return std::nullopt; // Relaxed computation. model.relaxComputationFloat32toFloat16(testModel.isRelaxed); + if (!model.isValid()) return std::nullopt; - if (!model.isValid()) { - return std::nullopt; - } if (model.finish() != Result::NO_ERROR) { return std::nullopt; } |