Skip to content

Commit ff2c70e

Browse files
authored
Add MatX, update ORT version, pybind11 version (#189)
* Add MatX * matx * better * skip whatever does not work * use 1.19.2 * e * improve error message * listdir * fix cmake * fix windows build
1 parent 5004ce6 commit ff2c70e

20 files changed

+314
-29
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,4 @@ onnx_extended/validation/cython/*.c
5959
onnx_extended/validation/cython/*.cpp
6060
onnx_extended/validation/cython/vector_function_cy.c*
6161
onnx_extended/ortcy/wrap/ortinf.c*
62+
onnx_extended/ortcy/wrap/*.lib

CHANGELOGS.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Change Logs
44
0.3.0
55
+++++
66

7-
* :pr:`186`: support numpy 2.0
7+
* :pr:`189`: use onnxruntime==1.19.2 as default, pybind11 2.13.5, MatX 0.8.0
88
* :pr:`187`: Fix compilation with GCC>=13 #187
99
* :pr:`185`: adds custom operator MulMulSigmoid on CUDA
1010
* :pr:`184`: use onnxruntime==1.18.0 as default

_cmake/CMakeLists.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,16 @@ message(STATUS "--------------------------------------------")
3737

3838
include("targets/common.cmake")
3939

40+
#
41+
# display all variables
42+
#
43+
44+
get_cmake_property(_variableNames VARIABLES)
45+
list (SORT _variableNames)
46+
foreach (_variableName ${_variableNames})
47+
message(STATUS "---- ${_variableName}=${${_variableName}}")
48+
endforeach()
49+
4050
#
4151
# standalone modules
4252
#

_cmake/externals/FindLocalMatX.cmake

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#
2+
# initialization
3+
#
4+
# defines matx matx_SOURCE_DIR matx_BINARY_DIR
5+
6+
#
7+
# matx
8+
#
9+
10+
set(matx_TAG "v0.8.0")
11+
12+
include(FetchContent)
13+
FetchContent_Declare(
14+
matx
15+
GIT_REPOSITORY https://github.com/NVIDIA/matx
16+
GIT_TAG ${matx_TAG})
17+
18+
FetchContent_MakeAvailable(matx)
19+
FetchContent_GetProperties(matx)
20+
21+
set(matx_VERSION ${matx_TAG})
22+
set(MATX_INCLUDE_DIR "${matx_SOURCE_DIR}/include")
23+
message(STATUS "matx_BINARY_DIR=${matx_BINARY_DIR}")
24+
message(STATUS "matx_SOURCE_DIR=${matx_SOURCE_DIR}")
25+
message(STATUS "MATX_INCLUDE_DIR=${MATX_INCLUDE_DIR}")
26+
message(STATUS "matx_VERSION=${matx_VERSION}")
27+
28+
include(FindPackageHandleStandardArgs)
29+
find_package_handle_standard_args(
30+
LocalMatX
31+
VERSION_VAR matx_VERSION
32+
REQUIRED_VARS matx_SOURCE_DIR matx_BINARY_DIR)

_cmake/externals/FindLocalPyBind11.cmake

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
# pybind11
99
#
1010

11-
set(pybind11_TAG "v2.10.4")
11+
set(pybind11_TAG "v2.13.5")
1212

1313
include(FetchContent)
1414
FetchContent_Declare(
@@ -19,6 +19,8 @@ FetchContent_Declare(
1919
FetchContent_GetProperties(pybind11)
2020
if(NOT pybind11_POPULATED)
2121
FetchContent_Populate(pybind11)
22+
message(STATUS "pybind11_SOURCE_DIR=${pybind11_SOURCE_DIR}")
23+
message(STATUS "pybind11_BINARY_DIR=${pybind11_BINARY_DIR}")
2224
add_subdirectory(${pybind11_SOURCE_DIR} ${pybind11_BINARY_DIR})
2325
else()
2426
message(FATAL_ERROR "Pybind11 was not found.")

_cmake/externals/FindOrt.cmake

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,16 @@ if(MSVC)
113113
"with extension 'pdb'.")
114114
endif()
115115
list(APPEND ORT_LIB_FILES ${ORT_LIB_FILES_PDB})
116+
117+
file(GLOB ORT_LIB_FILES_LIB ${ONNXRUNTIME_LIB_DIR}/*.lib)
118+
list(LENGTH ORT_LIB_FILES_LIB ORT_LIB_FILES_LIB_LENGTH)
119+
if (ORT_LIB_FILES_LIB_LENGTH LESS_EQUAL 1)
120+
message(FATAL_ERROR "No pdb file found in '${ONNXRUNTIME_LIB_DIR}' "
121+
"from path or url '${ORT_URL}', "
122+
"found files [${ORT_LIB_FILES}] "
123+
"with extension 'lib'.")
124+
endif()
125+
list(APPEND ORT_LIB_FILES ${ORT_LIB_FILES_LIB})
116126
endif()
117127

118128
#
@@ -133,19 +143,19 @@ function(ort_add_dependency name folder_copy)
133143
foreach(file_i ${ORT_LIB_FILES})
134144
message(STATUS "ort: copy ${file_i} to '${destination_dir}'")
135145
add_custom_command(
136-
TARGET ${name} POST_BUILD
146+
TARGET ${name} PRE_BUILD
137147
COMMAND ${CMAKE_COMMAND} ARGS -E copy ${file_i} ${destination_dir})
138148
if(folder_copy)
139149
message(STATUS "ort: copy '${file_i}' to '${ROOT_PROJECT_PATH}/${folder_copy}'")
140150
add_custom_command(
141-
TARGET ${name} POST_BUILD
151+
TARGET ${name} PRE_BUILD
142152
COMMAND ${CMAKE_COMMAND} ARGS -E copy "${file_i}" "${ROOT_PROJECT_PATH}/${folder_copy}")
143153
message(STATUS "ort: copy '${file_i}' to '${SETUP_BUILD_LIB}/${folder_copy}'")
144154
add_custom_command(
145-
TARGET ${name} POST_BUILD
155+
TARGET ${name} PRE_BUILD
146156
COMMAND ${CMAKE_COMMAND} ARGS -E make_directory "${SETUP_BUILD_LIB}/${folder_copy}")
147157
add_custom_command(
148-
TARGET ${name} POST_BUILD
158+
TARGET ${name} PRE_BUILD
149159
COMMAND ${CMAKE_COMMAND} ARGS -E copy "${file_i}" "${SETUP_BUILD_LIB}/${folder_copy}")
150160
endif()
151161
endforeach()

_cmake/load_externals.cmake

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,4 +156,14 @@ else()
156156
message(FATAL_ERROR "Module eigen is not installed.")
157157
endif()
158158

159+
if(USE_CUDA)
160+
message(STATUS "-------------------")
161+
find_package(LocalMatX REQUIRED)
162+
if(LocalMatX_FOUND)
163+
message(STATUS "Found MatX ${LocalMatX_VERSION}")
164+
else()
165+
message(FATAL_ERROR "Module MatX is not installed.")
166+
endif()
167+
endif()
168+
159169
message(STATUS "-------------------")

_cmake/targets/ortinf.cmake

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,30 @@ target_include_directories(
1111
${ROOT_INCLUDE_PATH})
1212
target_link_libraries(lib_ortapi PRIVATE common)
1313

14+
set(ORTAPI_INCLUDE_DIR "${ROOT_PROJECT_PATH}/onnx_extended/ortcy/wrap")
15+
1416
cython_add_module(
1517
ortinf
1618
../onnx_extended/ortcy/wrap/ortinf.pyx
1719
OpenMP::OpenMP_CXX)
18-
target_link_directories(ortinf PRIVATE ${ONNXRUNTIME_LIB_DIR})
19-
message(STATUS " LINK ortinf <- lib_ortapi onnxruntime")
20+
21+
message(STATUS " LINK ortinf <- lib_ortapi onnxruntime ${ORTAPI_INCLUDE_DIR}")
22+
23+
ort_add_dependency(
24+
ortinf
25+
onnx_extended/ortcy/wrap)
26+
27+
# If ONNXRUNTIME_LIB_DIR is used, then it seems a local installation does
28+
# does not the binaries anymore if they are removed.
29+
target_link_directories(ortinf PRIVATE ${ORTAPI_INCLUDE_DIR})
30+
2031
target_link_libraries(
2132
ortinf
2233
PRIVATE
2334
lib_ortapi
2435
onnxruntime
2536
common_kernels)
2637
target_include_directories(ortinf PRIVATE ${ROOT_INCLUDE_PATH})
27-
ort_add_dependency(
28-
ortinf
29-
onnx_extended/ortcy/wrap)
30-
31-
set(ORTAPI_INCLUDE_DIR "${ROOT_INCLUDE_PATH}/onnx_extended/ortcy/wrap")
3238

3339
add_executable(test_ortcy_inference_cpp ../_unittests/ut_ortcy/test_inference.cpp)
3440
target_compile_definitions(test_ortcy_inference_cpp PRIVATE PYTHON_MANYLINUX=${PYTHON_MANYLINUX})

_cmake/targets/ortops_tutorial_cuda.cmake

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# module: onnx_extended.reference.c_ops.cpu.c_op_conv_
2+
# custom ops: onnx_extended.ortops.tutorial.cuda
33
#
44

55
if(CUDA_AVAILABLE)
@@ -12,6 +12,7 @@ if(CUDA_AVAILABLE)
1212
onnx_extended/ortops/tutorial/cuda
1313
../onnx_extended/cpp/onnx_extended_helpers.cpp
1414
../onnx_extended/ortops/tutorial/cuda/custom_gemm.cu
15+
../onnx_extended/ortops/tutorial/cuda/matx_matmul.cu
1516
../onnx_extended/ortops/tutorial/cuda/ort_tutorial_cuda_lib.cc)
1617

1718
# needed to include onnx_extended_helpers.h
@@ -20,6 +21,9 @@ if(CUDA_AVAILABLE)
2021
PRIVATE
2122
"${ROOT_INCLUDE_PATH}"
2223
"${ORTAPI_INCLUDE_DIR}"
23-
"${ORTOPS_INCLUDE_DIR}")
24+
"${ORTOPS_INCLUDE_DIR}"
25+
"${matx_INCLUDE_DIR}")
26+
27+
target_link_libraries(ortops_tutorial_cuda PRIVATE matx::matx)
2428

2529
endif()

_doc/tutorial/old_version.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ It calls function :func:`bench_virtual <onnx_extended.tools.run_onnx.bench_virtu
112112
113113
runtimes = ["onnxruntime"]
114114
modules = [
115+
{"onnx-extended": "0.3.0", "onnx": "1.15.0", "onnxruntime": "1.19.2"},
115116
{"onnx-extended": "0.3.0", "onnx": "1.15.0", "onnxruntime": "1.18.0"},
116117
{"onnx-extended": "0.2.3", "onnx": "1.15.0", "onnxruntime": "1.17.3"},
117118
{"onnx-extended": "0.2.3", "onnx": "1.15.0", "onnxruntime": "1.16.3"},

0 commit comments

Comments
 (0)