Minor build and test setup fixes (#523)
* Build fixes - zlib needs to come from vcpkg if azures ops are being built and opencv isn't enabled - set the IR version to 8 for some of the azure ops test models so they can be tested when ORT 1.14 is used - pass through new ort version value so that a consistent version is used to a) pull the ORT package for the c++ unit tests and b) disable azure ops if ORT version is too old. * Update to automatically chain package to avoid build errors during the install if cmake runs commands in parallel * Define simplified ORT_FILE for older ORT versions
This commit is contained in:
Родитель
ee14fbe48e
Коммит
3b947b5580
|
@ -718,13 +718,14 @@ if(OCOS_ENABLE_AZURE)
|
|||
|
||||
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
set(curl_LIB_NAME "libcurl-d")
|
||||
set(zlib_LIB_NAME "zlibd")
|
||||
target_link_directories(ocos_operators PUBLIC ${VCPKG_SRC}/installed/${vcpkg_triplet}/debug/lib)
|
||||
else()
|
||||
set(curl_LIB_NAME "libcurl")
|
||||
set(zlib_LIB_NAME "zlib")
|
||||
target_link_directories(ocos_operators PUBLIC ${VCPKG_SRC}/installed/${vcpkg_triplet}/lib)
|
||||
endif()
|
||||
|
||||
target_link_libraries(ocos_operators PUBLIC httpclient_static ${curl_LIB_NAME} ws2_32 crypt32 Wldap32)
|
||||
target_link_libraries(ocos_operators PUBLIC httpclient_static ${curl_LIB_NAME} ${zlib_LIB_NAME} ws2_32 crypt32 Wldap32)
|
||||
else()
|
||||
find_package(ZLIB REQUIRED)
|
||||
|
||||
|
|
|
@ -9,7 +9,11 @@ else()
|
|||
message(STATUS "CMAKE_GENERATOR_PLATFORM=${CMAKE_GENERATOR_PLATFORM}")
|
||||
|
||||
# 1.15.1 is the latest ORT release.
|
||||
set(ONNXRUNTIME_VER "1.15.1")
|
||||
if (OCOS_ONNXRUNTIME_VERSION)
|
||||
set(ONNXRUNTIME_VER ${OCOS_ONNXRUNTIME_VERSION})
|
||||
else()
|
||||
set(ONNXRUNTIME_VER "1.15.1")
|
||||
endif()
|
||||
|
||||
if(APPLE)
|
||||
set(ONNXRUNTIME_URL "v${ONNXRUNTIME_VER}/onnxruntime-osx-universal2-${ONNXRUNTIME_VER}.tgz")
|
||||
|
|
|
@ -36,7 +36,15 @@ if (WIN32)
|
|||
add_custom_target(vcpkg_integrate ALL DEPENDS vcpkg_integrate.stamp)
|
||||
set(VCPKG_DEPENDENCIES "vcpkg_integrate")
|
||||
|
||||
function(vcpkg_install PACKAGE_NAME)
|
||||
# we need the installs to be sequential otherwise you get strange build errors,
|
||||
# and create fake dependencies between each to make the install of each package sequential
|
||||
set(PACKAGE_NAMES rapidjson # required by triton
|
||||
zlib # required by curl. zlib also comes from opencv if enabled. TODO: check compatibility
|
||||
openssl
|
||||
curl)
|
||||
|
||||
foreach(PACKAGE_NAME ${PACKAGE_NAMES})
|
||||
message(STATUS "Adding vcpkg package: ${PACKAGE_NAME}")
|
||||
add_custom_command(
|
||||
OUTPUT ${VCPKG_SRC}/packages/${PACKAGE_NAME}_${vcpkg_triplet}/BUILD_INFO
|
||||
COMMAND ${CMAKE_COMMAND} -E echo ${VCPKG_SRC}/vcpkg install --vcpkg-root=$ENV{VCPKG_ROOT}
|
||||
|
@ -51,21 +59,15 @@ if (WIN32)
|
|||
ALL
|
||||
DEPENDS ${VCPKG_SRC}/packages/${PACKAGE_NAME}_${vcpkg_triplet}/BUILD_INFO)
|
||||
|
||||
list(APPEND VCPKG_DEPENDENCIES "get${PACKAGE_NAME}")
|
||||
set(VCPKG_DEPENDENCIES ${VCPKG_DEPENDENCIES} PARENT_SCOPE)
|
||||
endfunction()
|
||||
set(_cur_package "get${PACKAGE_NAME}")
|
||||
list(APPEND VCPKG_DEPENDENCIES ${_cur_package})
|
||||
|
||||
vcpkg_install(rapidjson) # required by triton
|
||||
vcpkg_install(openssl)
|
||||
vcpkg_install(curl)
|
||||
|
||||
# fake dependency between openssl and rapidjson.
|
||||
# without this 2 `vcpkg install` commands run in parallel which results in errors like this on the first build:
|
||||
# write_contents_and_dirs("D:\src\github\ort-extensions\.scb\temp.win-amd64-cpython-311\Release\_deps\vcpkg\src\vcpkg\buildtrees\0.vcpkg_tags.cmake"): permission denied
|
||||
# second attempt works, but that's not good enough for a CI.
|
||||
add_dependencies(getopenssl getrapidjson)
|
||||
|
||||
add_dependencies(getcurl getopenssl)
|
||||
# chain the dependencies so that the packages are installed sequentially by cmake
|
||||
if(_prev_package)
|
||||
add_dependencies(${_cur_package} ${_prev_package})
|
||||
endif()
|
||||
set(_prev_package ${_cur_package})
|
||||
endforeach()
|
||||
|
||||
set(triton_extra_cmake_args -DVCPKG_TARGET_TRIPLET=${vcpkg_triplet}
|
||||
-DCMAKE_TOOLCHAIN_FILE=${VCPKG_SRC}/scripts/buildsystems/vcpkg.cmake)
|
||||
|
|
|
@ -21,6 +21,17 @@
|
|||
// #endif
|
||||
#include "onnxruntime_c_api.h"
|
||||
|
||||
// ORT_FILE is defined in the ORT C API from 1.15 on. Provide simplified definition for older versions.
|
||||
// On Windows, ORT_FILE is a wchar_t version of the __FILE__ macro.
|
||||
// Otherwise, ORT_FILE is equivalent to __FILE__.
|
||||
#ifndef ORT_FILE
|
||||
#ifdef _WIN32
|
||||
#define ORT_FILE __FILEW__
|
||||
#else
|
||||
#define ORT_FILE __FILE__
|
||||
#endif
|
||||
#endif
|
||||
|
||||
namespace OrtW {
|
||||
|
||||
// All C++ methods that can fail will throw an exception of this type
|
||||
|
|
|
@ -5,6 +5,9 @@
|
|||
import onnx
|
||||
from onnx import helper, TensorProto
|
||||
|
||||
# ORT 1.14 only supports IR version 8 so if we're unit testing with the oldest version of ORT that can be used
|
||||
# with the Azure ops we need to use this version instead of onnx.IR_VERSION
|
||||
MODEL_IR_VERSION = 8
|
||||
|
||||
def create_audio_model():
|
||||
auth_token = helper.make_tensor_value_info('auth_token', TensorProto.STRING, [1])
|
||||
|
@ -24,7 +27,7 @@ def create_audio_model():
|
|||
verbose=False)
|
||||
|
||||
graph = helper.make_graph([invoker], 'graph', [auth_token, model, response_format, file], [transcriptions])
|
||||
model = helper.make_model(graph,
|
||||
model = helper.make_model(graph, ir_version=MODEL_IR_VERSION,
|
||||
opset_imports=[helper.make_operatorsetid('com.microsoft.extensions', 1)])
|
||||
|
||||
onnx.save(model, 'openai_audio.onnx')
|
||||
|
@ -42,7 +45,7 @@ def create_chat_model():
|
|||
verbose=False)
|
||||
|
||||
graph = helper.make_graph([invoker], 'graph', [auth_token, chat], [response])
|
||||
model = helper.make_model(graph,
|
||||
model = helper.make_model(graph, ir_version=MODEL_IR_VERSION,
|
||||
opset_imports=[helper.make_operatorsetid('com.microsoft.extensions', 1)])
|
||||
|
||||
onnx.save(model, 'openai_chat.onnx')
|
||||
|
|
|
@ -8,6 +8,10 @@ import onnx
|
|||
import numpy as np
|
||||
import sys
|
||||
|
||||
# ORT 1.14 only supports IR version 8 so if we're unit testing with the oldest version of ORT that can be used
|
||||
# with the Azure ops we need to use this version instead of onnx.IR_VERSION
|
||||
MODEL_IR_VERSION = 8
|
||||
|
||||
|
||||
def order_repeated_field(repeated_proto, key_name, order):
|
||||
order = list(order)
|
||||
|
@ -33,6 +37,7 @@ def make_graph(*args, doc_string=None, **kwargs):
|
|||
# The filename can be specified to indicate a different audio type to the default value in the audio_format attribute.
|
||||
model = helper.make_model(
|
||||
opset_imports=[helper.make_operatorsetid('com.microsoft.extensions', 1)],
|
||||
ir_version=MODEL_IR_VERSION,
|
||||
graph=make_graph(
|
||||
name='OpenAIWhisperTranscribe',
|
||||
initializer=[
|
||||
|
|
Двоичные данные
test/data/azure/openai_audio.onnx
Двоичные данные
test/data/azure/openai_audio.onnx
Двоичный файл не отображается.
Двоичные данные
test/data/azure/openai_chat.onnx
Двоичные данные
test/data/azure/openai_chat.onnx
Двоичный файл не отображается.
Двоичные данные
test/data/azure/openai_whisper_transcriptions.onnx
Двоичные данные
test/data/azure/openai_whisper_transcriptions.onnx
Двоичный файл не отображается.
|
@ -320,7 +320,7 @@ def _generate_build_tree(cmake_path: Path,
|
|||
]
|
||||
|
||||
if args.onnxruntime_version:
|
||||
cmake_args.append(f"-DONNXRUNTIME_VER={args.onnxruntime_version}")
|
||||
cmake_args.append(f"-DOCOS_ONNXRUNTIME_VERSION={args.onnxruntime_version}")
|
||||
|
||||
if args.enable_cxx_tests:
|
||||
cmake_args.append("-DOCOS_ENABLE_CTEST=ON")
|
||||
|
|
Загрузка…
Ссылка в новой задаче