未验证 提交 3675f0b0 编写于 作者: O openharmony_ci 提交者: Gitee

!8680 适配新的NNRT API

Merge pull request !8680 from zhuguodong/master
...@@ -63,21 +63,21 @@ void AddContextDeviceCPU(OH_AI_ContextHandle context) { ...@@ -63,21 +63,21 @@ void AddContextDeviceCPU(OH_AI_ContextHandle context) {
// add nnrt device info // add nnrt device info
void AddContextDeviceNNRT(OH_AI_ContextHandle context) { void AddContextDeviceNNRT(OH_AI_ContextHandle context) {
size_t num = 0; size_t num = 0;
auto desc = OH_AI_NNRTGetAllDeviceDescs(&num); auto desc = OH_AI_GetAllNNRTDeviceDescs(&num);
if (desc == nullptr) { if (desc == nullptr) {
return; return;
} }
std::cout << "found " << num << " nnrt devices" << std::endl; std::cout << "found " << num << " nnrt devices" << std::endl;
auto id = OH_AI_NNRTDeviceDescGetId(desc); auto id = OH_AI_GetDeviceIdFromNNRTDeviceDesc(desc);
auto name = OH_AI_NNRTDeviceDescGetName(desc); auto name = OH_AI_GetNameFromNNRTDeviceDesc(desc);
auto type = OH_AI_NNRTDeviceDescGetType(desc); auto type = OH_AI_GetTypeFromNNRTDeviceDesc(desc);
std::cout << "NNRT device: id = " << id << ", name: " << name << ", type:" << type << std::endl; std::cout << "NNRT device: id = " << id << ", name: " << name << ", type:" << type << std::endl;
OH_AI_DeviceInfoHandle nnrt_device_info = OH_AI_DeviceInfoCreate(OH_AI_DEVICETYPE_NNRT); OH_AI_DeviceInfoHandle nnrt_device_info = OH_AI_DeviceInfoCreate(OH_AI_DEVICETYPE_NNRT);
ASSERT_NE(nnrt_device_info, nullptr); ASSERT_NE(nnrt_device_info, nullptr);
OH_AI_DeviceInfoSetDeviceId(nnrt_device_info, id); OH_AI_DeviceInfoSetDeviceId(nnrt_device_info, id);
OH_AI_NNRTDestroyAllDeviceDescs(&desc); OH_AI_DestroyAllNNRTDeviceDescs(&desc);
OH_AI_DeviceType device_type = OH_AI_DeviceInfoGetDeviceType(nnrt_device_info); OH_AI_DeviceType device_type = OH_AI_DeviceInfoGetDeviceType(nnrt_device_info);
printf("==========device_type:%d\n", device_type); printf("==========device_type:%d\n", device_type);
...@@ -94,18 +94,18 @@ void AddContextDeviceNNRT(OH_AI_ContextHandle context) { ...@@ -94,18 +94,18 @@ void AddContextDeviceNNRT(OH_AI_ContextHandle context) {
// add nnrt device info by type // add nnrt device info by type
void AddContextDeviceNNRTByType(OH_AI_ContextHandle context) { void AddContextDeviceNNRTByType(OH_AI_ContextHandle context) {
size_t num = 0; size_t num = 0;
auto desc = OH_AI_NNRTGetAllDeviceDescs(&num); auto desc = OH_AI_GetAllNNRTDeviceDescs(&num);
if (desc == nullptr) { if (desc == nullptr) {
return; return;
} }
std::cout << "found " << num << " nnrt devices" << std::endl; std::cout << "found " << num << " nnrt devices" << std::endl;
auto id = OH_AI_NNRTDeviceDescGetId(desc); auto id = OH_AI_GetDeviceIdFromNNRTDeviceDesc(desc);
auto name = OH_AI_NNRTDeviceDescGetName(desc); auto name = OH_AI_GetNameFromNNRTDeviceDesc(desc);
auto type = OH_AI_NNRTDeviceDescGetType(desc); auto type = OH_AI_GetTypeFromNNRTDeviceDesc(desc);
std::cout << "NNRT device: id = " << id << ", name: " << name << ", type:" << type << std::endl; std::cout << "NNRT device: id = " << id << ", name: " << name << ", type:" << type << std::endl;
auto nnrt_device_info = OH_AI_CreateNNRTDeviceInfoByType(type); auto nnrt_device_info = OH_AI_CreateNNRTDeviceInfoByType(type);
OH_AI_NNRTDestroyAllDeviceDescs(&desc); OH_AI_DestroyAllNNRTDeviceDescs(&desc);
ASSERT_NE(nnrt_device_info, nullptr); ASSERT_NE(nnrt_device_info, nullptr);
OH_AI_DeviceType device_type = OH_AI_DeviceInfoGetDeviceType(nnrt_device_info); OH_AI_DeviceType device_type = OH_AI_DeviceInfoGetDeviceType(nnrt_device_info);
...@@ -119,18 +119,18 @@ void AddContextDeviceNNRTByType(OH_AI_ContextHandle context) { ...@@ -119,18 +119,18 @@ void AddContextDeviceNNRTByType(OH_AI_ContextHandle context) {
// add nnrt device info by name // add nnrt device info by name
void AddContextDeviceNNRTByName(OH_AI_ContextHandle context) { void AddContextDeviceNNRTByName(OH_AI_ContextHandle context) {
size_t num = 0; size_t num = 0;
auto desc = OH_AI_NNRTGetAllDeviceDescs(&num); auto desc = OH_AI_GetAllNNRTDeviceDescs(&num);
if (desc == nullptr) { if (desc == nullptr) {
return; return;
} }
std::cout << "found " << num << " nnrt devices" << std::endl; std::cout << "found " << num << " nnrt devices" << std::endl;
auto id = OH_AI_NNRTDeviceDescGetId(desc); auto id = OH_AI_GetDeviceIdFromNNRTDeviceDesc(desc);
auto name = OH_AI_NNRTDeviceDescGetName(desc); auto name = OH_AI_GetNameFromNNRTDeviceDesc(desc);
auto type = OH_AI_NNRTDeviceDescGetType(desc); auto type = OH_AI_GetTypeFromNNRTDeviceDesc(desc);
std::cout << "NNRT device: id = " << id << ", name: " << name << ", type:" << type << std::endl; std::cout << "NNRT device: id = " << id << ", name: " << name << ", type:" << type << std::endl;
auto nnrt_device_info = OH_AI_CreateNNRTDeviceInfoByName(name); auto nnrt_device_info = OH_AI_CreateNNRTDeviceInfoByName(name);
OH_AI_NNRTDestroyAllDeviceDescs(&desc); OH_AI_DestroyAllNNRTDeviceDescs(&desc);
ASSERT_NE(nnrt_device_info, nullptr); ASSERT_NE(nnrt_device_info, nullptr);
OH_AI_DeviceType device_type = OH_AI_DeviceInfoGetDeviceType(nnrt_device_info); OH_AI_DeviceType device_type = OH_AI_DeviceInfoGetDeviceType(nnrt_device_info);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册