summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXusong Wang <xusongw@google.com>2020-08-21 06:15:14 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2020-08-21 06:15:14 +0000
commit710735cab5cea6c188f3ea217f8d5601f4686f67 (patch)
tree4b6cf4536b16d1f154dcf3f0578a1668ac712f53
parentc637d993570cbc22e8c72894c02f8172243a2afe (diff)
parent6445511313395109be689d9649965c2e183c4747 (diff)
downloadml-710735cab5cea6c188f3ea217f8d5601f4686f67.tar.gz
Fix mixed-build CTS failures. am: 6445511313
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/ml/+/12283218 Change-Id: I7acdae6818fb9ceb7f054deae63d39a098c817db
-rw-r--r--nn/runtime/test/GeneratedTestUtils.h2
-rw-r--r--nn/runtime/test/TestGenerated.cpp36
-rw-r--r--nn/runtime/test/fuzzing/TestRandomGraph.cpp10
3 files changed, 47 insertions, 1 deletions
diff --git a/nn/runtime/test/GeneratedTestUtils.h b/nn/runtime/test/GeneratedTestUtils.h
index 3ac5cba03..1354f6749 100644
--- a/nn/runtime/test/GeneratedTestUtils.h
+++ b/nn/runtime/test/GeneratedTestUtils.h
@@ -20,6 +20,7 @@
#include <gtest/gtest.h>
#include <memory>
+#include <string>
#include <utility>
#include <vector>
@@ -31,6 +32,7 @@ namespace android::nn::generated_tests {
class GeneratedTestBase
: public ::testing::TestWithParam<test_helper::TestModelManager::TestParam> {
protected:
+ const std::string& kTestName = GetParam().first;
const test_helper::TestModel& testModel = *GetParam().second;
};
diff --git a/nn/runtime/test/TestGenerated.cpp b/nn/runtime/test/TestGenerated.cpp
index a76aecd92..70b0e6f72 100644
--- a/nn/runtime/test/TestGenerated.cpp
+++ b/nn/runtime/test/TestGenerated.cpp
@@ -15,6 +15,7 @@
*/
#include <android-base/logging.h>
+#include <android-base/properties.h>
#include <ftw.h>
#include <gtest/gtest.h>
#include <unistd.h>
@@ -26,6 +27,7 @@
#include <iostream>
#include <map>
#include <memory>
+#include <set>
#include <string>
#include <thread>
#include <utility>
@@ -60,6 +62,8 @@ class GeneratedTests : public GeneratedTestBase {
void SetUp() override;
void TearDown() override;
+ bool shouldSkipTest();
+
std::optional<Compilation> compileModel(const Model& model);
void executeWithCompilation(const Compilation& compilation, const TestModel& testModel);
void executeOnce(const Model& model, const TestModel& testModel);
@@ -68,6 +72,9 @@ class GeneratedTests : public GeneratedTestBase {
// Test driver for those generated from ml/nn/runtime/test/spec
void execute(const TestModel& testModel);
+ // VNDK version of the device under test.
+ static int mVndkVersion;
+
std::string mCacheDir;
std::vector<uint8_t> mToken;
bool mTestCompilationCaching = false;
@@ -77,6 +84,8 @@ class GeneratedTests : public GeneratedTestBase {
bool mTestDeviceMemory = false;
};
+int GeneratedTests::mVndkVersion = __ANDROID_API_FUTURE__;
+
// Tag for the dynamic output shape tests
class DynamicOutputShapeTest : public GeneratedTests {
protected:
@@ -328,8 +337,35 @@ void GeneratedTests::execute(const TestModel& testModel) {
}
}
+bool GeneratedTests::shouldSkipTest() {
+ // A map of {min VNDK version -> tests that should be skipped with earlier VNDK versions}.
+ // The listed tests are added in a later release, but exercising old APIs. They should be
+ // skipped if the device has a mixed build of system and vendor partitions.
+ static const std::map<int, std::set<std::string>> kMapOfMinVndkVersionToTests = {
+ {
+ __ANDROID_API_R__,
+ {
+ "add_broadcast_quant8_all_inputs_as_internal",
+ },
+ },
+ };
+ for (const auto& [minVersion, names] : kMapOfMinVndkVersionToTests) {
+ if (mVndkVersion < minVersion && names.count(kTestName) > 0) {
+ return true;
+ }
+ }
+ return false;
+}
+
void GeneratedTests::SetUp() {
GeneratedTestBase::SetUp();
+
+ mVndkVersion = ::android::base::GetIntProperty("ro.vndk.version", __ANDROID_API_FUTURE__);
+ if (shouldSkipTest()) {
+ GTEST_SKIP();
+ return;
+ }
+
char cacheDirTemp[] = "/data/local/tmp/TestCompilationCachingXXXXXX";
char* cacheDir = mkdtemp(cacheDirTemp);
ASSERT_NE(cacheDir, nullptr);
diff --git a/nn/runtime/test/fuzzing/TestRandomGraph.cpp b/nn/runtime/test/fuzzing/TestRandomGraph.cpp
index 2c8024a22..fc73bc2a3 100644
--- a/nn/runtime/test/fuzzing/TestRandomGraph.cpp
+++ b/nn/runtime/test/fuzzing/TestRandomGraph.cpp
@@ -14,6 +14,7 @@
* limitations under the License.
*/
+#include <android-base/properties.h>
#include <gtest/gtest.h>
#include <algorithm>
@@ -31,7 +32,6 @@
#include "fuzzing/RandomGraphGeneratorUtils.h"
#ifndef NNTEST_CTS
-#include <android-base/properties.h>
#include <memunreachable/memunreachable.h>
#include <vector>
@@ -152,6 +152,7 @@ class RandomGraphTest : public ::testing::TestWithParam<uint32_t> {
mSyntheticDevices.push_back(makeTestDevice<TestDriverV1_1>());
mSyntheticDevices.push_back(makeTestDevice<TestDriverV1_0>());
#endif
+ mVndkVersion = ::android::base::GetIntProperty("ro.vndk.version", __ANDROID_API_FUTURE__);
// Get all the devices and device names.
mStandardDevicesFeatureLevel = __ANDROID_API_FUTURE__;
@@ -225,6 +226,11 @@ class RandomGraphTest : public ::testing::TestWithParam<uint32_t> {
featureLevel <= __ANDROID_API_Q__) {
return true;
}
+ // Skip the following operations when the VNDK version is earlier than R.
+ if (mVndkVersion < __ANDROID_API_R__ &&
+ op.type == TestOperationType::HEATMAP_MAX_KEYPOINT) {
+ return true;
+ }
}
return false;
}
@@ -433,6 +439,7 @@ class RandomGraphTest : public ::testing::TestWithParam<uint32_t> {
// A vector of {name, output_results}.
std::vector<std::pair<std::string, std::vector<TestBuffer>>> mResults;
+ static int mVndkVersion;
static int64_t mStandardDevicesFeatureLevel; // minimum across all devices
#ifndef NNTEST_CTS
static std::vector<std::shared_ptr<Device>> mStandardDevices;
@@ -445,6 +452,7 @@ bool RandomGraphTest::mDumpSpec = false;
bool RandomGraphTest::mDetectMemoryLeak = false;
std::map<std::string, ANeuralNetworksDevice*> RandomGraphTest::mDevices;
+int RandomGraphTest::mVndkVersion = __ANDROID_API_FUTURE__;
int64_t RandomGraphTest::mStandardDevicesFeatureLevel;
#ifndef NNTEST_CTS
std::vector<std::shared_ptr<Device>> RandomGraphTest::mStandardDevices;