diff options
author | Xusong Wang <xusongw@google.com> | 2020-03-17 17:36:17 -0700 |
---|---|---|
committer | Xusong Wang <xusongw@google.com> | 2020-03-18 14:57:33 -0700 |
commit | 397d2a01f7c3da5faeb2c9039bf4110050e28002 (patch) | |
tree | 9d9546b85a3d88a21c0c06154941f1395f418192 /nn/runtime/test/fuzzing | |
parent | 039b11ee572b3e85ce879bdce6859161747ac09b (diff) | |
download | ml-397d2a01f7c3da5faeb2c9039bf4110050e28002.tar.gz |
Support omitted operand in RGG.
Bug: 132323720
Test: NNT_static_fuzzing
Change-Id: Iaf1d9b66be98f40ae04b732dc778951a236757c8
Diffstat (limited to 'nn/runtime/test/fuzzing')
-rw-r--r-- | nn/runtime/test/fuzzing/RandomGraphGenerator.cpp | 23 | ||||
-rw-r--r-- | nn/runtime/test/fuzzing/RandomGraphGenerator.h | 2 | ||||
-rw-r--r-- | nn/runtime/test/fuzzing/RandomGraphGeneratorUtils.h | 2 |
3 files changed, 20 insertions, 7 deletions
diff --git a/nn/runtime/test/fuzzing/RandomGraphGenerator.cpp b/nn/runtime/test/fuzzing/RandomGraphGenerator.cpp index a6e6f9ec9..e6f9eea9e 100644 --- a/nn/runtime/test/fuzzing/RandomGraphGenerator.cpp +++ b/nn/runtime/test/fuzzing/RandomGraphGenerator.cpp @@ -189,7 +189,8 @@ bool RandomGraph::generateValue() { if (operand->type == RandomOperandType::INPUT) numInputs--; operand->type = RandomOperandType::CONST; } - if (operand->type != RandomOperandType::INTERNAL) { + if (operand->type != RandomOperandType::INTERNAL && + operand->type != RandomOperandType::NO_VALUE) { if (operand->buffer.empty()) operand->resizeBuffer<uint8_t>(operand->getBufferSize()); // If operand is set by randomBuffer, copy the frozen values into buffer. if (!operand->randomBuffer.empty()) { @@ -218,6 +219,8 @@ static TestOperandLifeTime convertToTestOperandLifeTime(RandomOperandType type) return TestOperandLifeTime::TEMPORARY_VARIABLE; case RandomOperandType::CONST: return TestOperandLifeTime::CONSTANT_COPY; + case RandomOperandType::NO_VALUE: + return TestOperandLifeTime::NO_VALUE; } } @@ -241,10 +244,20 @@ TestModel RandomGraph::createTestModel() { }; // Test buffers. - if (testOperand.lifetime == TestOperandLifeTime::SUBGRAPH_OUTPUT) { - testOperand.data = TestBuffer(operand->getBufferSize()); - } else if (testOperand.lifetime != TestOperandLifeTime::TEMPORARY_VARIABLE) { - testOperand.data = TestBuffer(operand->getBufferSize(), operand->buffer.data()); + switch (testOperand.lifetime) { + case TestOperandLifeTime::SUBGRAPH_OUTPUT: + testOperand.data = TestBuffer(operand->getBufferSize()); + break; + case TestOperandLifeTime::SUBGRAPH_INPUT: + case TestOperandLifeTime::CONSTANT_COPY: + case TestOperandLifeTime::CONSTANT_REFERENCE: + testOperand.data = TestBuffer(operand->getBufferSize(), operand->buffer.data()); + break; + case TestOperandLifeTime::TEMPORARY_VARIABLE: + case TestOperandLifeTime::NO_VALUE: + break; + default: + NN_FUZZER_CHECK(false) << "Unknown lifetime"; } // Input/Output indexes. diff --git a/nn/runtime/test/fuzzing/RandomGraphGenerator.h b/nn/runtime/test/fuzzing/RandomGraphGenerator.h index 3c45aed9c..c152ee62c 100644 --- a/nn/runtime/test/fuzzing/RandomGraphGenerator.h +++ b/nn/runtime/test/fuzzing/RandomGraphGenerator.h @@ -35,7 +35,7 @@ struct OperandSignature; struct OperationSignature; class OperationManager; -enum class RandomOperandType { INPUT = 0, OUTPUT = 1, INTERNAL = 2, CONST = 3 }; +enum class RandomOperandType { INPUT = 0, OUTPUT = 1, INTERNAL = 2, CONST = 3, NO_VALUE = 4 }; struct RandomOperand { RandomOperandType type; diff --git a/nn/runtime/test/fuzzing/RandomGraphGeneratorUtils.h b/nn/runtime/test/fuzzing/RandomGraphGeneratorUtils.h index af155a859..fff632019 100644 --- a/nn/runtime/test/fuzzing/RandomGraphGeneratorUtils.h +++ b/nn/runtime/test/fuzzing/RandomGraphGeneratorUtils.h @@ -201,7 +201,7 @@ inline std::string toString<RandomVariableRange>(const RandomVariableRange& rang template <> inline std::string toString<RandomOperandType>(const RandomOperandType& type) { - static const std::string typeNames[] = {"Input", "Output", "Internal", "Parameter"}; + static const std::string typeNames[] = {"Input", "Output", "Internal", "Parameter", "No Value"}; return typeNames[static_cast<int>(type)]; } |