1 // 2 // Copyright © 2017 Arm Ltd. All rights reserved. 3 // SPDX-License-Identifier: MIT 4 // 5 6 #define LOG_TAG "ArmnnDriver" 7 8 #include "ArmnnDriver.hpp" 9 10 #include <hidl/LegacySupport.h> 11 #include <log/log.h> 12 13 #include <string> 14 15 using namespace armnn_driver; 16 using namespace std; 17 main(int argc,char ** argv)18int main(int argc, char** argv) 19 { 20 android::sp<ArmnnDriver> driver; 21 DriverOptions driverOptions(argc, argv); 22 23 if (driverOptions.ShouldExit()) 24 { 25 return driverOptions.GetExitCode(); 26 } 27 try 28 { 29 driver = new ArmnnDriver(DriverOptions(argc, argv)); 30 } 31 catch (const std::exception& e) 32 { 33 ALOGE("Could not create driver: %s", e.what()); 34 std::cout << "Unable to start:" << std::endl 35 << "Could not create driver: " << e.what() << std::endl; 36 return EXIT_FAILURE; 37 } 38 39 android::hardware::configureRpcThreadpool(1, true); 40 android::status_t status = android::UNKNOWN_ERROR; 41 try 42 { 43 status = driver->registerAsService(driverOptions.GetServiceName()); 44 } 45 catch (const std::exception& e) 46 { 47 ALOGE("Could not register service: %s", e.what()); 48 std::cout << "Unable to start:" << std::endl 49 << "Could not register service: " << e.what() << std::endl; 50 return EXIT_FAILURE; 51 } 52 53 if (status != android::OK) 54 { 55 ALOGE("Could not register service"); 56 std::cout << "Unable to start:" << std::endl 57 << "Could not register service" << std::endl; 58 return EXIT_FAILURE; 59 } 60 android::hardware::joinRpcThreadpool(); 61 ALOGW("Service exited!"); 62 return EXIT_SUCCESS; 63 } 64