Skip to content

Commit 0f3ea0e

Browse files
authored
Merge branch 'microsoft:main' into ovep-develop-lnl-1.1
2 parents 1c2ede8 + 2183014 commit 0f3ea0e

36 files changed

+1717
-502
lines changed

cmake/CMakeLists.txt

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,7 @@ if(NOT WIN32 AND NOT CMAKE_SYSTEM_NAME STREQUAL "Android")
551551
endif()
552552

553553
find_package(Patch)
554-
if (WIN32 AND NOT Patch_FOUND)
554+
if (CMAKE_HOST_WIN32 AND NOT Patch_FOUND)
555555
# work around CI machines missing patch from the git install by falling back to the binary in this repo.
556556
# replicate what happens in https://github.com/Kitware/CMake/blob/master/Modules/FindPatch.cmake but without
557557
# the hardcoded suffixes in the path to the patch binary.
@@ -1140,6 +1140,13 @@ endfunction()
11401140
function(onnxruntime_add_shared_library target_name)
11411141
add_library(${target_name} SHARED ${ARGN})
11421142
onnxruntime_configure_target(${target_name})
1143+
if(WIN32)
1144+
target_compile_definitions(${target_name} PRIVATE VER_MAJOR=${VERSION_MAJOR_PART})
1145+
target_compile_definitions(${target_name} PRIVATE VER_MINOR=${VERSION_MINOR_PART})
1146+
target_compile_definitions(${target_name} PRIVATE VER_BUILD=${VERSION_BUILD_PART})
1147+
target_compile_definitions(${target_name} PRIVATE VER_PRIVATE=${VERSION_PRIVATE_PART})
1148+
target_compile_definitions(${target_name} PRIVATE VER_STRING=\"${VERSION_STRING}\")
1149+
endif()
11431150
endfunction()
11441151

11451152
function(onnxruntime_add_static_library target_name)
@@ -1154,6 +1161,13 @@ function(onnxruntime_add_shared_library_module target_name)
11541161
else()
11551162
#On Windows, this target shouldn't generate an import lib, but I don't know how to disable it.
11561163
add_library(${target_name} MODULE ${ARGN})
1164+
if(WIN32)
1165+
target_compile_definitions(${target_name} PRIVATE VER_MAJOR=${VERSION_MAJOR_PART})
1166+
target_compile_definitions(${target_name} PRIVATE VER_MINOR=${VERSION_MINOR_PART})
1167+
target_compile_definitions(${target_name} PRIVATE VER_BUILD=${VERSION_BUILD_PART})
1168+
target_compile_definitions(${target_name} PRIVATE VER_PRIVATE=${VERSION_PRIVATE_PART})
1169+
target_compile_definitions(${target_name} PRIVATE VER_STRING=\"${VERSION_STRING}\")
1170+
endif()
11571171
endif()
11581172

11591173
onnxruntime_configure_target(${target_name})
@@ -1636,6 +1650,14 @@ set(VERSION_MINOR_PART 0 CACHE STRING "Second part of numeric file/product ver
16361650
set(VERSION_BUILD_PART 0 CACHE STRING "Third part of numeric file/product version.")
16371651
set(VERSION_PRIVATE_PART 0 CACHE STRING "Fourth part of numeric file/product version.")
16381652
set(VERSION_STRING "Internal Build" CACHE STRING "String representation of file/product version.")
1653+
if(VERSION_MAJOR_PART STREQUAL "0" AND VERSION_MINOR_PART STREQUAL "0" AND VERSION_BUILD_PART STREQUAL "0" AND VERSION_PRIVATE_PART STREQUAL "0")
1654+
string(REPLACE "." ";" ORT_VERSION_STRING_LIST ${ORT_VERSION})
1655+
list(GET ORT_VERSION_STRING_LIST 0 VERSION_MAJOR_PART)
1656+
list(GET ORT_VERSION_STRING_LIST 1 VERSION_MINOR_PART)
1657+
list(GET ORT_VERSION_STRING_LIST 2 VERSION_BUILD_PART)
1658+
set(VERSION_STRING ORT_VERSION)
1659+
endif()
1660+
16391661

16401662
if (WIN32)
16411663
list(APPEND onnxruntime_EXTERNAL_LIBRARIES ${SYS_PATH_LIB})

cmake/onnxruntime.cmake

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ elseif(onnxruntime_BUILD_APPLE_FRAMEWORK)
9595
FRAMEWORK TRUE
9696
FRAMEWORK_VERSION A
9797
MACOSX_FRAMEWORK_INFO_PLIST ${INFO_PLIST_PATH}
98-
SOVERSION ${ORT_VERSION}
9998
# Note: The PUBLIC_HEADER and VERSION properties for the 'onnxruntime' target will be set later in this file.
10099
)
101100
else()
@@ -108,11 +107,7 @@ endif()
108107
add_dependencies(onnxruntime onnxruntime_generate_def ${onnxruntime_EXTERNAL_DEPENDENCIES})
109108
target_include_directories(onnxruntime PRIVATE ${ONNXRUNTIME_ROOT} PUBLIC "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/onnxruntime>")
110109

111-
target_compile_definitions(onnxruntime PRIVATE VER_MAJOR=${VERSION_MAJOR_PART})
112-
target_compile_definitions(onnxruntime PRIVATE VER_MINOR=${VERSION_MINOR_PART})
113-
target_compile_definitions(onnxruntime PRIVATE VER_BUILD=${VERSION_BUILD_PART})
114-
target_compile_definitions(onnxruntime PRIVATE VER_PRIVATE=${VERSION_PRIVATE_PART})
115-
target_compile_definitions(onnxruntime PRIVATE VER_STRING=\"${VERSION_STRING}\")
110+
116111
target_compile_definitions(onnxruntime PRIVATE FILE_NAME=\"onnxruntime.dll\")
117112

118113
if(UNIX)
@@ -130,7 +125,6 @@ if (NOT WIN32)
130125
set(ONNXRUNTIME_SO_LINK_FLAG " -Wl,-exported_symbols_list,${SYMBOL_FILE}")
131126
if (${CMAKE_SYSTEM_NAME} STREQUAL "iOS")
132127
set_target_properties(onnxruntime PROPERTIES
133-
SOVERSION ${ORT_VERSION}
134128
MACOSX_RPATH TRUE
135129
INSTALL_RPATH_USE_LINK_PATH FALSE
136130
BUILD_WITH_INSTALL_NAME_DIR TRUE
@@ -222,13 +216,23 @@ target_link_libraries(onnxruntime PRIVATE
222216
)
223217

224218
set_property(TARGET onnxruntime APPEND_STRING PROPERTY LINK_FLAGS ${ONNXRUNTIME_SO_LINK_FLAG} ${onnxruntime_DELAYLOAD_FLAGS})
225-
set_target_properties(onnxruntime PROPERTIES
226-
PUBLIC_HEADER "${ONNXRUNTIME_PUBLIC_HEADERS}"
227-
LINK_DEPENDS ${SYMBOL_FILE}
228-
VERSION ${ORT_VERSION}
229-
FOLDER "ONNXRuntime"
230-
)
231219

220+
#See: https://cmake.org/cmake/help/latest/prop_tgt/SOVERSION.html
221+
if(NOT APPLE AND NOT WIN32)
222+
set_target_properties(onnxruntime PROPERTIES
223+
PUBLIC_HEADER "${ONNXRUNTIME_PUBLIC_HEADERS}"
224+
LINK_DEPENDS ${SYMBOL_FILE}
225+
VERSION ${ORT_VERSION}
226+
SOVERSION 1
227+
FOLDER "ONNXRuntime")
228+
else()
229+
# Omit the SOVERSION setting in Windows/macOS/iOS/.. build
230+
set_target_properties(onnxruntime PROPERTIES
231+
PUBLIC_HEADER "${ONNXRUNTIME_PUBLIC_HEADERS}"
232+
LINK_DEPENDS ${SYMBOL_FILE}
233+
VERSION ${ORT_VERSION}
234+
FOLDER "ONNXRuntime")
235+
endif()
232236
install(TARGETS onnxruntime
233237
EXPORT ${PROJECT_NAME}Targets
234238
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/onnxruntime

cmake/onnxruntime_providers_cpu.cmake

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -236,11 +236,6 @@ if (NOT onnxruntime_MINIMAL_BUILD AND NOT onnxruntime_EXTENDED_MINIMAL_BUILD
236236
set_target_properties(onnxruntime_providers_shared PROPERTIES FOLDER "ONNXRuntime")
237237
set_target_properties(onnxruntime_providers_shared PROPERTIES LINKER_LANGUAGE CXX)
238238

239-
target_compile_definitions(onnxruntime_providers_shared PRIVATE VER_MAJOR=${VERSION_MAJOR_PART})
240-
target_compile_definitions(onnxruntime_providers_shared PRIVATE VER_MINOR=${VERSION_MINOR_PART})
241-
target_compile_definitions(onnxruntime_providers_shared PRIVATE VER_BUILD=${VERSION_BUILD_PART})
242-
target_compile_definitions(onnxruntime_providers_shared PRIVATE VER_PRIVATE=${VERSION_PRIVATE_PART})
243-
target_compile_definitions(onnxruntime_providers_shared PRIVATE VER_STRING=\"${VERSION_STRING}\")
244239
target_compile_definitions(onnxruntime_providers_shared PRIVATE FILE_NAME=\"onnxruntime_providers_shared.dll\")
245240

246241

cmake/onnxruntime_providers_openvino.cmake

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,6 @@
4545
target_include_directories(onnxruntime_providers_openvino SYSTEM PUBLIC ${ONNXRUNTIME_ROOT} ${CMAKE_CURRENT_BINARY_DIR} ${eigen_INCLUDE_DIRS} ${OpenVINO_INCLUDE_DIR} ${OPENVINO_INCLUDE_DIR_LIST} ${PYTHON_INCLUDE_DIRS} $ENV{OPENCL_INCS} $ENV{OPENCL_INCS}/../../cl_headers/)
4646
target_link_libraries(onnxruntime_providers_openvino ${ONNXRUNTIME_PROVIDERS_SHARED} Boost::mp11 ${OPENVINO_LIB_LIST} ${ABSEIL_LIBS})
4747

48-
target_compile_definitions(onnxruntime_providers_openvino PRIVATE VER_MAJOR=${VERSION_MAJOR_PART})
49-
target_compile_definitions(onnxruntime_providers_openvino PRIVATE VER_MINOR=${VERSION_MINOR_PART})
50-
target_compile_definitions(onnxruntime_providers_openvino PRIVATE VER_BUILD=${VERSION_BUILD_PART})
51-
target_compile_definitions(onnxruntime_providers_openvino PRIVATE VER_PRIVATE=${VERSION_PRIVATE_PART})
52-
target_compile_definitions(onnxruntime_providers_openvino PRIVATE VER_STRING=\"${VERSION_STRING}\")
5348
target_compile_definitions(onnxruntime_providers_openvino PRIVATE FILE_NAME=\"onnxruntime_providers_openvino.dll\")
5449

5550
if(MSVC)

cmake/winml.cmake

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -718,11 +718,6 @@ target_compile_definitions(winml_dll PRIVATE ONNX_ML)
718718
target_compile_definitions(winml_dll PRIVATE LOTUS_LOG_THRESHOLD=2)
719719
target_compile_definitions(winml_dll PRIVATE LOTUS_ENABLE_STDERR_LOGGING)
720720
target_compile_definitions(winml_dll PRIVATE PLATFORM_WINDOWS)
721-
target_compile_definitions(winml_dll PRIVATE VER_MAJOR=${VERSION_MAJOR_PART})
722-
target_compile_definitions(winml_dll PRIVATE VER_MINOR=${VERSION_MINOR_PART})
723-
target_compile_definitions(winml_dll PRIVATE VER_BUILD=${VERSION_BUILD_PART})
724-
target_compile_definitions(winml_dll PRIVATE VER_PRIVATE=${VERSION_PRIVATE_PART})
725-
target_compile_definitions(winml_dll PRIVATE VER_STRING=\"${VERSION_STRING}\")
726721
target_compile_definitions(winml_dll PRIVATE BINARY_NAME=\"${BINARY_NAME}\")
727722

728723
if (onnxruntime_WINML_NAMESPACE_OVERRIDE STREQUAL "Windows")

include/onnxruntime/core/graph/basic_types.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ class TensorProto;
1919
class SparseTensorProto;
2020
class TypeProto;
2121
class AttributeProto;
22+
class FunctionProto;
23+
class OperatorSetIdProto;
2224
// define types that would come from the ONNX library if we were building against it.
2325
#if defined(ORT_MINIMAL_BUILD)
2426
using OperatorSetVersion = int;

java/build-android.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ task sourcesJar(type: Jar) {
105105

106106
task javadoc(type: Javadoc) {
107107
source = android.sourceSets.main.java.srcDirs
108-
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
108+
classpath += project.files(android.getBootClasspath())
109109
}
110110

111111
task javadocJar(type: Jar, dependsOn: javadoc) {

js/web/lib/wasm/jsep/webgpu/ops/3rd-party/matmul_packed_webgpu.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -328,13 +328,6 @@ fn main(@builtin(local_invocation_id) localId : vec3<u32>,
328328
var kStart = ${splitK ? `i32(globalId.z) * ${splitedDimInner}` : '0'};
329329
330330
var acc : array<array<${type}, colPerThread>, rowPerThread>;
331-
332-
// Without this initialization strange values show up in acc.
333-
for (var innerRow = 0; innerRow < rowPerThread; innerRow = innerRow + 1) {
334-
for (var innerCol = 0; innerCol < colPerThread; innerCol = innerCol + 1) {
335-
acc[innerRow][innerCol] = 0.0;
336-
}
337-
}
338331
${matmulSnippet}
339332
}
340333
`;

onnxruntime/core/mlas/inc/mlas_q4.h

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -360,12 +360,12 @@ MlasDequantizeBlockwise(
360360
);
361361

362362
/**
363-
* @brief Blockwise 2 bits or 4 bits quantization. After quantization, the weights and zero points
364-
* are packed row-wise. In terms of the qbits type, dst and src have the same shape, and
365-
* scales and zero_points have the same shape.
366-
* columns must be multiple of 8 / qbits.
363+
* @brief Blockwise 4 bits quantization. After quantization, the weights and zero points
364+
* are packed row-wise. If zero_points is null, quantized type is int4 with default
365+
* zero point 0, to align with DQ schema. Otherwise, quantized type is uint4.
366+
* In int4/uint4, dst have the same shape as src, and zero_points have the same shape as scales.
367367
* @tparam Tin
368-
* @tparam qbits number of bits used for quantization, 2 or 4
368+
* @tparam qbits number of bits used for quantization, only 4 is supported
369369
* @param src points to the floating point matrix, to be quantized, row major shape [rows, columns]
370370
* @param scales points to the scales matrix, row major
371371
* @param zero_points points to the zero_points matrix, row major
@@ -376,9 +376,10 @@ MlasDequantizeBlockwise(
376376
* @param columns
377377
* @param quant_block_size number of elements in a quantize block
378378
* @param thread_pool
379+
* @return the quantized type is signed.
379380
*/
380381
template <typename Tin, int qbits>
381-
void
382+
bool
382383
MlasQDQQuantizeBlockwise(
383384
const Tin* src,
384385
Tin* scales,
@@ -395,8 +396,17 @@ MlasQDQQuantizeBlockwise(
395396
* @brief Transpose blockwise quantized tensors. The src tensors are row major. src weights and zero
396397
* points are packed row-wise. The dst tensors are column major. dst weights and zero points
397398
* are packed column-wise.
399+
* dst_weights and dst_zero_points are in uint4.
400+
* If src_weights is int4 and has src_zero_points, src_weights and src_zero_points are
401+
* converted to uint4 by adding 8.
402+
* If src_weights is int4 and no src_zero_points, src_weights is converted to uint4 by adding 8.
403+
* src_zero_points is 0 and dst_zero_points is 8.
404+
* If src_weights is uint4 and has src_zero_points, just transpose.
405+
* If src_weights is uint4 and no src_zero_points, caller must allocate dst_zero_points with
406+
* 0 values. Otherwise exception is thrown.
398407
* @tparam Tin
399-
* @tparam qbits number of bits used for quantization, 2 or 4
408+
* @tparam qbits number of bits used for quantization, only 4 is supported
409+
* @tparam signed_quant true when quantized type is signed, false when quantized type is unsigned
400410
* @param src_weights points to the quantized matrix, row major, shape [rows, columns] in qbits type.
401411
* In uint8_t type, shape is [rows, columns * qbits / 8].
402412
* @param src_scales points to the scales matrix, row major
@@ -410,7 +420,7 @@ MlasQDQQuantizeBlockwise(
410420
* @param quant_block_size number of elements in a quantize block
411421
* @param thread_pool
412422
*/
413-
template <typename Tin, int qbits>
423+
template <typename Tin, int qbits, bool signed_quant>
414424
void
415425
MlasQDQTransposeBlockwiseQuantized(
416426
const uint8_t* src_weights,

0 commit comments

Comments
 (0)