summaryrefslogtreecommitdiff
path: root/nn/runtime/test/TestPartitioningRandom.cpp
diff options
context:
space:
mode:
authorDavid Gross <dgross@google.com>2017-12-11 11:08:52 -0800
committerDavid Gross <dgross@google.com>2017-12-11 11:09:43 -0800
commit4ca2f53fa5cc243c9c812078129fe06c612852ba (patch)
treea0dd8463f70ccb1144a3622f6ce9ea96f4331b14 /nn/runtime/test/TestPartitioningRandom.cpp
parent663155d58ca1e1eb42e01495e236258e0c00d40f (diff)
downloadml-4ca2f53fa5cc243c9c812078129fe06c612852ba.tar.gz
Make RandomPartitioningTest more easily configuable.
Test: nn/runtime/test --gtest_filter=Seed/RandomPartitioningTest.Test/* Change-Id: Id4bdaf1fb7c64e5e52a83dda6f8f9aa7365a326e
Diffstat (limited to 'nn/runtime/test/TestPartitioningRandom.cpp')
-rw-r--r--nn/runtime/test/TestPartitioningRandom.cpp18
1 files changed, 16 insertions, 2 deletions
diff --git a/nn/runtime/test/TestPartitioningRandom.cpp b/nn/runtime/test/TestPartitioningRandom.cpp
index 0ffea49b8..381eb7afc 100644
--- a/nn/runtime/test/TestPartitioningRandom.cpp
+++ b/nn/runtime/test/TestPartitioningRandom.cpp
@@ -120,8 +120,20 @@ static const unsigned kMaxNumOperations = 100;
// not exceed this size.
static const unsigned kMaxProblemSize = 8;
+// First seed for pseudorandom test generation.
+static const unsigned kFirstSeed = 0;
+
+// Number of test cases.
static const unsigned kNumTestCases = 200;
+// Force all graph weights into a single pool (as we recommend to users)
+// or allow them to be distributed across multiple pools (more stress
+// on the partitioning algorithm and the rest of the runtime)?
+// Forcing all graph weights into a single pool may be necessary to
+// prevent large graphs from running up against http://b/70302693
+// "NNAPI overuses (?) fds".
+static const bool kAllWeightsInOnePool = false;
+
//////////////////////////////////////////////////////////////////////////////////
// The signature of an operation consists of the operation type (e.g.,
@@ -522,7 +534,8 @@ private:
const std::set<Signature> mSignatures;
};
-INSTANTIATE_TEST_CASE_P(Seed, RandomPartitioningTest, ::testing::Range(0U, kNumTestCases));
+INSTANTIATE_TEST_CASE_P(Seed, RandomPartitioningTest,
+ ::testing::Range(kFirstSeed, kFirstSeed + kNumTestCases));
TEST_P(RandomPartitioningTest, Test) {
LOG(INFO) << "RandomPartitioningTest: GetParam() = " << GetParam();
@@ -747,7 +760,8 @@ TEST_P(RandomPartitioningTest, Test) {
valueOperands.push_back(std::make_pair(operandIndex, ~0U));
} else {
unsigned memoryIndex = ~0U;
- if ((weights.memoryCount() != 0) && (randFrac() < 0.5)) {
+ if ((weights.memoryCount() != 0) &&
+ (kAllWeightsInOnePool || (randFrac() < 0.5))) {
memoryIndex = randUInt(weights.memoryCount());
} else {
memoryIndex = weights.addMemory();