Implement full canonical Burst in NN util code
Bug: 180492058
Bug: 177267324
Test: mma
Test: presubmit
Change-Id: I5018f6cf2dbaf705f74f4f46318142c64433e19d
Merged-In: I5018f6cf2dbaf705f74f4f46318142c64433e19d
(cherry picked from commit acff4063b63c04cbb28af87eab61e9a1fa70980a)
diff --git a/neuralnetworks/1.3/utils/src/PreparedModel.cpp b/neuralnetworks/1.3/utils/src/PreparedModel.cpp
index 725e4f5..64275a3 100644
--- a/neuralnetworks/1.3/utils/src/PreparedModel.cpp
+++ b/neuralnetworks/1.3/utils/src/PreparedModel.cpp
@@ -29,8 +29,9 @@
#include <nnapi/Result.h>
#include <nnapi/TypeUtils.h>
#include <nnapi/Types.h>
-#include <nnapi/hal/1.0/Burst.h>
#include <nnapi/hal/1.2/Conversions.h>
+#include <nnapi/hal/1.2/ExecutionBurstController.h>
+#include <nnapi/hal/1.2/ExecutionBurstUtils.h>
#include <nnapi/hal/CommonUtils.h>
#include <nnapi/hal/HandleError.h>
#include <nnapi/hal/ProtectCallback.h>
@@ -199,7 +200,15 @@
}
nn::GeneralResult<nn::SharedBurst> PreparedModel::configureExecutionBurst() const {
- return V1_0::utils::Burst::create(shared_from_this());
+ auto self = shared_from_this();
+ auto fallback = [preparedModel = std::move(self)](const nn::Request& request,
+ nn::MeasureTiming measure)
+ -> nn::ExecutionResult<std::pair<std::vector<nn::OutputShape>, nn::Timing>> {
+ return preparedModel->execute(request, measure, {}, {});
+ };
+ const auto pollingTimeWindow = V1_2::utils::getBurstControllerPollingTimeWindow();
+ return V1_2::utils::ExecutionBurstController::create(kPreparedModel, std::move(fallback),
+ pollingTimeWindow);
}
std::any PreparedModel::getUnderlyingResource() const {