diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2023-12-15 09:20:27 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2023-12-15 09:20:27 +0000 |
commit | 0c2a46ff0340d3bcc62fbb14ceb01b68aabae337 (patch) | |
tree | 2bb62958f048ccb89373be8954d3f3a6ac88c479 | |
parent | fb7bf3b20ecfcaa61686fa0c924f800961314ff7 (diff) | |
parent | caf5103d939f86120501cf195bc4c2e1a0a1561c (diff) | |
download | android-nn-driver-aml_tz5_341510010.tar.gz |
Snap for 11224086 from caf5103d939f86120501cf195bc4c2e1a0a1561c to mainline-tzdata5-releaseaml_tz5_341510070aml_tz5_341510050aml_tz5_341510010aml_tz5_341510010
Change-Id: I245de12cf63644c6e2dfd7e3ebc3990289537700
-rw-r--r-- | ArmnnPreparedModel_1_3.cpp | 6 | ||||
-rw-r--r-- | Utils.cpp | 66 |
2 files changed, 29 insertions, 43 deletions
diff --git a/ArmnnPreparedModel_1_3.cpp b/ArmnnPreparedModel_1_3.cpp index bd5261e..353bdaf 100644 --- a/ArmnnPreparedModel_1_3.cpp +++ b/ArmnnPreparedModel_1_3.cpp @@ -343,6 +343,12 @@ Return<void> ArmnnPreparedModel_1_3<HalVersion>::executeFenced(const V1_3::Reque return Void(); } + if (fenceNativeHandle->numFds != 1) + { + cb(V1_3::ErrorStatus::INVALID_ARGUMENT, hidl_handle(nullptr), nullptr); + return Void(); + } + if (sync_wait(fenceNativeHandle->data[0], -1) < 0) { ALOGE("ArmnnPreparedModel_1_3::executeFenced sync fence failed."); @@ -21,6 +21,7 @@ #include <sstream> #include <cstdio> #include <time.h> +#include <string> @@ -43,6 +44,22 @@ void SwizzleAndroidNn4dTensorToArmNn(const armnn::TensorShape& inTensorShape, co armnnUtils::Permute(armnnUtils::Permuted(inTensorShape, mappings), mappings, input, output, dataTypeSize); } +template<typename Dimensions> +auto GetDimensionsSpecificity(const Dimensions& dimensions) +{ + // We can't use std::vector<bool> since that is a specialization that packs + // bits, so use a string of bools instead. This also has the benefit of + // using small string optimization. + std::basic_string<bool> specificity(dimensions.size(), false); + + for (std::size_t i = 0; i < dimensions.size(); ++i) + { + specificity[i] = dimensions.data()[i] != 0; + } + + return specificity; +} + } // anonymous namespace void SwizzleAndroidNn4dTensorToArmNn(const armnn::TensorInfo& tensor, const void* input, void* output, @@ -65,7 +82,6 @@ void SwizzleAndroidNn4dTensorToArmNn(const armnn::TensorInfo& tensor, const void assert(0); } } - void* GetMemoryFromPool(V1_0::DataLocation location, const std::vector<android::nn::RunTimePoolInfo>& memPools) { // find the location within the pool @@ -108,20 +124,8 @@ armnn::TensorInfo GetTensorInfoForOperand(const V1_0::Operand& operand) } else { - bool dimensionsSpecificity[5] = { true, true, true, true, true }; - int count = 0; - std::for_each(operand.dimensions.data(), - operand.dimensions.data() + operand.dimensions.size(), - [&](const unsigned int val) - { - if (val == 0) - { - dimensionsSpecificity[count] = false; - } - count++; - }); - - TensorShape tensorShape(operand.dimensions.size(), operand.dimensions.data(), dimensionsSpecificity); + auto dimensionsSpecificity = GetDimensionsSpecificity(operand.dimensions); + TensorShape tensorShape(operand.dimensions.size(), operand.dimensions.data(), dimensionsSpecificity.data()); ret = TensorInfo(tensorShape, type); } @@ -177,20 +181,8 @@ armnn::TensorInfo GetTensorInfoForOperand(const V1_2::Operand& operand) } else { - bool dimensionsSpecificity[5] = { true, true, true, true, true }; - int count = 0; - std::for_each(operand.dimensions.data(), - operand.dimensions.data() + operand.dimensions.size(), - [&](const unsigned int val) - { - if (val == 0) - { - dimensionsSpecificity[count] = false; - } - count++; - }); - - TensorShape tensorShape(operand.dimensions.size(), operand.dimensions.data(), dimensionsSpecificity); + auto dimensionsSpecificity = GetDimensionsSpecificity(operand.dimensions); + TensorShape tensorShape(operand.dimensions.size(), operand.dimensions.data(), dimensionsSpecificity.data()); ret = TensorInfo(tensorShape, type); } @@ -276,20 +268,8 @@ armnn::TensorInfo GetTensorInfoForOperand(const V1_3::Operand& operand) } else { - bool dimensionsSpecificity[5] = { true, true, true, true, true }; - int count = 0; - std::for_each(operand.dimensions.data(), - operand.dimensions.data() + operand.dimensions.size(), - [&](const unsigned int val) - { - if (val == 0) - { - dimensionsSpecificity[count] = false; - } - count++; - }); - - TensorShape tensorShape(operand.dimensions.size(), operand.dimensions.data(), dimensionsSpecificity); + auto dimensionsSpecificity = GetDimensionsSpecificity(operand.dimensions); + TensorShape tensorShape(operand.dimensions.size(), operand.dimensions.data(), dimensionsSpecificity.data()); ret = TensorInfo(tensorShape, type); } } |