Follow up CL to "Adjust code in response to Burst validation tests"
Bug: 129779280
Bug: 129157135
Test: mma
Change-Id: I36746ba31a6a68ead2a00f6135a5a6db83c32d14
diff --git a/nn/common/ExecutionBurstServer.cpp b/nn/common/ExecutionBurstServer.cpp
index 9bdcfdb..6f568dd 100644
--- a/nn/common/ExecutionBurstServer.cpp
+++ b/nn/common/ExecutionBurstServer.cpp
@@ -43,10 +43,7 @@
bool isCacheEntryPresent(int32_t slot) const override {
const auto it = mMemoryCache.find(slot);
- if (it == mMemoryCache.end()) {
- return false;
- }
- return it->second.valid();
+ return (it != mMemoryCache.end()) && it->second.valid();
}
void addCacheEntry(const hidl_memory& memory, int32_t slot) override {
@@ -418,7 +415,11 @@
<< "ResultChannelSender::sendPacket -- packet size exceeds size available in FMQ";
const std::vector<FmqResultDatum> errorPacket =
serialize(ErrorStatus::GENERAL_FAILURE, {}, kNoTiming);
- return mFmqResultChannel->writeBlocking(errorPacket.data(), errorPacket.size());
+ if (mBlocking) {
+ return mFmqResultChannel->writeBlocking(errorPacket.data(), errorPacket.size());
+ } else {
+ return mFmqResultChannel->write(errorPacket.data(), errorPacket.size());
+ }
}
if (mBlocking) {
diff --git a/nn/common/include/ExecutionBurstController.h b/nn/common/include/ExecutionBurstController.h
index f4c920f..3397d96 100644
--- a/nn/common/include/ExecutionBurstController.h
+++ b/nn/common/include/ExecutionBurstController.h
@@ -193,9 +193,29 @@
* buffer, they must use the same key.
*/
class ExecutionBurstCallback : public IBurstCallback {
+ DISALLOW_COPY_AND_ASSIGN(ExecutionBurstCallback);
+
public:
+ ExecutionBurstCallback() = default;
+
Return<void> getMemories(const hidl_vec<int32_t>& slots, getMemories_cb cb) override;
+ /**
+ * This function performs one of two different actions:
+ * 1) If a key corresponding to a memory resource is unrecognized by the
+ * ExecutionBurstCallback object, the ExecutionBurstCallback object
+ * will allocate a slot, bind the memory to the slot, and return the
+ * slot identifier.
+ * 2) If a key corresponding to a memory resource is recognized by the
+ * ExecutionBurstCallback object, the ExecutionBurstCallback object
+ * will return the existing slot identifier.
+ *
+ * @param memories Memory resources used in an inference.
+ * @param keys Unique identifiers where each element corresponds to a
+ * memory resource element in "memories".
+ * @return Unique slot identifiers where each returned slot element
+ * corresponds to a memory resource element in "memories".
+ */
std::vector<int32_t> getSlots(const hidl_vec<hidl_memory>& memories,
const std::vector<intptr_t>& keys);
diff --git a/nn/driver/sample/SampleDriver.cpp b/nn/driver/sample/SampleDriver.cpp
index bfb0a6c..25955e7 100644
--- a/nn/driver/sample/SampleDriver.cpp
+++ b/nn/driver/sample/SampleDriver.cpp
@@ -358,10 +358,7 @@
bool isCacheEntryPresent(int32_t slot) const override {
const auto it = mMemoryCache.find(slot);
- if (it == mMemoryCache.end()) {
- return false;
- }
- return it->second.has_value();
+ return (it != mMemoryCache.end()) && it->second.has_value();
}
void addCacheEntry(const hidl_memory& memory, int32_t slot) override {