diff options
Diffstat (limited to 'shim/sl/scripts')
-rw-r--r-- | shim/sl/scripts/NeuralNetworks.patch | 39 | ||||
-rw-r--r-- | shim/sl/scripts/NeuralNetworks_cpp.patch | 13 | ||||
-rwxr-xr-x | shim/sl/scripts/modify_aosp_libs.sh | 8 |
3 files changed, 43 insertions, 17 deletions
diff --git a/shim/sl/scripts/NeuralNetworks.patch b/shim/sl/scripts/NeuralNetworks.patch new file mode 100644 index 0000000000..c33177e081 --- /dev/null +++ b/shim/sl/scripts/NeuralNetworks.patch @@ -0,0 +1,39 @@ +diff --git a/common/SharedMemoryAndroid.cpp b/common/SharedMemoryAndroid.cpp +index 4730de36b..896d643e7 100644 +--- a/common/SharedMemoryAndroid.cpp ++++ b/common/SharedMemoryAndroid.cpp +@@ -160,8 +160,19 @@ 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) { ++ 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 b91d3ce45..8977dac68 100644 +--- a/runtime/NeuralNetworks.cpp ++++ b/runtime/NeuralNetworks.cpp +@@ -1859,7 +1859,7 @@ int SL_ANeuralNetworksDevice_forEachVendorExtensionOperandTypeInformation( + #define NNCL_FUNC(symbol) .symbol = symbol + + NnApiSLDriverImplFL5 slDriverImpl{ +- .base{.implFeatureLevel = ANEURALNETWORKS_FEATURE_LEVEL_5}, ++ .base={.implFeatureLevel = ANEURALNETWORKS_FEATURE_LEVEL_5}, + NNCL_FUNC(ANeuralNetworksBurst_create), + NNCL_FUNC(ANeuralNetworksBurst_free), + NNCL_FUNC(ANeuralNetworksCompilation_createForDevices), diff --git a/shim/sl/scripts/NeuralNetworks_cpp.patch b/shim/sl/scripts/NeuralNetworks_cpp.patch deleted file mode 100644 index 40bdc07e8b..0000000000 --- a/shim/sl/scripts/NeuralNetworks_cpp.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/runtime/NeuralNetworks.cpp b/runtime/NeuralNetworks.cpp -index b91d3ce45..8977dac68 100644 ---- a/runtime/NeuralNetworks.cpp -+++ b/runtime/NeuralNetworks.cpp -@@ -1859,7 +1859,7 @@ int SL_ANeuralNetworksDevice_forEachVendorExtensionOperandTypeInformation( - #define NNCL_FUNC(symbol) .symbol = symbol - - NnApiSLDriverImplFL5 slDriverImpl{ -- .base{.implFeatureLevel = ANEURALNETWORKS_FEATURE_LEVEL_5}, -+ .base={.implFeatureLevel = ANEURALNETWORKS_FEATURE_LEVEL_5}, - NNCL_FUNC(ANeuralNetworksBurst_create), - NNCL_FUNC(ANeuralNetworksBurst_free), - NNCL_FUNC(ANeuralNetworksCompilation_createForDevices), diff --git a/shim/sl/scripts/modify_aosp_libs.sh b/shim/sl/scripts/modify_aosp_libs.sh index c991678dd2..b10a36cfd1 100755 --- a/shim/sl/scripts/modify_aosp_libs.sh +++ b/shim/sl/scripts/modify_aosp_libs.sh @@ -11,12 +11,12 @@ pushd "${AOSP_DIR}/system/libbase/" popd pushd "${AOSP_DIR}/packages/modules/NeuralNetworks/" - echo "Applying NeuralNetworks.cpp patch" - git apply "${SCRIPT_PATH}/NeuralNetworks_cpp.patch" + echo "Applying NeuralNetworks patch" + git apply "${SCRIPT_PATH}/NeuralNetworks.patch" echo " Checking out master version of SharedMemory.h/.cpp which includes convertRequestFromPointerToShared" - git checkout master -- common/SharedMemory.cpp - git checkout master -- common/include/nnapi/SharedMemory.h + git checkout 736317504083629929373bd349f667893bc8204c -- common/SharedMemory.cpp + git checkout 736317504083629929373bd349f667893bc8204c -- common/include/nnapi/SharedMemory.h popd pushd "${SCRIPT_PATH}/.." |