diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2023-07-11 18:54:57 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2023-07-11 18:54:57 +0000 |
commit | 597efc06479e0661ed3974948cbab29c336f1c7e (patch) | |
tree | 2bb62958f048ccb89373be8954d3f3a6ac88c479 | |
parent | ce483a89868e508655d5b6c438cd6f9314dc0042 (diff) | |
parent | caf5103d939f86120501cf195bc4c2e1a0a1561c (diff) | |
download | android-nn-driver-android14-mainline-wifi-release.tar.gz |
Snap for 10476824 from caf5103d939f86120501cf195bc4c2e1a0a1561c to mainline-wifi-releaseaml_wif_341711020aml_wif_341610000aml_wif_341510000aml_wif_341410080aml_wif_341310010aml_wif_341110010aml_wif_341011010aml_wif_340913010android14-mainline-wifi-release
Change-Id: Ic46d505ed064316a37736e32108e3a135b893780
-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); } } |