From e9dc1674f0b45a4a076a1161616fa66e8c784046 Mon Sep 17 00:00:00 2001 From: Michael Butler Date: Mon, 11 Sep 2017 13:53:19 -0700 Subject: [PATCH] Make prepareModel asynchronous. Updated the corresponding VTS tests. Bug: 63905942 Test: mm, vts Change-Id: Ie520af845f491dbdd93ea66fd643d77cfb4703f7 --- neuralnetworks/1.0/IDevice.hal | 3 ++- .../VtsHalNeuralnetworksV1_0TargetTest.cpp | 18 +++++++++++------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/neuralnetworks/1.0/IDevice.hal b/neuralnetworks/1.0/IDevice.hal index b826b23774..9e190977bc 100644 --- a/neuralnetworks/1.0/IDevice.hal +++ b/neuralnetworks/1.0/IDevice.hal @@ -18,6 +18,7 @@ package android.hardware.neuralnetworks@1.0; +import IEvent; import IPreparedModel; interface IDevice { @@ -25,7 +26,7 @@ interface IDevice { getSupportedSubgraph(Model model) generates(vec supported); - prepareModel(Model model) generates(IPreparedModel preparedModel); + prepareModel(Model model, IEvent event) generates(IPreparedModel preparedModel); getStatus() generates(DeviceStatus status); }; diff --git a/neuralnetworks/1.0/vts/functional/VtsHalNeuralnetworksV1_0TargetTest.cpp b/neuralnetworks/1.0/vts/functional/VtsHalNeuralnetworksV1_0TargetTest.cpp index 90ccd0609d..9c64c04825 100644 --- a/neuralnetworks/1.0/vts/functional/VtsHalNeuralnetworksV1_0TargetTest.cpp +++ b/neuralnetworks/1.0/vts/functional/VtsHalNeuralnetworksV1_0TargetTest.cpp @@ -209,10 +209,14 @@ TEST_F(NeuralnetworksHidlTest, SimpleExecuteGraphTest) { const uint32_t INPUT = 0; const uint32_t OUTPUT = 1; - // prpeare request + // prepare request Model model = createTestModel(); - sp preparedModel = device->prepareModel(model); + sp preparationEvent = new Event(); + ASSERT_NE(nullptr, preparationEvent.get()); + sp preparedModel = device->prepareModel(model, preparationEvent); ASSERT_NE(nullptr, preparedModel.get()); + Event::Status preparationStatus = preparationEvent->wait(); + EXPECT_EQ(Event::Status::SUCCESS, preparationStatus); // prepare inputs uint32_t inputSize = static_cast(inputData.size() * sizeof(float)); @@ -245,13 +249,13 @@ TEST_F(NeuralnetworksHidlTest, SimpleExecuteGraphTest) { outputMemory->commit(); // execute request - sp event = sp(new Event()); - ASSERT_NE(nullptr, event.get()); + sp executionEvent = new Event(); + ASSERT_NE(nullptr, executionEvent.get()); bool success = preparedModel->execute({.inputs = inputs, .outputs = outputs, .pools = pools}, - event); + executionEvent); EXPECT_TRUE(success); - Event::Status status = event->wait(); - EXPECT_EQ(Event::Status::SUCCESS, status); + Event::Status executionStatus = executionEvent->wait(); + EXPECT_EQ(Event::Status::SUCCESS, executionStatus); // validate results { 1+5, 2+6, 3+7, 4+8 } outputMemory->read();