使用框架
Qualcomm® AI Hub 支持使用多個 Qualcomm® AI Engine Direct 版本進行編譯、分析文件和推理作業。
查詢框架
To programmatically get a list of all supported Qualcomm® AI Engine Direct versions, use get_frameworks().
import qai_hub as hub
client = hub.Client()
supported_frameworks = client.get_frameworks()
print(supported_frameworks)
請注意,這也可以通過 CLI 使用
qai-hub list-frameworks
每個框架有兩個特殊標籤:
default:指的是在 Qualcomm® AI Hub Workbench 中使用的框架預設版本。
latest:指的是在 Qualcomm® AI Hub Workbench 中使用的框架最新釋出版本。
使用框架版本提交作業
Compile, profile, or inference jobs can be submitted with a specific framework
version identified by the api_version listed in get_frameworks()
import qai_hub as hub
client = hub.Client()
compile_job = client.submit_compile_job(
model="mobilenet_v2.onnx",
device=hub.Device("Samsung Galaxy S23 (Family)"),
target_runime="qnn_context_binary",
options="--qairt_version 2.31"
)
print(compile_job)
框架也可以使用 default 或 latest 標籤來識別。以下代碼示例使用最新可用版本的 Qualcomm® AI Engine Direct 框架
import qai_hub as hub
client = hub.Client()
compile_job = client.submit_compile_job(
model="mobilenet_v2.onnx",
device=hub.Device("Samsung Galaxy S23 (Family)"),
target_runime="qnn_context_binary",
options="--qairt_version latest"
)
print(compile_job)
以下代碼示例使用默認(最穩定)版本的 Qualcomm® AI Engine Direct 框架
import qai_hub as hub
client = hub.Client()
compile_job = client.submit_compile_job(
model="mobilenet_v2.onnx",
device=hub.Device("Samsung Galaxy S23 (Family)"),
target_runime="qnn_context_binary",
options="--qairt_version default"
)
print(compile_job)
版本選擇
當提交包含明確指定 Qualcomm® AI Runtime 版本的設定檔或推論工作時,若該版本與輸入模型相容,Qualcomm® AI Hub Workbench 會使用該版本;如果請求的版本與輸入模型不相容,Qualcomm® AI Hub Workbench 會回傳錯誤。
當提交設定檔或推論工作時,若未明確指定 Qualcomm® AI Runtime 版本,Qualcomm® AI Hub Workbench 會根據輸入模型自動選擇相容的版本。
如果輸入模型不是 Qualcomm® AI Engine Direct 資產(例如 TensorFlow Lite 模型或標準 ONNX 模型),Qualcomm® AI Hub Workbench 會一律選擇預設的 Qualcomm® AI Engine Direct 版本。
If the input model is a DLC or a context binary model Qualcomm® AI Engine Direct asset, Qualcomm® AI Hub Workbench will query the Qualcomm® AI Engine Direct version from the asset in order to select a compatible Qualcomm® AI Engine Direct version. The default Qualcomm® AI Engine Direct version is used if it is compatible with the model; the latest Qualcomm® AI Engine Direct version is used if the default version is not compatible with the model. An error will be returned if no compatible version is available.