blob: 0b8b917b0aca0ceb9d9343bd0389103e8028d062 [file] [log] [blame]
Slava Shklyaev1d6b4652019-05-14 14:15:14 +01001/*
2 * Copyright (C) 2019 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef ANDROID_HARDWARE_NEURALNETWORKS_V1_2_GENERATED_TEST_HARNESS_H
18#define ANDROID_HARDWARE_NEURALNETWORKS_V1_2_GENERATED_TEST_HARNESS_H
19
20#include <android/hardware/neuralnetworks/1.2/IDevice.h>
21#include <android/hardware/neuralnetworks/1.2/IPreparedModel.h>
22#include <android/hardware/neuralnetworks/1.2/types.h>
23#include <functional>
24#include <vector>
25#include "TestHarness.h"
Xusong Wang9e2b97b2019-08-23 16:10:54 -070026#include "VtsHalNeuralnetworks.h"
Slava Shklyaev1d6b4652019-05-14 14:15:14 +010027
Michael Butlerbbe5dad2019-08-26 23:55:47 -070028namespace android::hardware::neuralnetworks::V1_2::vts::functional {
Xusong Wang9e2b97b2019-08-23 16:10:54 -070029
30class GeneratedTestBase
31 : public NeuralnetworksHidlTest,
Michael Butlere16af0a2019-08-29 22:17:24 -070032 public testing::WithParamInterface<test_helper::TestModelManager::TestParam> {
Xusong Wang9e2b97b2019-08-23 16:10:54 -070033 protected:
Michael Butlere16af0a2019-08-29 22:17:24 -070034 const test_helper::TestModel& kTestModel = *GetParam().second;
Xusong Wang9e2b97b2019-08-23 16:10:54 -070035};
36
Michael Butlere16af0a2019-08-29 22:17:24 -070037#define INSTANTIATE_GENERATED_TEST(TestSuite, filter) \
38 INSTANTIATE_TEST_SUITE_P( \
39 TestGenerated, TestSuite, \
40 testing::ValuesIn(::test_helper::TestModelManager::get().getTestModels(filter)), \
Xusong Wang9e2b97b2019-08-23 16:10:54 -070041 [](const auto& info) { return info.param.first; })
42
43// Tag for the validation tests, instantiated in VtsHalNeuralnetworks.cpp.
44// TODO: Clean up the hierarchy for ValidationTest.
Michael Butlere16af0a2019-08-29 22:17:24 -070045class ValidationTest : public GeneratedTestBase {};
Slava Shklyaev1d6b4652019-05-14 14:15:14 +010046
Xusong Wang491b0a82019-08-09 16:45:24 -070047Model createModel(const ::test_helper::TestModel& testModel);
Slava Shklyaev1d6b4652019-05-14 14:15:14 +010048
Michael Butlerbbe5dad2019-08-26 23:55:47 -070049void PrepareModel(const sp<IDevice>& device, const Model& model, sp<IPreparedModel>* preparedModel);
Slava Shklyaev1d6b4652019-05-14 14:15:14 +010050
Michael Butlerbbe5dad2019-08-26 23:55:47 -070051void EvaluatePreparedModel(const sp<IPreparedModel>& preparedModel,
Xusong Wang491b0a82019-08-09 16:45:24 -070052 const ::test_helper::TestModel& testModel, bool testDynamicOutputShape);
Slava Shklyaev1d6b4652019-05-14 14:15:14 +010053
Michael Butlerbbe5dad2019-08-26 23:55:47 -070054} // namespace android::hardware::neuralnetworks::V1_2::vts::functional
Slava Shklyaev1d6b4652019-05-14 14:15:14 +010055
56#endif // ANDROID_HARDWARE_NEURALNETWORKS_V1_2_GENERATED_TEST_HARNESS_H