blob: 56f3c0b7e21e2293a07570ecd7159825340413e2 [file] [log] [blame]
Slava Shklyaev73ee79d2019-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#include "GeneratedTestHarness.h"
18
19#include <android-base/logging.h>
20#include <android/hardware/neuralnetworks/1.0/IDevice.h>
21#include <android/hardware/neuralnetworks/1.0/IExecutionCallback.h>
22#include <android/hardware/neuralnetworks/1.0/IPreparedModel.h>
23#include <android/hardware/neuralnetworks/1.0/IPreparedModelCallback.h>
24#include <android/hardware/neuralnetworks/1.0/types.h>
25#include <android/hardware/neuralnetworks/1.1/IDevice.h>
26#include <android/hardware/neuralnetworks/1.2/IDevice.h>
27#include <android/hardware/neuralnetworks/1.2/IExecutionCallback.h>
28#include <android/hardware/neuralnetworks/1.2/IPreparedModel.h>
29#include <android/hardware/neuralnetworks/1.2/IPreparedModelCallback.h>
30#include <android/hidl/allocator/1.0/IAllocator.h>
31#include <android/hidl/memory/1.0/IMemory.h>
Lev Proleev56cda832019-12-05 14:49:47 +000032#include <gtest/gtest.h>
Slava Shklyaev73ee79d2019-05-14 14:15:14 +010033#include <hidlmemory/mapping.h>
34
Xusong Wangead950d2019-08-09 16:45:24 -070035#include <algorithm>
Michael Butler648ada52019-07-25 17:22:11 -070036#include <chrono>
Slava Shklyaev73ee79d2019-05-14 14:15:14 +010037#include <iostream>
Xusong Wangead950d2019-08-09 16:45:24 -070038#include <numeric>
Lev Proleev56cda832019-12-05 14:49:47 +000039#include <vector>
Slava Shklyaev73ee79d2019-05-14 14:15:14 +010040
41#include "1.0/Utils.h"
42#include "1.2/Callbacks.h"
43#include "ExecutionBurstController.h"
44#include "MemoryUtils.h"
45#include "TestHarness.h"
Xusong Wangbcaa7822019-08-23 16:10:54 -070046#include "VtsHalNeuralnetworks.h"
Slava Shklyaev73ee79d2019-05-14 14:15:14 +010047
Michael Butler62749b92019-08-26 23:55:47 -070048namespace android::hardware::neuralnetworks::V1_2::vts::functional {
Slava Shklyaev73ee79d2019-05-14 14:15:14 +010049
Xusong Wangead950d2019-08-09 16:45:24 -070050using namespace test_helper;
Michael Butler62749b92019-08-26 23:55:47 -070051using hidl::memory::V1_0::IMemory;
52using implementation::ExecutionCallback;
53using implementation::PreparedModelCallback;
54using V1_0::DataLocation;
55using V1_0::ErrorStatus;
56using V1_0::OperandLifeTime;
57using V1_0::Request;
58using V1_1::ExecutionPreference;
Slava Shklyaev73ee79d2019-05-14 14:15:14 +010059using HidlToken = hidl_array<uint8_t, static_cast<uint32_t>(Constant::BYTE_SIZE_OF_CACHE_TOKEN)>;
60
Lev Proleev0d4ba3f2019-10-02 17:32:06 +010061namespace {
62
63enum class Executor { ASYNC, SYNC, BURST };
64
Xusong Wangead950d2019-08-09 16:45:24 -070065enum class OutputType { FULLY_SPECIFIED, UNSPECIFIED, INSUFFICIENT };
66
Lev Proleev0d4ba3f2019-10-02 17:32:06 +010067struct TestConfig {
68 Executor executor;
69 MeasureTiming measureTiming;
70 OutputType outputType;
Xusong Wang41adc5b2020-02-25 11:43:10 -080071 MemoryType memoryType;
Lev Proleev0d4ba3f2019-10-02 17:32:06 +010072};
73
74} // namespace
75
Xusong Wangead950d2019-08-09 16:45:24 -070076Model createModel(const TestModel& testModel) {
77 // Model operands.
Slava Shklyaev1f98e2e2020-01-31 15:14:24 +000078 CHECK_EQ(testModel.referenced.size(), 0u); // Not supported in 1.1.
79 hidl_vec<Operand> operands(testModel.main.operands.size());
Xusong Wangead950d2019-08-09 16:45:24 -070080 size_t constCopySize = 0, constRefSize = 0;
Slava Shklyaev1f98e2e2020-01-31 15:14:24 +000081 for (uint32_t i = 0; i < testModel.main.operands.size(); i++) {
82 const auto& op = testModel.main.operands[i];
Xusong Wangead950d2019-08-09 16:45:24 -070083
84 DataLocation loc = {};
85 if (op.lifetime == TestOperandLifeTime::CONSTANT_COPY) {
86 loc = {.poolIndex = 0,
87 .offset = static_cast<uint32_t>(constCopySize),
88 .length = static_cast<uint32_t>(op.data.size())};
89 constCopySize += op.data.alignedSize();
90 } else if (op.lifetime == TestOperandLifeTime::CONSTANT_REFERENCE) {
91 loc = {.poolIndex = 0,
92 .offset = static_cast<uint32_t>(constRefSize),
93 .length = static_cast<uint32_t>(op.data.size())};
94 constRefSize += op.data.alignedSize();
95 }
96
97 Operand::ExtraParams extraParams;
98 if (op.type == TestOperandType::TENSOR_QUANT8_SYMM_PER_CHANNEL) {
99 extraParams.channelQuant(SymmPerChannelQuantParams{
100 .scales = op.channelQuant.scales, .channelDim = op.channelQuant.channelDim});
101 }
102
103 operands[i] = {.type = static_cast<OperandType>(op.type),
104 .dimensions = op.dimensions,
105 .numberOfConsumers = op.numberOfConsumers,
106 .scale = op.scale,
107 .zeroPoint = op.zeroPoint,
108 .lifetime = static_cast<OperandLifeTime>(op.lifetime),
109 .location = loc,
110 .extraParams = std::move(extraParams)};
Slava Shklyaev73ee79d2019-05-14 14:15:14 +0100111 }
Xusong Wangead950d2019-08-09 16:45:24 -0700112
113 // Model operations.
Slava Shklyaev1f98e2e2020-01-31 15:14:24 +0000114 hidl_vec<Operation> operations(testModel.main.operations.size());
115 std::transform(testModel.main.operations.begin(), testModel.main.operations.end(),
116 operations.begin(), [](const TestOperation& op) -> Operation {
Xusong Wangead950d2019-08-09 16:45:24 -0700117 return {.type = static_cast<OperationType>(op.type),
118 .inputs = op.inputs,
119 .outputs = op.outputs};
120 });
121
122 // Constant copies.
123 hidl_vec<uint8_t> operandValues(constCopySize);
Slava Shklyaev1f98e2e2020-01-31 15:14:24 +0000124 for (uint32_t i = 0; i < testModel.main.operands.size(); i++) {
125 const auto& op = testModel.main.operands[i];
Xusong Wangead950d2019-08-09 16:45:24 -0700126 if (op.lifetime == TestOperandLifeTime::CONSTANT_COPY) {
127 const uint8_t* begin = op.data.get<uint8_t>();
128 const uint8_t* end = begin + op.data.size();
129 std::copy(begin, end, operandValues.data() + operands[i].location.offset);
130 }
131 }
132
133 // Shared memory.
134 hidl_vec<hidl_memory> pools = {};
135 if (constRefSize > 0) {
136 hidl_vec_push_back(&pools, nn::allocateSharedMemory(constRefSize));
137 CHECK_NE(pools[0].size(), 0u);
138
139 // load data
140 sp<IMemory> mappedMemory = mapMemory(pools[0]);
141 CHECK(mappedMemory.get() != nullptr);
142 uint8_t* mappedPtr =
143 reinterpret_cast<uint8_t*>(static_cast<void*>(mappedMemory->getPointer()));
144 CHECK(mappedPtr != nullptr);
145
Slava Shklyaev1f98e2e2020-01-31 15:14:24 +0000146 for (uint32_t i = 0; i < testModel.main.operands.size(); i++) {
147 const auto& op = testModel.main.operands[i];
Xusong Wangead950d2019-08-09 16:45:24 -0700148 if (op.lifetime == TestOperandLifeTime::CONSTANT_REFERENCE) {
149 const uint8_t* begin = op.data.get<uint8_t>();
150 const uint8_t* end = begin + op.data.size();
151 std::copy(begin, end, mappedPtr + operands[i].location.offset);
152 }
153 }
154 }
155
156 return {.operands = std::move(operands),
157 .operations = std::move(operations),
Slava Shklyaev1f98e2e2020-01-31 15:14:24 +0000158 .inputIndexes = testModel.main.inputIndexes,
159 .outputIndexes = testModel.main.outputIndexes,
Xusong Wangead950d2019-08-09 16:45:24 -0700160 .operandValues = std::move(operandValues),
161 .pools = std::move(pools),
162 .relaxComputationFloat32toFloat16 = testModel.isRelaxed};
Slava Shklyaev73ee79d2019-05-14 14:15:14 +0100163}
164
Xusong Wangead950d2019-08-09 16:45:24 -0700165static bool isOutputSizeGreaterThanOne(const TestModel& testModel, uint32_t index) {
Slava Shklyaev1f98e2e2020-01-31 15:14:24 +0000166 const auto byteSize = testModel.main.operands[testModel.main.outputIndexes[index]].data.size();
Xusong Wangead950d2019-08-09 16:45:24 -0700167 return byteSize > 1u;
168}
169
170static void makeOutputInsufficientSize(uint32_t outputIndex, Request* request) {
171 auto& length = request->outputs[outputIndex].location.length;
172 ASSERT_GT(length, 1u);
173 length -= 1u;
174}
175
176static void makeOutputDimensionsUnspecified(Model* model) {
177 for (auto i : model->outputIndexes) {
178 auto& dims = model->operands[i].dimensions;
179 std::fill(dims.begin(), dims.end(), 0);
180 }
181}
182
183static Return<ErrorStatus> ExecutePreparedModel(const sp<IPreparedModel>& preparedModel,
Slava Shklyaev73ee79d2019-05-14 14:15:14 +0100184 const Request& request, MeasureTiming measure,
185 sp<ExecutionCallback>& callback) {
186 return preparedModel->execute_1_2(request, measure, callback);
187}
Xusong Wangead950d2019-08-09 16:45:24 -0700188static Return<ErrorStatus> ExecutePreparedModel(const sp<IPreparedModel>& preparedModel,
Slava Shklyaev73ee79d2019-05-14 14:15:14 +0100189 const Request& request, MeasureTiming measure,
190 hidl_vec<OutputShape>* outputShapes,
191 Timing* timing) {
192 ErrorStatus result;
193 Return<void> ret = preparedModel->executeSynchronously(
194 request, measure,
195 [&result, outputShapes, timing](ErrorStatus error, const hidl_vec<OutputShape>& shapes,
196 const Timing& time) {
197 result = error;
198 *outputShapes = shapes;
199 *timing = time;
200 });
201 if (!ret.isOk()) {
202 return ErrorStatus::GENERAL_FAILURE;
203 }
204 return result;
205}
206static std::shared_ptr<::android::nn::ExecutionBurstController> CreateBurst(
207 const sp<IPreparedModel>& preparedModel) {
Michael Butler648ada52019-07-25 17:22:11 -0700208 return android::nn::ExecutionBurstController::create(preparedModel,
209 std::chrono::microseconds{0});
Slava Shklyaev73ee79d2019-05-14 14:15:14 +0100210}
Xusong Wangead950d2019-08-09 16:45:24 -0700211
212void EvaluatePreparedModel(const sp<IPreparedModel>& preparedModel, const TestModel& testModel,
Lev Proleev0d4ba3f2019-10-02 17:32:06 +0100213 const TestConfig& testConfig) {
Xusong Wangead950d2019-08-09 16:45:24 -0700214 // If output0 does not have size larger than one byte, we can not test with insufficient buffer.
Lev Proleev0d4ba3f2019-10-02 17:32:06 +0100215 if (testConfig.outputType == OutputType::INSUFFICIENT &&
216 !isOutputSizeGreaterThanOne(testModel, 0)) {
Xusong Wangead950d2019-08-09 16:45:24 -0700217 return;
218 }
Slava Shklyaev73ee79d2019-05-14 14:15:14 +0100219
Xusong Wang41adc5b2020-02-25 11:43:10 -0800220 ExecutionContext context;
221 Request request = context.createRequest(testModel, testConfig.memoryType);
Lev Proleev0d4ba3f2019-10-02 17:32:06 +0100222 if (testConfig.outputType == OutputType::INSUFFICIENT) {
Xusong Wangead950d2019-08-09 16:45:24 -0700223 makeOutputInsufficientSize(/*outputIndex=*/0, &request);
224 }
Slava Shklyaev73ee79d2019-05-14 14:15:14 +0100225
Xusong Wangead950d2019-08-09 16:45:24 -0700226 ErrorStatus executionStatus;
227 hidl_vec<OutputShape> outputShapes;
228 Timing timing;
Lev Proleev0d4ba3f2019-10-02 17:32:06 +0100229 switch (testConfig.executor) {
Xusong Wangead950d2019-08-09 16:45:24 -0700230 case Executor::ASYNC: {
231 SCOPED_TRACE("asynchronous");
232
233 // launch execution
234 sp<ExecutionCallback> executionCallback = new ExecutionCallback();
Lev Proleev0d4ba3f2019-10-02 17:32:06 +0100235 Return<ErrorStatus> executionLaunchStatus = ExecutePreparedModel(
236 preparedModel, request, testConfig.measureTiming, executionCallback);
Xusong Wangead950d2019-08-09 16:45:24 -0700237 ASSERT_TRUE(executionLaunchStatus.isOk());
238 EXPECT_EQ(ErrorStatus::NONE, static_cast<ErrorStatus>(executionLaunchStatus));
239
240 // retrieve execution status
241 executionCallback->wait();
242 executionStatus = executionCallback->getStatus();
243 outputShapes = executionCallback->getOutputShapes();
244 timing = executionCallback->getTiming();
245
246 break;
Slava Shklyaev73ee79d2019-05-14 14:15:14 +0100247 }
Xusong Wangead950d2019-08-09 16:45:24 -0700248 case Executor::SYNC: {
249 SCOPED_TRACE("synchronous");
Slava Shklyaev73ee79d2019-05-14 14:15:14 +0100250
Xusong Wangead950d2019-08-09 16:45:24 -0700251 // execute
Lev Proleev0d4ba3f2019-10-02 17:32:06 +0100252 Return<ErrorStatus> executionReturnStatus = ExecutePreparedModel(
253 preparedModel, request, testConfig.measureTiming, &outputShapes, &timing);
Xusong Wangead950d2019-08-09 16:45:24 -0700254 ASSERT_TRUE(executionReturnStatus.isOk());
255 executionStatus = static_cast<ErrorStatus>(executionReturnStatus);
256
257 break;
258 }
259 case Executor::BURST: {
260 SCOPED_TRACE("burst");
261
262 // create burst
263 const std::shared_ptr<::android::nn::ExecutionBurstController> controller =
264 CreateBurst(preparedModel);
265 ASSERT_NE(nullptr, controller.get());
266
267 // create memory keys
268 std::vector<intptr_t> keys(request.pools.size());
269 for (size_t i = 0; i < keys.size(); ++i) {
270 keys[i] = reinterpret_cast<intptr_t>(&request.pools[i]);
Slava Shklyaev73ee79d2019-05-14 14:15:14 +0100271 }
Slava Shklyaev73ee79d2019-05-14 14:15:14 +0100272
Xusong Wangead950d2019-08-09 16:45:24 -0700273 // execute burst
Michael Butler648ada52019-07-25 17:22:11 -0700274 int n;
275 std::tie(n, outputShapes, timing, std::ignore) =
Lev Proleev0d4ba3f2019-10-02 17:32:06 +0100276 controller->compute(request, testConfig.measureTiming, keys);
Michael Butler4876af12020-03-12 15:12:23 -0700277 executionStatus = nn::legacyConvertResultCodeToErrorStatus(n);
Slava Shklyaev73ee79d2019-05-14 14:15:14 +0100278
Xusong Wangead950d2019-08-09 16:45:24 -0700279 break;
Slava Shklyaev73ee79d2019-05-14 14:15:14 +0100280 }
281 }
Xusong Wangead950d2019-08-09 16:45:24 -0700282
Lev Proleev0d4ba3f2019-10-02 17:32:06 +0100283 if (testConfig.outputType != OutputType::FULLY_SPECIFIED &&
Xusong Wangead950d2019-08-09 16:45:24 -0700284 executionStatus == ErrorStatus::GENERAL_FAILURE) {
285 LOG(INFO) << "NN VTS: Early termination of test because vendor service cannot "
286 "execute model that it does not support.";
287 std::cout << "[ ] Early termination of test because vendor service cannot "
288 "execute model that it does not support."
289 << std::endl;
290 GTEST_SKIP();
291 }
Lev Proleev0d4ba3f2019-10-02 17:32:06 +0100292 if (testConfig.measureTiming == MeasureTiming::NO) {
Xusong Wangead950d2019-08-09 16:45:24 -0700293 EXPECT_EQ(UINT64_MAX, timing.timeOnDevice);
294 EXPECT_EQ(UINT64_MAX, timing.timeInDriver);
295 } else {
296 if (timing.timeOnDevice != UINT64_MAX && timing.timeInDriver != UINT64_MAX) {
297 EXPECT_LE(timing.timeOnDevice, timing.timeInDriver);
298 }
299 }
300
Lev Proleev0d4ba3f2019-10-02 17:32:06 +0100301 switch (testConfig.outputType) {
Xusong Wangead950d2019-08-09 16:45:24 -0700302 case OutputType::FULLY_SPECIFIED:
303 // If the model output operands are fully specified, outputShapes must be either
304 // either empty, or have the same number of elements as the number of outputs.
305 ASSERT_EQ(ErrorStatus::NONE, executionStatus);
306 ASSERT_TRUE(outputShapes.size() == 0 ||
Slava Shklyaev1f98e2e2020-01-31 15:14:24 +0000307 outputShapes.size() == testModel.main.outputIndexes.size());
Xusong Wangead950d2019-08-09 16:45:24 -0700308 break;
309 case OutputType::UNSPECIFIED:
310 // If the model output operands are not fully specified, outputShapes must have
311 // the same number of elements as the number of outputs.
312 ASSERT_EQ(ErrorStatus::NONE, executionStatus);
Slava Shklyaev1f98e2e2020-01-31 15:14:24 +0000313 ASSERT_EQ(outputShapes.size(), testModel.main.outputIndexes.size());
Xusong Wangead950d2019-08-09 16:45:24 -0700314 break;
315 case OutputType::INSUFFICIENT:
316 ASSERT_EQ(ErrorStatus::OUTPUT_INSUFFICIENT_SIZE, executionStatus);
Slava Shklyaev1f98e2e2020-01-31 15:14:24 +0000317 ASSERT_EQ(outputShapes.size(), testModel.main.outputIndexes.size());
Xusong Wangead950d2019-08-09 16:45:24 -0700318 ASSERT_FALSE(outputShapes[0].isSufficient);
319 return;
320 }
321
322 // Go through all outputs, check returned output shapes.
323 for (uint32_t i = 0; i < outputShapes.size(); i++) {
324 EXPECT_TRUE(outputShapes[i].isSufficient);
Slava Shklyaev1f98e2e2020-01-31 15:14:24 +0000325 const auto& expect = testModel.main.operands[testModel.main.outputIndexes[i]].dimensions;
Xusong Wangead950d2019-08-09 16:45:24 -0700326 const std::vector<uint32_t> actual = outputShapes[i].dimensions;
327 EXPECT_EQ(expect, actual);
328 }
329
330 // Retrieve execution results.
Xusong Wang41adc5b2020-02-25 11:43:10 -0800331 const std::vector<TestBuffer> outputs = context.getOutputBuffers(request);
Xusong Wangead950d2019-08-09 16:45:24 -0700332
333 // We want "close-enough" results.
334 checkResults(testModel, outputs);
Slava Shklyaev73ee79d2019-05-14 14:15:14 +0100335}
336
Xusong Wangead950d2019-08-09 16:45:24 -0700337void EvaluatePreparedModel(const sp<IPreparedModel>& preparedModel, const TestModel& testModel,
338 bool testDynamicOutputShape) {
Lev Proleev56cda832019-12-05 14:49:47 +0000339 std::vector<OutputType> outputTypesList;
340 std::vector<MeasureTiming> measureTimingList;
341 std::vector<Executor> executorList;
Xusong Wang41adc5b2020-02-25 11:43:10 -0800342 std::vector<MemoryType> memoryTypeList;
Lev Proleev0d4ba3f2019-10-02 17:32:06 +0100343
Slava Shklyaev73ee79d2019-05-14 14:15:14 +0100344 if (testDynamicOutputShape) {
Lev Proleev0d4ba3f2019-10-02 17:32:06 +0100345 outputTypesList = {OutputType::UNSPECIFIED, OutputType::INSUFFICIENT};
346 measureTimingList = {MeasureTiming::NO, MeasureTiming::YES};
347 executorList = {Executor::ASYNC, Executor::SYNC, Executor::BURST};
Xusong Wang41adc5b2020-02-25 11:43:10 -0800348 memoryTypeList = {MemoryType::ASHMEM};
Slava Shklyaev73ee79d2019-05-14 14:15:14 +0100349 } else {
Lev Proleev0d4ba3f2019-10-02 17:32:06 +0100350 outputTypesList = {OutputType::FULLY_SPECIFIED};
351 measureTimingList = {MeasureTiming::NO, MeasureTiming::YES};
352 executorList = {Executor::ASYNC, Executor::SYNC, Executor::BURST};
Xusong Wangb6427002020-04-09 14:26:54 -0700353 memoryTypeList = {MemoryType::ASHMEM};
Lev Proleev0d4ba3f2019-10-02 17:32:06 +0100354 }
355
356 for (const OutputType outputType : outputTypesList) {
357 for (const MeasureTiming measureTiming : measureTimingList) {
358 for (const Executor executor : executorList) {
Xusong Wang41adc5b2020-02-25 11:43:10 -0800359 for (const MemoryType memoryType : memoryTypeList) {
360 const TestConfig testConfig = {.executor = executor,
361 .measureTiming = measureTiming,
362 .outputType = outputType,
363 .memoryType = memoryType};
364 EvaluatePreparedModel(preparedModel, testModel, testConfig);
365 }
Lev Proleev0d4ba3f2019-10-02 17:32:06 +0100366 }
367 }
Slava Shklyaev73ee79d2019-05-14 14:15:14 +0100368 }
369}
370
Michael Butler13b05162019-08-29 22:17:24 -0700371void Execute(const sp<IDevice>& device, const TestModel& testModel, bool testDynamicOutputShape) {
372 Model model = createModel(testModel);
373 if (testDynamicOutputShape) {
374 makeOutputDimensionsUnspecified(&model);
Slava Shklyaev73ee79d2019-05-14 14:15:14 +0100375 }
Michael Butler13b05162019-08-29 22:17:24 -0700376
377 sp<IPreparedModel> preparedModel;
378 createPreparedModel(device, model, &preparedModel);
379 if (preparedModel == nullptr) return;
380
381 EvaluatePreparedModel(preparedModel, testModel, testDynamicOutputShape);
Slava Shklyaev73ee79d2019-05-14 14:15:14 +0100382}
383
Michael Butler07633282019-08-29 11:08:25 -0700384void GeneratedTestBase::SetUp() {
385 testing::TestWithParam<GeneratedTestParam>::SetUp();
386 ASSERT_NE(kDevice, nullptr);
387}
388
389std::vector<NamedModel> getNamedModels(const FilterFn& filter) {
390 return TestModelManager::get().getTestModels(filter);
391}
392
Michael Butler678a1062020-03-19 17:10:34 -0700393std::vector<NamedModel> getNamedModels(const FilterNameFn& filter) {
394 return TestModelManager::get().getTestModels(filter);
395}
396
Michael Butler07633282019-08-29 11:08:25 -0700397std::string printGeneratedTest(const testing::TestParamInfo<GeneratedTestParam>& info) {
398 const auto& [namedDevice, namedModel] = info.param;
399 return gtestCompliantName(getName(namedDevice) + "_" + getName(namedModel));
400}
401
Xusong Wangbcaa7822019-08-23 16:10:54 -0700402// Tag for the generated tests
Michael Butler13b05162019-08-29 22:17:24 -0700403class GeneratedTest : public GeneratedTestBase {};
Xusong Wangbcaa7822019-08-23 16:10:54 -0700404
405// Tag for the dynamic output shape tests
406class DynamicOutputShapeTest : public GeneratedTest {};
407
408TEST_P(GeneratedTest, Test) {
Michael Butler13b05162019-08-29 22:17:24 -0700409 Execute(kDevice, kTestModel, /*testDynamicOutputShape=*/false);
Slava Shklyaev73ee79d2019-05-14 14:15:14 +0100410}
411
Xusong Wangbcaa7822019-08-23 16:10:54 -0700412TEST_P(DynamicOutputShapeTest, Test) {
Michael Butler13b05162019-08-29 22:17:24 -0700413 Execute(kDevice, kTestModel, /*testDynamicOutputShape=*/true);
Xusong Wangbcaa7822019-08-23 16:10:54 -0700414}
415
416INSTANTIATE_GENERATED_TEST(GeneratedTest,
417 [](const TestModel& testModel) { return !testModel.expectFailure; });
418
419INSTANTIATE_GENERATED_TEST(DynamicOutputShapeTest,
420 [](const TestModel& testModel) { return !testModel.expectFailure; });
421
Michael Butler62749b92019-08-26 23:55:47 -0700422} // namespace android::hardware::neuralnetworks::V1_2::vts::functional