# QNN delegate 的外部 delegate 选项

Source: [https://docs.qualcomm.com/doc/80-70014-54Y/topic/external-delegate-options-for-qnn-delegate.html](https://docs.qualcomm.com/doc/80-70014-54Y/topic/external-delegate-options-for-qnn-delegate.html)

外部 delegate 接口动态加载 Qualcomm AI Engine Direct delegate。因此，它没有关于 Qualcomm AI Engine Direct delegate 选项的静态信息。

外部 delegate 将字符串作为键值对发送给 Qualcomm AI Engine Direct delegate，后者将其解析为选项。使用外部 delegate 接口的应用程序必须事先知道接受的键和值选项字符串。

下表列出了 Qualcomm AI Engine Direct delegate 中可用的键值选项字符串：

Table : 键值选项字符串

| 选项键 | 选项值 | 默认值 | 必选 | 说明 |
| --- | --- | --- | --- | --- |
| backend\_type | gpu 和 htp | NA | 是 | 用于打开和运行图表的后端 Qualcomm AI Engine Direct 库。 |
| gpu\_precision | 0, 1, 2, 3 | 2 = Float16 以获得最佳性能 | 否 | GPU 后端的精度定义了图张量（输入或输出张量）的优化级别。<br><br><br>                            <ul class="ul" id="external-delegate-options-for-qnn-delegate__ul_vgz_x5m_tbc"><br>                                <li class="li">0：遵守 TensorFlow Lite 图中指定的精度</li><br><br>                                <li class="li">1：Float32</li><br><br>                                <li class="li">2：Float16</li><br><br>                                <li class="li">3: 混合</li><br><br>                            </ul> |
| gpu\_performance\_mode | 0, 1, 2, 3 | 0 = 默认值 | 否 | 用于提供 GPU 后端支持的精度模式的标志。<br><br><br>                            <ul class="ul" id="external-delegate-options-for-qnn-delegate__ul_wgz_x5m_tbc"><br>                                <li class="li">0：默认值</li><br><br>                                <li class="li">1：高</li><br><br>                                <li class="li">2：正常</li><br><br>                                <li class="li">3: 低</li><br><br>                            </ul> |
| htp\_performance\_mode | 0, 1, 2, 3, 4, 5, 6, 7, 8 | 0 = 默认值 | 否 | 当使用 performance\_mode 时，delegate 会在推理过程中优先选择用户提供的性能级别，并在推理完成后恢复到较为宽松的状态。<br><br><br>                            <ul class="ul" id="external-delegate-options-for-qnn-delegate__ul_xgz_x5m_tbc"><br>                                <li class="li">0：默认值</li><br><br>                                <li class="li">1：持续的高性能</li><br><br>                                <li class="li">2：突发</li><br><br>                                <li class="li">3: 高性能</li><br><br>                                <li class="li">4: 节能</li><br><br>                                <li class="li">5: 低节能</li><br><br>                                <li class="li">6: 高节能</li><br><br>                                <li class="li">7：低平衡</li><br><br>                                <li class="li">8: 平衡</li><br><br>                            </ul> |
| htp\_pd\_session | unsigned, signed | unsigned | 否 | 此标志定义 Hexagon Tensor Processor 后端的 PD 会话。 |
| htp\_precision | 0 | 0 = 量化精度 | 否 | 用于提供 Hexagon Tensor Processor 后端支持的精度模式的标志。默认精度模式支持量化网络。其他精度模式可能仅在某些 SoC 上受支持。<br><br><br>                            <ul class="ul" id="external-delegate-options-for-qnn-delegate__ul_ygz_x5m_tbc"><br>                                <li class="li">0：量化精度</li><br><br>                            </ul> |
| htp\_optimization\_strategy | 0, 1 | 0 = 优化推理 | 否 | 用于选择 Hexagon Tensor Processor 后端优化策略的标志。默认优化策略对图进行推理优化。<br><br><br>                            <ul class="ul" id="external-delegate-options-for-qnn-delegate__ul_zgz_x5m_tbc"><br>                                <li class="li">0：优化推理</li><br><br>                                <li class="li">1：优化准备</li><br><br>                            </ul> |
| htp\_perf\_ctrl\_strategy | 0, 1 | 0 = 手动 | 否 | 用于选择 Hexagon Tensor Processor 性能控制策略的标志。在初始化后端时手动评估性能，并在销毁后端时释放性能。<br><br><br>                            <ul class="ul" id="external-delegate-options-for-qnn-delegate__ul_ahz_x5m_tbc"><br>                                <li class="li">0：手动</li><br><br>                                <li class="li">1：自动</li><br><br>                            </ul> |
| htp\_use\_conv\_hmx | 0, 1 | 1 = 启用 HMX 以支持浅层 conv2d | 否 | 启用 HMX 以支持浅层 conv2d 的标志。更多信息，参见 C 接口或 qnn\_delegate.h。<br><br><br>                            <ul class="ul" id="external-delegate-options-for-qnn-delegate__ul_bhz_x5m_tbc"><br>                                <li class="li">0：不为浅层 conv2d 启用 HMX。</li><br><br>                                <li class="li">1：为浅层 conv2d 启用 HMX。</li><br><br>                            </ul> |
| htp\_use\_fold\_relu | 0,1 | 0 = 不将 Relu 融合到 conv2d 中 | 否 | 启用 Relu 与 conv2d 融合的标志。更多信息，参见 C 接口或 qnn\_delegate.h。<br><br><br>                            <ul class="ul" id="external-delegate-options-for-qnn-delegate__ul_chz_x5m_tbc"><br>                                <li class="li">0：不要启用 Relu 与 conv2d 的融合。</li><br><br>                                <li class="li">1：启用 Relu 与 conv2d 的融合。</li><br><br>                            </ul> |
| library\_path | &lt;Path to backend library file&gt; | 与所选 Qualcomm AI Engine Direct 后端关联的默认库 | 否 | 可选参数，用于覆写 Qualcomm AI Engine Direct 后端库。 |

Last Published: Aug 06, 2024

[Previous Topic
使用外部 delegate 接口运行 QNN delegate](https://docs.qualcomm.com/bundle/publicresource/80-70014-54Y/topics/run-qnn-delegate-using-the-external-delegate-interface.md) [Next Topic
可选：编译 TensorFlow Lite Runtime](https://docs.qualcomm.com/bundle/publicresource/80-70014-54Y/topics/build-qualcomm-linux-and-install-tensorflow-lite-runtime.md)