ArmNN
 24.02
shimservice.cpp File Reference
#include <android-base/logging.h>
#include <android-base/scopeguard.h>
#include <dlfcn.h>
#include "NeuralNetworksShim.h"
#include "SupportLibrarySymbols.h"
#include <string>
Include dependency graph for shimservice.cpp:

Go to the source code of this file.

Macros

#define LOG_TAG   "ArmnnDriver"
 

Functions

int main ()
 

Macro Definition Documentation

◆ LOG_TAG

#define LOG_TAG   "ArmnnDriver"

Definition at line 6 of file shimservice.cpp.

Function Documentation

◆ main()

int main ( )

The platform shim allows use of the armnn support library driver (arm-armnn-sl) to create a binderized vendor service (arm-armnn-shim) that is started at device startup

Definition at line 19 of file shimservice.cpp.

20 {
21  /// The platform shim allows use of the armnn support library driver (arm-armnn-sl) to create a
22  /// binderized vendor service (arm-armnn-shim) that is started at device startup
23 
24  NnApiSLDriverImpl* impl = ANeuralNetworks_getSLDriverImpl();
25  if (impl == nullptr)
26  {
27  LOG(ERROR) << "ArmnnDriver: ANeuralNetworks_getSLDriverImpl returned nullptr!!!";
28  return EXIT_FAILURE;
29  }
30 
31  ANeuralNetworksShimDeviceInfo* deviceInfo;
32  ANeuralNetworksShimDeviceInfo_create(&deviceInfo,
33  /*deviceName=*/"arm-armnn-sl",
34  /*serviceName=*/"arm-armnn-shim");
35  const auto guardDeviceInfo = android::base::make_scope_guard(
36  [deviceInfo] { ANeuralNetworksShimDeviceInfo_free(deviceInfo); });
37 
38  ANeuralNetworksShimRegistrationParams* params;
39  ANeuralNetworksShimRegistrationParams_create(impl, &params);
40  const auto guardParams = android::base::make_scope_guard(
41  [params] { ANeuralNetworksShimRegistrationParams_free(params); });
42  ANeuralNetworksShimRegistrationParams_addDeviceInfo(params, deviceInfo);
43  ANeuralNetworksShimRegistrationParams_setNumberOfListenerThreads(params, 15);
44  ANeuralNetworksShimRegistrationParams_registerAsLazyService(params, false);
45  ANeuralNetworksShimRegistrationParams_fallbackToMinimumSupportDevice(params, false);
46 
47  auto result = ANeuralNetworksShim_registerSupportLibraryService(params);
48  LOG(ERROR) << "ArmnnDriver: ANeuralNetworksShim_registerSupportLibraryService returned error status: " << result;
49 
50  return EXIT_FAILURE;
51 }