summaryrefslogtreecommitdiff
path: root/nn/runtime/test/TestExecution.cpp
diff options
context:
space:
mode:
authorMichael Butler <butlermichael@google.com>2019-01-22 23:07:06 -0800
committerMiao Wang <miaowang@google.com>2019-01-24 18:08:06 -0800
commit11a443c027387db8cf5b6ee97552e18afb231ff7 (patch)
treed27b82eebc336ec66d95c919a174e583e2bf1200 /nn/runtime/test/TestExecution.cpp
parent31206e75151de4501e895fa04b6e91a235d011f6 (diff)
downloadml-11a443c027387db8cf5b6ee97552e18afb231ff7.tar.gz
NNAPI Burst -- runtime V1_2 skeletal implementation
FastMessageQueue is a Treble-compliant data structure that enables fast communication between two processes. The FMQ object itself is an atomic circular buffer that is optionally synchronized with a futex. However, FMQ has no notion of ownership or lifetime across processes, so it must be paired with higher-level constructs to manage the lifetime and ownership. The NNAPI is introducing the notion of an "Execution Burst" object (or more simply a "Burst" object), which is similar to an ANeuralNetworksExecution, but is intended to be reused across multiple executions and has lower IPC overheads. It achieves this low IPC overhead by replacing HIDL HwBinder calls with FMQ messages. Specifically, it replaces IPreparedModel::executeSynchronously's call from the client into the service with fmq_sync<FmqRequestDatum> (an FMQ channel used to pass a serialized Request object) and it replaces the return from the service into the client with fmq_sync<FmqResultDatum> (an FMQ channel used to return serialized result status and OutputShapes information). Each channel is a unidirectional flow of information with exactly one producer and exactly one consumer. The channels are created by the NN runtime and passed to the service via IPreparedModel::configureExecutionBurst. This CL implements the new method V1_2::IPreparedModel::configureExecutionBurst in TestExecution, TestPartitioning, and the sample driver to prevent compiler errors. Bug: 119570067 Test: mma Change-Id: I3bf8d5ab1510d34c4409691f76b200a718a1a224 Merged-In: I3bf8d5ab1510d34c4409691f76b200a718a1a224 (cherry picked from commit 27c35dade9445b389bab7bcb0d8b2df99b79d28a)
Diffstat (limited to 'nn/runtime/test/TestExecution.cpp')
-rw-r--r--nn/runtime/test/TestExecution.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/nn/runtime/test/TestExecution.cpp b/nn/runtime/test/TestExecution.cpp
index f7889b8f7..d19df6b46 100644
--- a/nn/runtime/test/TestExecution.cpp
+++ b/nn/runtime/test/TestExecution.cpp
@@ -47,6 +47,9 @@ using WrapperModel = nn::test_wrapper::Model;
using WrapperOperandType = nn::test_wrapper::OperandType;
using WrapperType = nn::test_wrapper::Type;
+template <typename T>
+using MQDescriptorSync = ::android::hardware::MQDescriptorSync<T>;
+
namespace {
// Wraps an V1_2::IPreparedModel to allow dummying up the execution status.
@@ -96,6 +99,20 @@ class TestPreparedModel12 : public V1_2::IPreparedModel {
}
}
+ Return<void> configureExecutionBurst(
+ const sp<V1_2::IBurstCallback>& callback,
+ const MQDescriptorSync<V1_2::FmqRequestDatum>& requestChannel,
+ const MQDescriptorSync<V1_2::FmqResultDatum>& resultChannel,
+ configureExecutionBurst_cb cb) override {
+ if (mErrorStatus == ErrorStatus::NONE) {
+ return mPreparedModelV1_2->configureExecutionBurst(callback, requestChannel,
+ resultChannel, cb);
+ } else {
+ cb(ErrorStatus::DEVICE_UNAVAILABLE, nullptr);
+ return Void();
+ }
+ }
+
private:
sp<V1_0::IPreparedModel> mPreparedModelV1_0;
sp<V1_2::IPreparedModel> mPreparedModelV1_2;