diff options
author | Michael Butler <butlermichael@google.com> | 2020-11-13 01:46:02 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2020-11-13 01:46:02 +0000 |
commit | 638a57c1b06b4369487c6d36ae6c7bbc245ec14d (patch) | |
tree | 03222db8d106f161bed47c1e3f156dd28eb4ed4c | |
parent | d721244c09f05f03bbde16a622425e0d27fa6c36 (diff) | |
parent | 8250ec9e013fa53237f385deb9e6fdc127f79c93 (diff) | |
download | ml-638a57c1b06b4369487c6d36ae6c7bbc245ec14d.tar.gz |
Merge "Remove HAL types from NNAPI fuzz test harness"
-rw-r--r-- | nn/runtime/test/android_fuzzing/Android.bp | 2 | ||||
-rw-r--r-- | nn/runtime/test/android_fuzzing/Converter.cpp | 11 | ||||
-rw-r--r-- | nn/runtime/test/android_fuzzing/FuzzHarness.cpp | 9 |
3 files changed, 10 insertions, 12 deletions
diff --git a/nn/runtime/test/android_fuzzing/Android.bp b/nn/runtime/test/android_fuzzing/Android.bp index 02a32256f..89ce1ea78 100644 --- a/nn/runtime/test/android_fuzzing/Android.bp +++ b/nn/runtime/test/android_fuzzing/Android.bp @@ -40,7 +40,6 @@ cc_library_static { "libprotobuf-cpp-full", ], static_libs: [ - "android.hardware.neuralnetworks@1.3", "libneuralnetworks_common", "libneuralnetworks_generated_test_harness", "libneuralnetworks_static", @@ -48,6 +47,7 @@ cc_library_static { whole_static_libs: [ "libneuralnetworks_fuzzer_proto", "libprotobuf-mutator", + "neuralnetworks_types", ], } diff --git a/nn/runtime/test/android_fuzzing/Converter.cpp b/nn/runtime/test/android_fuzzing/Converter.cpp index c2fc354fa..4733b3b55 100644 --- a/nn/runtime/test/android_fuzzing/Converter.cpp +++ b/nn/runtime/test/android_fuzzing/Converter.cpp @@ -17,14 +17,13 @@ #include "Converter.h" #include <android-base/logging.h> +#include <nnapi/TypeUtils.h> #include <algorithm> #include <random> #include <utility> #include <vector> -#include "Utils.h" - namespace android::nn::fuzz { namespace { @@ -78,11 +77,11 @@ TestOperand convert(const android_nn_fuzz::Operand& operand) { auto channelQuant = convert(operand.channel_quant()); const bool isIgnored = false; - const auto halType = static_cast<V1_3::OperandType>(type); - const bool willOverflow = nonExtensionOperandSizeOfDataOverflowsUInt32(halType, dimensions); + const auto opType = static_cast<OperandType>(type); + const size_t size = getNonExtensionSize(opType, dimensions).value_or(0); const bool makeEmpty = (lifetime == TestOperandLifeTime::NO_VALUE || - lifetime == TestOperandLifeTime::TEMPORARY_VARIABLE || willOverflow); - const size_t bufferSize = makeEmpty ? 0 : nonExtensionOperandSizeOfData(halType, dimensions); + lifetime == TestOperandLifeTime::TEMPORARY_VARIABLE); + const size_t bufferSize = makeEmpty ? 0 : size; TestBuffer data = convert(bufferSize, operand.data()); return {.type = type, diff --git a/nn/runtime/test/android_fuzzing/FuzzHarness.cpp b/nn/runtime/test/android_fuzzing/FuzzHarness.cpp index 76c34a75a..17dac3ab9 100644 --- a/nn/runtime/test/android_fuzzing/FuzzHarness.cpp +++ b/nn/runtime/test/android_fuzzing/FuzzHarness.cpp @@ -14,7 +14,7 @@ * limitations under the License. */ -#include <android/hardware/neuralnetworks/1.3/types.h> +#include <nnapi/TypeUtils.h> #include <src/libfuzzer/libfuzzer_macro.h> #include <algorithm> @@ -22,22 +22,21 @@ #include "Converter.h" #include "Model.pb.h" #include "TestHarness.h" -#include "Utils.h" // Fuzz test logic. This function will either run to completion and return, or crash. extern void nnapiFuzzTest(const ::test_helper::TestModel& testModel); namespace { -using ::android::nn::nonExtensionOperandSizeOfDataOverflowsUInt32; +using ::android::nn::getNonExtensionSize; +using ::android::nn::OperandType; using ::android::nn::fuzz::convertToTestModel; -using ::android::nn::V1_3::OperandType; using ::test_helper::TestModel; using ::test_helper::TestOperand; bool operandOverflows(const TestOperand& operand) { const auto operandType = static_cast<OperandType>(operand.type); - return nonExtensionOperandSizeOfDataOverflowsUInt32(operandType, operand.dimensions); + return getNonExtensionSize(operandType, operand.dimensions).has_value(); } bool shouldSkip(const TestModel& model) { |