Sadik Armagan | 8f397a1 | 2022-06-17 15:38:22 +0100 | [diff] [blame] | 1 | diff --git a/common/types/src/SharedMemoryAndroid.cpp b/common/types/src/SharedMemoryAndroid.cpp |
| 2 | index c361a1eb6..3c09c5f4d 100644 |
| 3 | --- a/common/types/src/SharedMemoryAndroid.cpp |
| 4 | +++ b/common/types/src/SharedMemoryAndroid.cpp |
| 5 | @@ -115,8 +115,23 @@ GeneralResult<SharedMemory> allocateSharedMemory(size_t size) { |
| 6 | return createSharedMemoryFromUniqueFd(size, prot, std::move(fd), offset); |
| 7 | } |
| 8 | |
| 9 | -GeneralResult<Mapping> map(const Memory::Ashmem& /*memory*/) { |
| 10 | - return NN_ERROR(ErrorStatus::INVALID_ARGUMENT) << "Cannot map ashmem memory"; |
| 11 | +//GeneralResult<Mapping> map(const Memory::Ashmem& /*memory*/) { |
| 12 | +// return NN_ERROR(ErrorStatus::INVALID_ARGUMENT) << "Cannot map ashmem memory"; |
| 13 | +//} |
| 14 | + |
| 15 | +GeneralResult<Mapping> map(const Memory::Ashmem& memory) { |
| 16 | + constexpr off64_t offset = 0; |
| 17 | + constexpr int prot = PROT_READ | PROT_WRITE; |
| 18 | + std::shared_ptr<base::MappedFile> mapping = |
| 19 | + base::MappedFile::FromFd(memory.fd, offset, memory.size, prot); |
| 20 | + if (mapping == nullptr || mapping->data() == nullptr) { |
| 21 | + return NN_ERROR() << "Can't mmap the file descriptor."; |
| 22 | + } |
| 23 | + return Mapping{ |
| 24 | + .pointer = mapping->data(), |
| 25 | + .size = memory.size, |
| 26 | + .context = std::move(mapping), |
| 27 | + }; |
| 28 | } |
| 29 | |
| 30 | #endif // NN_COMPATIBILITY_LIBRARY_BUILD |
| 31 | diff --git a/runtime/NeuralNetworks.cpp b/runtime/NeuralNetworks.cpp |
| 32 | index 678888e9f..805a600bb 100644 |
| 33 | --- a/runtime/NeuralNetworks.cpp |
| 34 | +++ b/runtime/NeuralNetworks.cpp |
| 35 | @@ -1927,7 +1927,7 @@ int SL_ANeuralNetworksDevice_forEachVendorExtensionOperandTypeInformation( |
| 36 | #define NNCL_FUNC(symbol) .symbol = symbol |
| 37 | |
| 38 | NnApiSLDriverImplFL7 slDriverImpl{ |
| 39 | - .base{.implFeatureLevel = ANEURALNETWORKS_FEATURE_LEVEL_7}, |
| 40 | + .base={.implFeatureLevel = ANEURALNETWORKS_FEATURE_LEVEL_7}, |
| 41 | NNCL_FUNC(ANeuralNetworksBurst_create), |
| 42 | NNCL_FUNC(ANeuralNetworksBurst_free), |
| 43 | NNCL_FUNC(ANeuralNetworksCompilation_createForDevices), |