Skip to content

Commit 1c535cb

Browse files
committed
fix merged conflicts
2 parents c406f42 + bef5f07 commit 1c535cb

19 files changed

+272
-32
lines changed

.pipelines/ci.yml

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,12 @@ stages:
121121
inputs:
122122
versionSpec: '3.x'
123123
disableDownloadFromRegistry: true
124-
addToPath: false
124+
addToPath: true
125125
architecture: 'x64'
126126

127127
- script: |
128128
python -m pip install --upgrade setuptools pip
129-
python -m pip install numpy
129+
python -m pip install 'numpy < 2.0.0'
130130
export OCOS_NO_OPENCV=1
131131
export OCOS_SCB_DEBUG=1
132132
CPU_NUMBER=8 python -m pip install -e .
@@ -322,6 +322,7 @@ stages:
322322
python -m pip install --upgrade pip
323323
python -m pip install --upgrade setuptools
324324
python -m pip install --upgrade wheel
325+
python -m pip install 'numpy < 2.0.0'
325326
python -m pip install onnxruntime==$(ort.version)
326327
displayName: Install requirements
327328
@@ -507,13 +508,13 @@ stages:
507508
inputs:
508509
versionSpec: '3.x'
509510
disableDownloadFromRegistry: true
510-
addToPath: false
511+
addToPath: true
511512
architecture: 'x64'
512513
displayName: Use ADO python task
513514

514515
- script: |
515516
python -m pip install --upgrade setuptools pip
516-
python -m pip install numpy
517+
python -m pip install "numpy < 2.0.0"
517518
set OCOS_NO_OPENCV=1
518519
set OCOS_SCB_DEBUG=1
519520
python -m pip install -v -e .
@@ -570,7 +571,9 @@ stages:
570571

571572
- script: |
572573
set CUDA_PATH=$(Agent.TempDirectory)\v11.8
573-
call .\build.bat -T cuda="%CUDA_PATH%" -DOCOS_ENABLE_CTEST=ON -DOCOS_USE_CUDA=ON -DCMAKE_CUDA_ARCHITECTURES=70;86^
574+
call .\build.bat -T cuda="%CUDA_PATH%" -DOCOS_ENABLE_CTEST=ON^
575+
-DCMAKE_CUDA_FLAGS_INIT=-allow-unsupported-compiler^
576+
-DOCOS_USE_CUDA=ON -DCMAKE_CUDA_ARCHITECTURES=70;86^
574577
-DOCOS_ONNXRUNTIME_VERSION="$(ORT_VERSION)" -DONNXRUNTIME_PKG_DIR=.\onnxruntime-win-x64-gpu-$(ORT_VERSION)
575578
displayName: build the customop library with onnxruntime
576579
@@ -583,14 +586,14 @@ stages:
583586
inputs:
584587
versionSpec: '3.x'
585588
disableDownloadFromRegistry: true
586-
addToPath: false
589+
addToPath: true
587590
architecture: 'x64'
588591
displayName: Use ADO python task
589592

590593
- script: |
591594
set CUDA_PATH=$(Agent.TempDirectory)\v11.8
592595
python -m pip install --upgrade setuptools pip
593-
python -m pip install numpy coloredlogs flatbuffers packaging protobuf sympy
596+
python -m pip install "numpy < 2.0.0" coloredlogs flatbuffers packaging protobuf sympy
594597
python -m pip install onnxruntime-gpu==$(ORT_VERSION)
595598
python -m pip install -v --config-settings "ortx-user-option=use-cuda,cuda_archs=70;86" .
596599
displayName: Build and install onnxruntime-extensions CUDA package.

.pipelines/ci_optional.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ stages:
132132
inputs:
133133
versionSpec: '3.x'
134134
disableDownloadFromRegistry: true
135-
addToPath: false
135+
addToPath: true
136136
architecture: 'x64'
137137
displayName: Use ADO python task
138138

@@ -172,7 +172,7 @@ stages:
172172
inputs:
173173
versionSpec: '3.x'
174174
disableDownloadFromRegistry: true
175-
addToPath: false
175+
addToPath: true
176176
architecture: 'x64'
177177
displayName: Use ADO python task
178178

.pipelines/wheels_linux.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ parameters:
22
- name: ExtraEnv
33
displayName: 'Extra env variable set to CIBW_ENVIRONMENT, in form of "A=1 B=2 C=3"'
44
type: string
5-
default: 'OCOS_ENABLE_AZURE=1'
5+
default: 'OCOS_ENABLE_AZURE=0'
66

77
jobs:
88
- job: linux_x86_64

.pyproject/cmdclass.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,8 @@ def build_cmake(self, extension):
226226
if sys.platform == "win32":
227227
cuda_path = os.environ.get("CUDA_PATH")
228228
cmake_args += [f'-T cuda={cuda_path}']
229+
# TODO: temporarily add a flag for MSVC 19.40
230+
cmake_args += ['-DCMAKE_CUDA_FLAGS_INIT=-allow-unsupported-compiler']
229231
f_ver = ext_fullpath.parent / "_version.py"
230232
with f_ver.open('a') as _f:
231233
_f.writelines(["\n", f"cuda = \"{cuda_ver}\"", "\n"])
@@ -235,7 +237,8 @@ def build_cmake(self, extension):
235237
else:
236238
smi = _load_nvidia_smi()
237239
if not smi:
238-
raise RuntimeError(f"Cannot detect the CUDA archs from your machine, please specify it by yourself.")
240+
raise RuntimeError(
241+
"Cannot detect the CUDA archs from your machine, please specify it manually.")
239242
cmake_args += ['-DCMAKE_CUDA_ARCHITECTURES=' + smi]
240243

241244
# CMake lets you override the generator - we need to check this.
@@ -274,7 +277,6 @@ def build_cmake(self, extension):
274277
cmake_args += [
275278
"-DCMAKE_OSX_ARCHITECTURES={}".format(";".join(archs))]
276279

277-
278280
# overwrite the Python module info if the auto-detection doesn't work.
279281
# export Python3_INCLUDE_DIRS=/opt/python/cp38-cp38
280282
# export Python3_LIBRARIES=/opt/python/cp38-cp38
@@ -292,14 +294,18 @@ def build_cmake(self, extension):
292294
'--parallel' + ('' if cpu_number is None else ' ' + cpu_number)
293295
]
294296
cmake_exe = 'cmake'
295-
# unlike Linux/macOS, cmake pip package on Windows fails to build some 3rd party dependencies.
296-
# so we have to use the cmake installed from Visual Studio.
297-
if os.environ.get(VSINSTALLDIR_NAME):
298-
cmake_exe = os.environ[VSINSTALLDIR_NAME] + \
299-
'Common7\\IDE\\CommonExtensions\\Microsoft\\CMake\\CMake\\bin\\cmake.exe'
300-
# Add this cmake directory into PATH to make sure the child-process still find it.
301-
os.environ['PATH'] = os.path.dirname(
302-
cmake_exe) + os.pathsep + os.environ['PATH']
297+
# if sys.platform == "win32":
298+
# # unlike Linux/macOS, cmake pip package on Windows fails to build some 3rd party dependencies.
299+
# # so we have to use the cmake from a standalone installation or the one from Visual Studio.
300+
# standalone_cmake = os.path.join(os.environ.get("ProgramFiles"), "\\CMake\\bin\\cmake.exe")
301+
# if os.path.exists(standalone_cmake):
302+
# cmake_exe = standalone_cmake
303+
# elif os.environ.get(VSINSTALLDIR_NAME):
304+
# cmake_exe = os.environ[VSINSTALLDIR_NAME] + \
305+
# 'Common7\\IDE\\CommonExtensions\\Microsoft\\CMake\\CMake\\bin\\cmake.exe'
306+
# # Add this cmake directory into PATH to make sure the child-process still find it.
307+
# os.environ['PATH'] = os.path.dirname(
308+
# cmake_exe) + os.pathsep + os.environ['PATH']
303309

304310
self.spawn([cmake_exe, '-S', str(project_dir),
305311
'-B', str(build_temp)] + cmake_args)

CMakeLists.txt

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.24.0")
3636
cmake_policy(SET CMP0077 NEW)
3737
endif()
3838

39+
# Avoid warning of Calling FetchContent_Populate(GSL) is deprecated
40+
if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.30.0")
41+
cmake_policy(CMP0169 OLD)
42+
endif()
43+
3944
# Needed for Java
4045
set(CMAKE_C_STANDARD 99)
4146

@@ -90,12 +95,11 @@ set(OCOS_ONNXRUNTIME_PKG_URI "" CACHE STRING
9095
"Specify the onnxruntime C++ shared library zip package path, like ./onnxruntime-win-x64-1.16.0.zip")
9196
set(OCOS_BUILD_PRESET "" CACHE STRING
9297
"Specify the build preset cmake settings file path, like 'token_api_only' which includes ./cmake/presets/token_api_only.cmake")
93-
# TODO: Remove the following statements if AzureOp build is enabled by default.
94-
# If build_buildid environment varaible is set, which means this is a CI build, then always enable AzureOp.
95-
# or it is enabled when OCOS_ENABLE_AZURE is set, which means the user explicitly enables it.
96-
if ((DEFINED ENV{BUILD_BUILDID}) OR (DEFINED ENV{OCOS_ENABLE_AZURE}))
98+
99+
# AzureOp can be enabled by environment varaible OCOS_ENABLE_AZURE == 1
100+
if (DEFINED ENV{OCOS_ENABLE_AZURE})
97101
set(OCOS_ENABLE_AZURE ON CACHE INTERNAL "" FORCE)
98-
message(STATUS "=> AzureOp is enabled by default.")
102+
message(STATUS "=> AzureOp is enabled env variable.")
99103
endif()
100104

101105
function(disable_all_operators)

build.bat

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,21 @@
11
@ECHO OFF
22
SETLOCAL ENABLEDELAYEDEXPANSION
3+
4+
IF NOT EXIST "%ProgramFiles%\CMake\bin\cmake.exe" GOTO :FIND_VS
5+
set cmake_exe="%ProgramFiles%\CMake\bin\cmake.exe"
6+
7+
:FIND_VS
38
IF DEFINED VSINSTALLDIR GOTO :VSDEV_CMD
49
set _VSFINDER=%~dp0tools\get_vsdevcmd.ps1
510
for /f "tokens=* USEBACKQ" %%i in (
611
`powershell -NoProfile -ExecutionPolicy Bypass -File "%_VSFINDER%"`) do call "%%i"
712

813
IF NOT DEFINED VSINSTALLDIR GOTO :NOT_FOUND
914

15+
IF DEFINED cmake_exe GOTO :CMAKE_DEF
16+
set cmake_exe="%VSINSTALLDIR%Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe"
17+
18+
:CMAKE_DEF
1019
IF "%1" == "-A" GOTO :VSDEV_CMD
1120
set GEN_PLATFORM=-A x64
1221

@@ -16,8 +25,8 @@ IF "%VisualStudioVersion:~0,2%" == "16" GOTO :START_BUILD
1625
set GENERATOR="Visual Studio 17 2022"
1726

1827
:START_BUILD
19-
set cmake_exe="%VSINSTALLDIR%Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe"
2028
mkdir .\out\Windows\ 2>NUL
29+
ECHO %cmake_exe% -G %GENERATOR% %GEN_PLATFORM% %* -B out\Windows -S .
2130
%cmake_exe% -G %GENERATOR% %GEN_PLATFORM% %* -B out\Windows -S .
2231
IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%
2332
%cmake_exe% --build out\Windows --config RelWithDebInfo

cmake/externals/opencv-no-rtti.patch

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,19 @@ index d95e5db163..db185453df 100644
3939
include(cmake/OpenCVCompilerOptions.cmake)
4040

4141
ocv_cmake_hook(POST_COMPILER_OPTIONS)
42+
diff --git a/cmake/OpenCVDetectCXXCompiler.cmake b/cmake/OpenCVDetectCXXCompiler.cmake
43+
index 7f229cde96..92e204a5b9 100644
44+
--- a/cmake/OpenCVDetectCXXCompiler.cmake
45+
+++ b/cmake/OpenCVDetectCXXCompiler.cmake
46+
@@ -171,7 +171,7 @@ elseif(MSVC)
47+
set(OpenCV_RUNTIME vc15)
48+
elseif(MSVC_VERSION MATCHES "^192[0-9]$")
49+
set(OpenCV_RUNTIME vc16)
50+
- elseif(MSVC_VERSION MATCHES "^193[0-9]$")
51+
+ elseif(MSVC_VERSION MATCHES "^19[34][0-9]$")
52+
set(OpenCV_RUNTIME vc17)
53+
else()
54+
message(WARNING "OpenCV does not recognize MSVC_VERSION \"${MSVC_VERSION}\". Cannot set OpenCV_RUNTIME")
4255
diff --git a/modules/core/include/opencv2/core/ocl.hpp b/modules/core/include/opencv2/core/ocl.hpp
4356
index 4503fa00dd..642b0508d0 100644
4457
--- a/modules/core/include/opencv2/core/ocl.hpp

docs/custom_ops.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1312,7 +1312,7 @@ expect(node, inputs=[text, pattern, rewrite], outputs=[y],
13121312
13131313
13141314
## Azure operators
1315-
1315+
Starting from onnxruntime-extensions 0.12, these Azure operators will be removed from the official onnxruntime-extensions packages. However, they can still be built from source using `cmake -DOCOS_ENABLE_AZURE=ON ...`.
13161316
### OpenAIAudioToText
13171317
13181318
<details>

operators/cuda/cuda_ops.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88
#include "cuda/fast_gelu.h"
99
#include "cuda/mul_sigmoid.h"
1010
#include "cuda/negxplus1.h"
11+
#include "cuda/replace_zero.h"
1112
#include "cuda/rotary.h"
1213
#include "cuda/scatter_nd_of_shape.h"
1314
#include "cuda/transpose_cast.h"
1415
#endif
1516

1617
FxLoadCustomOpFactory LoadCustomOpClasses_Contrib = []() -> CustomOpArray& {
17-
1818
using AddSharedInputFloat32Type = typename contrib::AddOrMulSharedInput<float, true>;
1919
using MulSharedInputFloat32Type = typename contrib::AddOrMulSharedInput<float, false>;
2020

@@ -25,7 +25,6 @@ FxLoadCustomOpFactory LoadCustomOpClasses_Contrib = []() -> CustomOpArray& {
2525
using Transpose2DCastFloat16ToFloat32Type = typename contrib::Transpose2DCast<ortc::MFloat16, float>;
2626
#endif
2727

28-
2928
static OrtOpLoader op_loader(
3029
[]() { return nullptr; }
3130
#ifdef USE_CUDA
@@ -37,6 +36,7 @@ FxLoadCustomOpFactory LoadCustomOpClasses_Contrib = []() -> CustomOpArray& {
3736
CustomCudaStructV2("MulMulSigmoid", contrib::MulMulSigmoid<float>),
3837
CustomCudaStructV2("MulSigmoid", contrib::MulSigmoid<float>),
3938
CustomCudaStructV2("NegXPlus1", contrib::NegXPlus1<float>),
39+
CustomCudaStructV2("ReplaceZero", contrib::ReplaceZero<float>),
4040
CustomCudaStructV2("Rotary", contrib::Rotary<float>),
4141
CustomCudaStructV2("ScatterNDOfShape", contrib::ScatterNDOfShape<float>),
4242
#if ORT_API_VERSION >= 16
@@ -49,6 +49,7 @@ FxLoadCustomOpFactory LoadCustomOpClasses_Contrib = []() -> CustomOpArray& {
4949
CustomCudaStructV2("MulMulSigmoid", contrib::MulMulSigmoid<ortc::MFloat16>),
5050
CustomCudaStructV2("MulSigmoid", contrib::MulSigmoid<ortc::MFloat16>),
5151
CustomCudaStructV2("NegXPlus1", contrib::NegXPlus1<ortc::MFloat16>),
52+
CustomCudaStructV2("ReplaceZero", contrib::ReplaceZero<ortc::MFloat16>),
5253
CustomCudaStructV2("Rotary", contrib::Rotary<ortc::MFloat16>),
5354
CustomCudaStructV2("ScatterNDOfShape", contrib::ScatterNDOfShape<ortc::MFloat16>),
5455
CustomCudaStructV2("Transpose2DCastFP16", Transpose2DCastFloat32ToFloat16Type),

operators/cuda/negxplus1.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88

99
namespace contrib {
1010

11+
/**
12+
* NegXPlus1(X) = 1 - X
13+
*/
1114
template <typename T>
1215
struct NegXPlus1 {
1316
template <typename TDict>

0 commit comments

Comments
 (0)