Fix use-after-free error in NNAPI VTS tests

am: 56cda83f8c

Change-Id: Ide89166dfa6792b0e63105dcea71254a78897322
This commit is contained in:
Lev Proleev 2019-12-09 12:04:20 -08:00 committed by android-build-merger
commit 0854f5f759
2 changed files with 13 additions and 13 deletions

View file

@ -29,13 +29,14 @@
#include <android/hardware/neuralnetworks/1.2/IPreparedModelCallback.h> #include <android/hardware/neuralnetworks/1.2/IPreparedModelCallback.h>
#include <android/hidl/allocator/1.0/IAllocator.h> #include <android/hidl/allocator/1.0/IAllocator.h>
#include <android/hidl/memory/1.0/IMemory.h> #include <android/hidl/memory/1.0/IMemory.h>
#include <gtest/gtest.h>
#include <hidlmemory/mapping.h> #include <hidlmemory/mapping.h>
#include <gtest/gtest.h>
#include <algorithm> #include <algorithm>
#include <chrono> #include <chrono>
#include <iostream> #include <iostream>
#include <numeric> #include <numeric>
#include <vector>
#include "1.0/Utils.h" #include "1.0/Utils.h"
#include "1.2/Callbacks.h" #include "1.2/Callbacks.h"
@ -333,9 +334,9 @@ void EvaluatePreparedModel(const sp<IPreparedModel>& preparedModel, const TestMo
void EvaluatePreparedModel(const sp<IPreparedModel>& preparedModel, const TestModel& testModel, void EvaluatePreparedModel(const sp<IPreparedModel>& preparedModel, const TestModel& testModel,
bool testDynamicOutputShape) { bool testDynamicOutputShape) {
std::initializer_list<OutputType> outputTypesList; std::vector<OutputType> outputTypesList;
std::initializer_list<MeasureTiming> measureTimingList; std::vector<MeasureTiming> measureTimingList;
std::initializer_list<Executor> executorList; std::vector<Executor> executorList;
if (testDynamicOutputShape) { if (testDynamicOutputShape) {
outputTypesList = {OutputType::UNSPECIFIED, OutputType::INSUFFICIENT}; outputTypesList = {OutputType::UNSPECIFIED, OutputType::INSUFFICIENT};

View file

@ -34,13 +34,14 @@
#include <android/hardware/neuralnetworks/1.3/types.h> #include <android/hardware/neuralnetworks/1.3/types.h>
#include <android/hidl/allocator/1.0/IAllocator.h> #include <android/hidl/allocator/1.0/IAllocator.h>
#include <android/hidl/memory/1.0/IMemory.h> #include <android/hidl/memory/1.0/IMemory.h>
#include <gtest/gtest.h>
#include <hidlmemory/mapping.h> #include <hidlmemory/mapping.h>
#include <gtest/gtest.h>
#include <algorithm> #include <algorithm>
#include <chrono> #include <chrono>
#include <iostream> #include <iostream>
#include <numeric> #include <numeric>
#include <vector>
#include "1.0/Utils.h" #include "1.0/Utils.h"
#include "1.2/Callbacks.h" #include "1.2/Callbacks.h"
@ -368,9 +369,9 @@ void EvaluatePreparedModel(const sp<IPreparedModel>& preparedModel, const TestMo
void EvaluatePreparedModel(const sp<IPreparedModel>& preparedModel, const TestModel& testModel, void EvaluatePreparedModel(const sp<IPreparedModel>& preparedModel, const TestModel& testModel,
TestKind testKind) { TestKind testKind) {
std::initializer_list<OutputType> outputTypesList; std::vector<OutputType> outputTypesList;
std::initializer_list<MeasureTiming> measureTimingList; std::vector<MeasureTiming> measureTimingList;
std::initializer_list<Executor> executorList; std::vector<Executor> executorList;
switch (testKind) { switch (testKind) {
case TestKind::GENERAL: { case TestKind::GENERAL: {
@ -403,11 +404,9 @@ void EvaluatePreparedCoupledModels(const sp<IPreparedModel>& preparedModel,
const TestModel& testModel, const TestModel& testModel,
const sp<IPreparedModel>& preparedCoupledModel, const sp<IPreparedModel>& preparedCoupledModel,
const TestModel& coupledModel) { const TestModel& coupledModel) {
std::initializer_list<OutputType> outputTypesList = {OutputType::FULLY_SPECIFIED}; const std::vector<OutputType> outputTypesList = {OutputType::FULLY_SPECIFIED};
std::initializer_list<MeasureTiming> measureTimingList = {MeasureTiming::NO, const std::vector<MeasureTiming> measureTimingList = {MeasureTiming::NO, MeasureTiming::YES};
MeasureTiming::YES}; const std::vector<Executor> executorList = {Executor::ASYNC, Executor::SYNC, Executor::BURST};
std::initializer_list<Executor> executorList = {Executor::ASYNC, Executor::SYNC,
Executor::BURST};
for (const OutputType outputType : outputTypesList) { for (const OutputType outputType : outputTypesList) {
for (const MeasureTiming measureTiming : measureTimingList) { for (const MeasureTiming measureTiming : measureTimingList) {