Create VTS tests for QoS in NNAPI
Bug: 136739795
Bug: 142902514
Bug: 145300530
Test: mma
Test: VtsHalNeuralnetworksV1_3TargetTest
Change-Id: If3ab91cfb3158e4c33e809ff3b149dff47cda76f
Merged-In: If3ab91cfb3158e4c33e809ff3b149dff47cda76f
(cherry picked from commit 616701d3cdb4108a0482cf4539ce7eaff270fc2e)
diff --git a/neuralnetworks/1.3/vts/functional/ValidateModel.cpp b/neuralnetworks/1.3/vts/functional/ValidateModel.cpp
index 43e53ef..a211428 100644
--- a/neuralnetworks/1.3/vts/functional/ValidateModel.cpp
+++ b/neuralnetworks/1.3/vts/functional/ValidateModel.cpp
@@ -44,12 +44,18 @@
}
static void validatePrepareModel(const sp<IDevice>& device, const std::string& message,
- const Model& model, ExecutionPreference preference) {
+ const Model& model, ExecutionPreference preference,
+ bool testDeadline) {
SCOPED_TRACE(message + " [prepareModel_1_3]");
+ OptionalTimePoint deadline;
+ if (testDeadline) {
+ deadline.nanoseconds(std::numeric_limits<uint64_t>::max());
+ }
+
sp<PreparedModelCallback> preparedModelCallback = new PreparedModelCallback();
Return<ErrorStatus> prepareLaunchStatus = device->prepareModel_1_3(
- model, preference, kDefaultPriority, {}, hidl_vec<hidl_handle>(),
+ model, preference, kDefaultPriority, deadline, hidl_vec<hidl_handle>(),
hidl_vec<hidl_handle>(), HidlToken(), preparedModelCallback);
ASSERT_TRUE(prepareLaunchStatus.isOk());
ASSERT_EQ(ErrorStatus::INVALID_ARGUMENT, static_cast<ErrorStatus>(prepareLaunchStatus));
@@ -73,12 +79,13 @@
// to the model does not leave this function.
static void validate(const sp<IDevice>& device, const std::string& message, Model model,
const std::function<void(Model*)>& mutation,
- ExecutionPreference preference = ExecutionPreference::FAST_SINGLE_ANSWER) {
+ ExecutionPreference preference = ExecutionPreference::FAST_SINGLE_ANSWER,
+ bool testDeadline = false) {
mutation(&model);
- if (validExecutionPreference(preference)) {
+ if (validExecutionPreference(preference) && !testDeadline) {
validateGetSupportedOperations(device, message, model);
}
- validatePrepareModel(device, message, model, preference);
+ validatePrepareModel(device, message, model, preference, testDeadline);
}
static uint32_t addOperand(Model* model) {
@@ -714,9 +721,19 @@
}
}
+///////////////////////// DEADLINE /////////////////////////
+
+static void deadlineTest(const sp<IDevice>& device, const Model& model) {
+ const std::string message = "deadlineTest: deadline not supported";
+ const auto noop = [](Model*) {};
+ validate(device, message, model, noop, ExecutionPreference::FAST_SINGLE_ANSWER,
+ /*testDeadline=*/true);
+}
+
////////////////////////// ENTRY POINT //////////////////////////////
-void validateModel(const sp<IDevice>& device, const Model& model) {
+void validateModel(const sp<IDevice>& device, const Model& model,
+ bool prepareModelDeadlineSupported) {
mutateOperandTypeTest(device, model);
mutateOperandRankTest(device, model);
mutateOperandScaleTest(device, model);
@@ -732,6 +749,9 @@
addOperationInputTest(device, model);
addOperationOutputTest(device, model);
mutateExecutionPreferenceTest(device, model);
+ if (!prepareModelDeadlineSupported) {
+ deadlineTest(device, model);
+ }
}
} // namespace android::hardware::neuralnetworks::V1_3::vts::functional