From 9fcccf8b85b3ecde96a1b0810a61b2156e083885 Mon Sep 17 00:00:00 2001 From: Xusong Wang Date: Fri, 13 Mar 2020 10:02:36 -0700 Subject: [PATCH] Fix VTS of fenced execution with zero-sized output. Fixes: 151441390 Test: 1.3 VTS Change-Id: I100329e18c34c377d217af155c2abc8e67078778 --- .../vts/functional/GeneratedTestHarness.cpp | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/neuralnetworks/1.3/vts/functional/GeneratedTestHarness.cpp b/neuralnetworks/1.3/vts/functional/GeneratedTestHarness.cpp index 83a8d94ba5..aae58bfb3e 100644 --- a/neuralnetworks/1.3/vts/functional/GeneratedTestHarness.cpp +++ b/neuralnetworks/1.3/vts/functional/GeneratedTestHarness.cpp @@ -493,6 +493,13 @@ static std::vector getOutputBuffers(const TestModel& testModel, cons return outputBuffers; } +static bool hasZeroSizedOutput(const TestModel& testModel) { + return std::any_of(testModel.main.outputIndexes.begin(), testModel.main.outputIndexes.end(), + [&testModel](uint32_t index) { + return testModel.main.operands[index].data.size() == 0; + }); +} + static Return ExecutePreparedModel(const sp& preparedModel, const Request& request, MeasureTiming measure, const OptionalTimeoutDuration& loopTimeoutDuration, @@ -689,6 +696,11 @@ void EvaluatePreparedModel(const sp& device, const sp& switch (testConfig.outputType) { case OutputType::FULLY_SPECIFIED: + if (testConfig.executor == Executor::FENCED && hasZeroSizedOutput(testModel)) { + // Executor::FENCED does not support zero-sized output. + ASSERT_EQ(ErrorStatus::INVALID_ARGUMENT, executionStatus); + return; + } // If the model output operands are fully specified, outputShapes must be either // either empty, or have the same number of elements as the number of outputs. ASSERT_EQ(ErrorStatus::NONE, executionStatus); @@ -936,13 +948,8 @@ INSTANTIATE_GENERATED_TEST(DynamicOutputShapeTest, [](const TestModel& testModel INSTANTIATE_GENERATED_TEST(MemoryDomainTest, [](const TestModel& testModel) { return !testModel.expectFailure; }); -INSTANTIATE_GENERATED_TEST(FencedComputeTest, [](const TestModel& testModel) { - return !testModel.expectFailure && - std::all_of(testModel.main.outputIndexes.begin(), testModel.main.outputIndexes.end(), - [&testModel](uint32_t index) { - return testModel.main.operands[index].data.size() > 0; - }); -}); +INSTANTIATE_GENERATED_TEST(FencedComputeTest, + [](const TestModel& testModel) { return !testModel.expectFailure; }); INSTANTIATE_GENERATED_TEST(QuantizationCouplingTest, [](const TestModel& testModel) { return testModel.hasQuant8CoupledOperands() && testModel.main.operations.size() == 1;