[qnn ep] include qnn sdk in onnxruntime-qnn python whl (#20485)

script changes to include qnn sdk libs with onnxruntime-qnn python
package.
This commit is contained in:
George Wu 2024-04-29 09:44:54 -07:00 committed by GitHub
parent 3e4db2c686
commit 49b2bebe85
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 42 additions and 4 deletions

View file

@ -1015,6 +1015,14 @@ if (onnxruntime_USE_QNN)
${QNN_LIB_FILES}
$<TARGET_FILE_DIR:${build_output_target}>/onnxruntime/capi/
)
if (EXISTS "${onnxruntime_QNN_HOME}/Qualcomm AI Hub Proprietary License.pdf")
add_custom_command(
TARGET onnxruntime_pybind11_state POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
"${onnxruntime_QNN_HOME}/Qualcomm AI Hub Proprietary License.pdf"
$<TARGET_FILE_DIR:${build_output_target}>/onnxruntime/
)
endif()
endif()
endif()

View file

@ -1286,8 +1286,24 @@ void* QnnBackendManager::LoadLib(const char* file_name, int flags, std::string&
return nullptr;
}
// search from system lib path first
HMODULE mod = LoadLibraryExA(file_name, nullptr, LOAD_WITH_ALTERED_SEARCH_PATH);
HMODULE mod;
auto file_path = std::filesystem::path(file_name);
if (!file_path.is_absolute()) {
// construct an absolute path from ORT runtime path + file_name and check whether it exists.
auto pathstring = Env::Default().GetRuntimePath() + ToPathString(file_name);
auto absolute_path = pathstring.c_str();
if (std::filesystem::exists(std::filesystem::path(absolute_path))) {
// load library from absolute path and search for dependencies there.
mod = LoadLibraryExW(absolute_path, nullptr, LOAD_WITH_ALTERED_SEARCH_PATH);
} else {
// use default dll search order for file_name.
mod = LoadLibraryExA(file_name, nullptr, 0);
}
} else {
// file_name represents an absolute path.
// load library from absolute path and search for dependencies there.
mod = LoadLibraryExA(file_name, nullptr, LOAD_WITH_ALTERED_SEARCH_PATH);
}
if (!mod) {
error_msg = "load library failed";
return nullptr;

View file

@ -332,6 +332,20 @@ else:
libs.extend(["onnxruntime_providers_vitisai.dll"])
# DirectML Libs
libs.extend(["DirectML.dll"])
# QNN V68/V73 dependencies
qnn_deps = [
"QnnCpu.dll",
"QnnHtp.dll",
"QnnSaver.dll",
"QnnSystem.dll",
"QnnHtpPrepare.dll",
"QnnHtpV73Stub.dll",
"libQnnHtpV73Skel.so",
"libqnnhtpv73.cat",
"QnnHtpV68Stub.dll",
"libQnnHtpV68Skel.so",
]
libs.extend(qnn_deps)
if nightly_build:
libs.extend(["onnxruntime_pywrapper.dll"])
@ -376,8 +390,8 @@ else:
examples_names = ["mul_1.onnx", "logreg_iris.onnx", "sigmoid.onnx"]
examples = [path.join("datasets", x) for x in examples_names]
# Extra files such as EULA and ThirdPartyNotices
extra = ["LICENSE", "ThirdPartyNotices.txt", "Privacy.md"]
# Extra files such as EULA and ThirdPartyNotices (and Qualcomm License, only for QNN release packages)
extra = ["LICENSE", "ThirdPartyNotices.txt", "Privacy.md", "Qualcomm AI Hub Proprietary License.pdf"]
# Description
readme_file = "docs/python/ReadMeOV.rst" if is_openvino else "docs/python/README.rst"