aboutsummaryrefslogtreecommitdiff
path: root/shim/sl/scripts
diff options
context:
space:
mode:
authorSadik Armagan <sadik.armagan@arm.com>2022-06-17 15:38:22 +0100
committerSadik Armagan <sadik.armagan@arm.com>2022-06-20 14:41:39 +0100
commit8f397a1efed11e17e9f8cb12b53a72b7e32ab978 (patch)
tree5a4f351ee688bd760449c82c455b0e324b11f88d /shim/sl/scripts
parentd2e52e8873629ff920188615121cb104eb0fcc96 (diff)
downloadarmnn-8f397a1efed11e17e9f8cb12b53a72b7e32ab978.tar.gz
IVGCVSW-6989 "Merged experimental/armnn_shim_sl"
* Updated Serializer CMakeLists.txt to build armnnSerializerObj * Added constant tensors as input support to SL Signed-off-by: Sadik Armagan <sadik.armagan@arm.com> Change-Id: I22f6cf50147d99a01f7fe70d7446b114a4c57af3
Diffstat (limited to 'shim/sl/scripts')
-rw-r--r--shim/sl/scripts/NeuralNetworks.patch43
-rwxr-xr-xshim/sl/scripts/clone_aosp_libs.sh84
-rw-r--r--shim/sl/scripts/libbase_logging_cpp.patch171
-rwxr-xr-xshim/sl/scripts/modify_aosp_libs.sh36
4 files changed, 334 insertions, 0 deletions
diff --git a/shim/sl/scripts/NeuralNetworks.patch b/shim/sl/scripts/NeuralNetworks.patch
new file mode 100644
index 0000000000..81e859bd67
--- /dev/null
+++ b/shim/sl/scripts/NeuralNetworks.patch
@@ -0,0 +1,43 @@
+diff --git a/common/types/src/SharedMemoryAndroid.cpp b/common/types/src/SharedMemoryAndroid.cpp
+index c361a1eb6..3c09c5f4d 100644
+--- a/common/types/src/SharedMemoryAndroid.cpp
++++ b/common/types/src/SharedMemoryAndroid.cpp
+@@ -115,8 +115,23 @@ GeneralResult<SharedMemory> allocateSharedMemory(size_t size) {
+ return createSharedMemoryFromUniqueFd(size, prot, std::move(fd), offset);
+ }
+
+-GeneralResult<Mapping> map(const Memory::Ashmem& /*memory*/) {
+- return NN_ERROR(ErrorStatus::INVALID_ARGUMENT) << "Cannot map ashmem memory";
++//GeneralResult<Mapping> map(const Memory::Ashmem& /*memory*/) {
++// return NN_ERROR(ErrorStatus::INVALID_ARGUMENT) << "Cannot map ashmem memory";
++//}
++
++GeneralResult<Mapping> map(const Memory::Ashmem& memory) {
++ constexpr off64_t offset = 0;
++ constexpr int prot = PROT_READ | PROT_WRITE;
++ std::shared_ptr<base::MappedFile> mapping =
++ base::MappedFile::FromFd(memory.fd, offset, memory.size, prot);
++ if (mapping == nullptr || mapping->data() == nullptr) {
++ return NN_ERROR() << "Can't mmap the file descriptor.";
++ }
++ return Mapping{
++ .pointer = mapping->data(),
++ .size = memory.size,
++ .context = std::move(mapping),
++ };
+ }
+
+ #endif // NN_COMPATIBILITY_LIBRARY_BUILD
+diff --git a/runtime/NeuralNetworks.cpp b/runtime/NeuralNetworks.cpp
+index 678888e9f..805a600bb 100644
+--- a/runtime/NeuralNetworks.cpp
++++ b/runtime/NeuralNetworks.cpp
+@@ -1927,7 +1927,7 @@ int SL_ANeuralNetworksDevice_forEachVendorExtensionOperandTypeInformation(
+ #define NNCL_FUNC(symbol) .symbol = symbol
+
+ NnApiSLDriverImplFL7 slDriverImpl{
+- .base{.implFeatureLevel = ANEURALNETWORKS_FEATURE_LEVEL_7},
++ .base={.implFeatureLevel = ANEURALNETWORKS_FEATURE_LEVEL_7},
+ NNCL_FUNC(ANeuralNetworksBurst_create),
+ NNCL_FUNC(ANeuralNetworksBurst_free),
+ NNCL_FUNC(ANeuralNetworksCompilation_createForDevices),
diff --git a/shim/sl/scripts/clone_aosp_libs.sh b/shim/sl/scripts/clone_aosp_libs.sh
new file mode 100755
index 0000000000..370126ada2
--- /dev/null
+++ b/shim/sl/scripts/clone_aosp_libs.sh
@@ -0,0 +1,84 @@
+#!/usr/bin/env bash
+
+#
+# Copyright © 2022 ARM Ltd and Contributors. All rights reserved.
+# SPDX-License-Identifier: MIT
+#
+
+AOSP_WORKING_DIR=$1
+
+if [ "$#" -ne 1 ]; then
+ echo "Usage: This script must be passed a single parameter which is a path "
+ echo " to an existing directory where the AOSP repo's will be cloned into."
+ echo "Error: No working directory path parameter provided."
+ exit 1
+fi
+if [ ! -d "$1" ]; then
+ echo "Usage: This script must be passed a single parameter which is a path "
+ echo " to an existing directory where the AOSP repo's will be cloned into."
+ echo "Error: Working directory path provided is not a directory."
+ exit 1
+fi
+
+echo "AOSP_WORKING_DIR = $AOSP_WORKING_DIR"
+
+# NNAPI SUPPORT (SHA's for each repo taken from master branch 25/03/22)
+git clone https://android.googlesource.com/platform/packages/modules/NeuralNetworks/ "${AOSP_WORKING_DIR}/packages/modules/NeuralNetworks"
+pushd "${AOSP_WORKING_DIR}/packages/modules/NeuralNetworks"
+git checkout 9c2360318a35756addcd5d321a85f9270e0a04da
+popd
+
+git clone https://android.googlesource.com/platform/system/core "${AOSP_WORKING_DIR}/system/core/"
+pushd "${AOSP_WORKING_DIR}/system/core/"
+git checkout c408ee943a1d9c486e4fac10bee7f76a61c75bab
+popd
+
+git clone https://android.googlesource.com/platform/system/libbase "${AOSP_WORKING_DIR}/system/libbase"
+pushd "${AOSP_WORKING_DIR}/system/libbase"
+git checkout 2d235ac982044ea4985c39a834e2d85c6a8bca8f
+popd
+
+git clone https://android.googlesource.com/platform/system/libfmq "${AOSP_WORKING_DIR}/system/libfmq"
+pushd "${AOSP_WORKING_DIR}/system/libfmq"
+git checkout 331b20e54ddde93785d7688ebb0cdc1cbcf9fd9b
+popd
+
+git clone https://android.googlesource.com/platform/frameworks/native "${AOSP_WORKING_DIR}/frameworks/native"
+pushd "${AOSP_WORKING_DIR}/frameworks/native"
+git checkout fea6523ac18c9d4d40db04c996e833f60ff88489
+popd
+
+git clone https://android.googlesource.com/platform/system/logging "${AOSP_WORKING_DIR}/system/logging"
+pushd "${AOSP_WORKING_DIR}/system/logging"
+git checkout e1a669e529cf5a42cd8b331ca89634bb9dce5cae
+popd
+
+git clone https://android.googlesource.com/platform/external/boringssl "${AOSP_WORKING_DIR}/external/boringssl"
+pushd "${AOSP_WORKING_DIR}/external/boringssl"
+git checkout ebeca38b4ecbe81fdf1d127ef7abb4689722308c
+popd
+
+git clone https://android.googlesource.com/platform/external/tensorflow "${AOSP_WORKING_DIR}/external/tensorflow"
+pushd "${AOSP_WORKING_DIR}/external/tensorflow"
+git checkout a6772d90a9b542ceb50f35f67e1cebf322d8b0d0
+popd
+
+git clone https://android.googlesource.com/platform/external/eigen "${AOSP_WORKING_DIR}/external/eigen"
+pushd "${AOSP_WORKING_DIR}/external/eigen"
+git checkout 10f298fc4175c1b8537c674f654a070c871960e5
+popd
+
+git clone https://android.googlesource.com/platform/external/ruy "${AOSP_WORKING_DIR}/external/ruy"
+pushd "${AOSP_WORKING_DIR}/external/ruy"
+git checkout 4377b97cf0850e0a61caa191586ebe68ccbc2abf
+popd
+
+git clone https://android.googlesource.com/platform/external/gemmlowp "${AOSP_WORKING_DIR}/external/gemmlowp"
+pushd "${AOSP_WORKING_DIR}/external/gemmlowp"
+git checkout 689c69e88b91e7bff068e33396f74c0a5b17390e
+popd
+
+git clone https://android.googlesource.com/platform/prebuilts/vndk/v29 "${AOSP_WORKING_DIR}/prebuilts/vndk/v29"
+pushd "${AOSP_WORKING_DIR}/prebuilts/vndk/v29"
+git checkout 5a73511dd91512681df643ce604d36763cd81b0e
+popd
diff --git a/shim/sl/scripts/libbase_logging_cpp.patch b/shim/sl/scripts/libbase_logging_cpp.patch
new file mode 100644
index 0000000000..ecf3e9ca36
--- /dev/null
+++ b/shim/sl/scripts/libbase_logging_cpp.patch
@@ -0,0 +1,171 @@
+diff --git a/logging.cpp b/logging.cpp
+index 4942e2f..1ff0996 100644
+--- a/logging.cpp
++++ b/logging.cpp
+@@ -209,9 +209,9 @@ static std::recursive_mutex& TagLock() {
+ static std::string* gDefaultTag;
+
+ void SetDefaultTag(const std::string& tag) {
+- if (__builtin_available(android 30, *)) {
+- __android_log_set_default_tag(tag.c_str());
+- } else {
++// if (__builtin_available(android 30, *)) {
++// __android_log_set_default_tag(tag.c_str());
++// } else {
+ std::lock_guard<std::recursive_mutex> lock(TagLock());
+ if (gDefaultTag != nullptr) {
+ delete gDefaultTag;
+@@ -220,7 +220,7 @@ void SetDefaultTag(const std::string& tag) {
+ if (!tag.empty()) {
+ gDefaultTag = new std::string(tag);
+ }
+- }
++// }
+ }
+
+ static bool gInitialized = false;
+@@ -314,13 +314,13 @@ static void LogdLogChunk(LogId id, LogSeverity severity, const char* tag, const
+ int32_t lg_id = LogIdTolog_id_t(id);
+ int32_t priority = LogSeverityToPriority(severity);
+
+- if (__builtin_available(android 30, *)) {
+- __android_log_message log_message = {sizeof(__android_log_message), lg_id, priority, tag,
+- static_cast<const char*>(nullptr), 0, message};
+- __android_log_logd_logger(&log_message);
+- } else {
++// if (__builtin_available(android 30, *)) {
++// __android_log_message log_message = {sizeof(__android_log_message), lg_id, priority, tag,
++// static_cast<const char*>(nullptr), 0, message};
++// __android_log_logd_logger(&log_message);
++// } else {
+ __android_log_buf_print(lg_id, priority, tag, "%s", message);
+- }
++// }
+ }
+
+ LogdLogger::LogdLogger(LogId default_log_id) : default_log_id_(default_log_id) {}
+@@ -396,15 +396,15 @@ LogFunction SetLogger(LogFunction&& logger) {
+ LogFunction old_logger = std::move(Logger());
+ Logger() = std::move(logger);
+
+- if (__builtin_available(android 30, *)) {
+- __android_log_set_logger([](const struct __android_log_message* log_message) {
+- auto log_id = log_id_tToLogId(log_message->buffer_id);
+- auto severity = PriorityToLogSeverity(log_message->priority);
+-
+- Logger()(log_id, severity, log_message->tag, log_message->file, log_message->line,
+- log_message->message);
+- });
+- }
++// if (__builtin_available(android 30, *)) {
++// __android_log_set_logger([](const struct __android_log_message* log_message) {
++// auto log_id = log_id_tToLogId(log_message->buffer_id);
++// auto severity = PriorityToLogSeverity(log_message->priority);
++//
++// Logger()(log_id, severity, log_message->tag, log_message->file, log_message->line,
++// log_message->message);
++// });
++// }
+ return old_logger;
+ }
+
+@@ -412,9 +412,9 @@ AbortFunction SetAborter(AbortFunction&& aborter) {
+ AbortFunction old_aborter = std::move(Aborter());
+ Aborter() = std::move(aborter);
+
+- if (__builtin_available(android 30, *)) {
+- __android_log_set_aborter([](const char* abort_message) { Aborter()(abort_message); });
+- }
++// if (__builtin_available(android 30, *)) {
++// __android_log_set_aborter([](const char* abort_message) { Aborter()(abort_message); });
++// }
+ return old_aborter;
+ }
+
+@@ -500,11 +500,11 @@ LogMessage::~LogMessage() {
+
+ // Abort if necessary.
+ if (data_->GetSeverity() == FATAL) {
+- if (__builtin_available(android 30, *)) {
+- __android_log_call_aborter(msg.c_str());
+- } else {
++// if (__builtin_available(android 30, *)) {
++// __android_log_call_aborter(msg.c_str());
++// } else {
+ Aborter()(msg.c_str());
+- }
++// }
+ }
+ }
+
+@@ -515,11 +515,11 @@ std::ostream& LogMessage::stream() {
+ void LogMessage::LogLine(const char* file, unsigned int line, LogSeverity severity, const char* tag,
+ const char* message) {
+ int32_t priority = LogSeverityToPriority(severity);
+- if (__builtin_available(android 30, *)) {
+- __android_log_message log_message = {
+- sizeof(__android_log_message), LOG_ID_DEFAULT, priority, tag, file, line, message};
+- __android_log_write_log_message(&log_message);
+- } else {
++// if (__builtin_available(android 30, *)) {
++// __android_log_message log_message = {
++// sizeof(__android_log_message), LOG_ID_DEFAULT, priority, tag, file, line, message};
++// __android_log_write_log_message(&log_message);
++// } else {
+ if (tag == nullptr) {
+ std::lock_guard<std::recursive_mutex> lock(TagLock());
+ if (gDefaultTag == nullptr) {
+@@ -530,38 +530,38 @@ void LogMessage::LogLine(const char* file, unsigned int line, LogSeverity severi
+ } else {
+ Logger()(DEFAULT, severity, tag, file, line, message);
+ }
+- }
++// }
+ }
+
+ LogSeverity GetMinimumLogSeverity() {
+- if (__builtin_available(android 30, *)) {
+- return PriorityToLogSeverity(__android_log_get_minimum_priority());
+- } else {
++// if (__builtin_available(android 30, *)) {
++// return PriorityToLogSeverity(__android_log_get_minimum_priority());
++// } else {
+ return gMinimumLogSeverity;
+- }
++// }
+ }
+
+ bool ShouldLog(LogSeverity severity, const char* tag) {
+ // Even though we're not using the R liblog functions in this function, if we're running on Q,
+ // we need to fall back to using gMinimumLogSeverity, since __android_log_is_loggable() will not
+ // take into consideration the value from SetMinimumLogSeverity().
+- if (__builtin_available(android 30, *)) {
+- int32_t priority = LogSeverityToPriority(severity);
+- return __android_log_is_loggable(priority, tag, ANDROID_LOG_INFO);
+- } else {
++// if (__builtin_available(android 30, *)) {
++// int32_t priority = LogSeverityToPriority(severity);
++// return __android_log_is_loggable(priority, tag, ANDROID_LOG_INFO);
++// } else {
+ return severity >= gMinimumLogSeverity;
+- }
++// }
+ }
+
+ LogSeverity SetMinimumLogSeverity(LogSeverity new_severity) {
+- if (__builtin_available(android 30, *)) {
+- int32_t priority = LogSeverityToPriority(new_severity);
+- return PriorityToLogSeverity(__android_log_set_minimum_priority(priority));
+- } else {
++// if (__builtin_available(android 30, *)) {
++// int32_t priority = LogSeverityToPriority(new_severity);
++// return PriorityToLogSeverity(__android_log_set_minimum_priority(priority));
++// } else {
+ LogSeverity old_severity = gMinimumLogSeverity;
+ gMinimumLogSeverity = new_severity;
+ return old_severity;
+- }
++// }
+ }
+
+ ScopedLogSeverity::ScopedLogSeverity(LogSeverity new_severity) {
diff --git a/shim/sl/scripts/modify_aosp_libs.sh b/shim/sl/scripts/modify_aosp_libs.sh
new file mode 100755
index 0000000000..c13976baf8
--- /dev/null
+++ b/shim/sl/scripts/modify_aosp_libs.sh
@@ -0,0 +1,36 @@
+#!/usr/bin/env bash
+
+#
+# Copyright © 2022 ARM Ltd and Contributors. All rights reserved.
+# SPDX-License-Identifier: MIT
+#
+
+AOSP_WORKING_DIR=$1
+
+if [ "$#" -ne 1 ]; then
+
+ echo "Usage: This script must be passed a single parameter which is a path "
+ echo " to an existing directory where the AOSP repo's have been cloned."
+ echo "Error: No working directory path parameter provided."
+ exit 1
+fi
+if [ ! -d "$1" ]; then
+
+ echo "Usage: This script must be passed a single parameter which is a path "
+ echo " to an existing directory where the AOSP repo's have been cloned."
+ echo "Error: Working directory path provided is not a directory."
+ exit 1
+fi
+
+SCRIPT_PATH=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
+echo "SCRIPT_PATH= ${SCRIPT_PATH}"
+
+pushd "${AOSP_WORKING_DIR}/system/libbase/"
+ echo "Applying libbase logging.cpp patch"
+ git apply "${SCRIPT_PATH}/libbase_logging_cpp.patch"
+popd
+
+pushd "${AOSP_WORKING_DIR}/packages/modules/NeuralNetworks/"
+ echo "Applying NeuralNetworks patch"
+ git apply "${SCRIPT_PATH}/NeuralNetworks.patch"
+popd