1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
| 你可以参考 SDK 中这部分的文档docs\general\api2_migration_guide.html
Offline 生成cache 的代码可以不用指定 device 相关的信息,只需要在device 跑的时候再指定。你也可以在生成cache的时候就指定。
下面是我再QNN 2.2 上可以跑到htp1 的例子 deviceID = 1u 如果是1就指定context 绑定的context 运行在HTP1 上,如果是0 就指定到HTP0 上。或者你在设备上也可以通过deviceGetPlatformInfo去查询硬件信息
uint32_t desiredDeviceType = 0u; uint32_t desiredCoreType = 0u; uint32_t deviceID = 1u;
QnnDevice_CoreInfo_t coreSpec = QNN_DEVICE_CORE_INFO_INIT; coreSpec.v1.coreType = desiredCoreType; coreSpec.v1.coreId = 0;
QnnDevice_HardwareDeviceInfo_t deviceSpec = QNN_DEVICE_HARDWARE_DEVICE_INFO_INIT; deviceSpec.v1.deviceId = deviceID; deviceSpec.v1.deviceType = 0; deviceSpec.v1.numCores = 1u; deviceSpec.v1.cores = &coreSpec;
QnnDevice_PlatformInfo_t hardwareSpec = QNN_DEVICE_PLATFORM_INFO_INIT; hardwareSpec.v1.numHwDevices = 1u; hardwareSpec.v1.hwDevices = &deviceSpec;
QnnDevice_Config_t hardwareConfig = QNN_DEVICE_CONFIG_INIT; hardwareConfig.option = QNN_DEVICE_CONFIG_OPTION_PLATFORM_INFO; hardwareConfig.hardwareInfo = &hardwareSpec;
const QnnDevice_Config_t* configs[] = {&hardwareConfig, NULL};
if (QNN_CONTEXT_NO_ERROR != m_qnnFunctionPointers.qnnInterface.deviceCreate( nullptr, configs, &m_deviceHandle))
contextCreateFromBinary(xxx,m_deviceHandle,xxx)
|