Mock ASharedMemory_create on non-Android platforms only if NNAPI is loaded
This ensures identical behaviour on platforms which use full nnapi_implementation.cc, but don't have libneuralnetworks.so library, and platforms which use nnapi_implementation_disabled.cc stub. PiperOrigin-RevId: 262387219
This commit is contained in:
parent
934c284867
commit
f71f815048
@ -178,7 +178,13 @@ const NnApi LoadNnApi() {
|
||||
}
|
||||
}
|
||||
#else
|
||||
nnapi.ASharedMemory_create = ASharedMemory_create;
|
||||
// Mock ASharedMemory_create only if libneuralnetworks.so was successfully
|
||||
// loaded. This ensures identical behaviour on platforms which use this
|
||||
// implementation, but don't have libneuralnetworks.so library, and
|
||||
// platforms which use nnapi_implementation_disabled.cc stub.
|
||||
if (libneuralnetworks != nullptr) {
|
||||
nnapi.ASharedMemory_create = ASharedMemory_create;
|
||||
}
|
||||
#endif // __ANDROID__
|
||||
|
||||
// API 28 (NN 1.1) methods.
|
||||
|
@ -116,7 +116,7 @@ TEST(NnapiLibTest, NnApiImplementation) {
|
||||
EXPECT_EQ(nnapi->ANeuralNetworksExecution_startCompute, nullptr);
|
||||
EXPECT_EQ(nnapi->ANeuralNetworksEvent_wait, nullptr);
|
||||
EXPECT_EQ(nnapi->ANeuralNetworksEvent_free, nullptr);
|
||||
EXPECT_NE(nnapi->ASharedMemory_create, nullptr);
|
||||
EXPECT_EQ(nnapi->ASharedMemory_create, nullptr);
|
||||
EXPECT_EQ(nnapi->ANeuralNetworks_getDeviceCount, nullptr);
|
||||
EXPECT_EQ(nnapi->ANeuralNetworks_getDevice, nullptr);
|
||||
EXPECT_EQ(nnapi->ANeuralNetworksDevice_getName, nullptr);
|
||||
|
Loading…
Reference in New Issue
Block a user