Skip to content

Commit f89f64e

Browse files
authored
Merge pull request #734 from intel/sync_msft_9_7_25
BackMerging with Msft Commits
2 parents 54151b1 + b4b9492 commit f89f64e

File tree

219 files changed

+2940
-1693
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

219 files changed

+2940
-1693
lines changed

.github/workflows/linux-wasm-ci-build-and-test-workflow.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,28 @@ jobs:
4545
with:
4646
submodules: recursive
4747

48+
- name: Set up Node.js
49+
uses: actions/setup-node@v4
50+
with:
51+
node-version: "22"
52+
53+
# The image used in this workflow has an old version of Node.js installed at /bin/node and npm at /bin/npm.
54+
# We need to remove the system Node.js and npm, otherwise CMake will not be able to find the correct Node.js and npm executables.
55+
- name: Remove the system Node.js
56+
run: |
57+
if [ -f /bin/node ]; then
58+
rm /bin/node
59+
fi
60+
if [ -f /bin/npm ]; then
61+
rm /bin/npm
62+
fi
63+
4864
- name: Set up Python
4965
uses: actions/setup-python@v5
5066
with:
5167
python-version: "3.12"
5268
architecture: ${{ env.buildArch }}
69+
5370
- uses: microsoft/onnxruntime-github-actions/[email protected]
5471
with:
5572
vcpkg-version: '2025.06.13'

.github/workflows/stale.yml

Lines changed: 0 additions & 39 deletions
This file was deleted.

.vscode/settings.json

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,7 @@
88
],
99
"[python]": {
1010
"editor.tabSize": 4,
11-
// Auto sort imports
12-
"editor.formatOnSave": true,
13-
"editor.codeActionsOnSave": {
14-
"source.organizeImports": "explicit"
15-
},
16-
"editor.defaultFormatter": "ms-python.black-formatter"
1711
},
18-
// Enable Python linting and Pylance type checking
19-
"python.analysis.typeCheckingMode": "basic",
2012
"cpplint.lineLength": 120,
2113
"cpplint.filters": [
2214
"-build/include_subdir",

cmake/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ option(onnxruntime_USE_CANN "Build with CANN support" OFF)
134134
option(onnxruntime_USE_XNNPACK "Build with XNNPACK support. Provides an alternative math library on ARM, WebAssembly and x86." OFF)
135135
option(onnxruntime_USE_WEBNN "Build with WebNN support. Enable hardware acceleration in web browsers." OFF)
136136
option(onnxruntime_USE_WEBGPU "Build with WebGPU support. Enable WebGPU via C/C++ interface." OFF)
137+
option(onnxruntime_WGSL_TEMPLATE "Specify the code generator for WGSL template. Default is static." "static")
137138
option(onnxruntime_USE_EXTERNAL_DAWN "Build with treating Dawn as external dependency. Will not link Dawn at build time." OFF)
138139
option(onnxruntime_CUSTOM_DAWN_SRC_PATH "Path to custom Dawn src dir.")
139140
option(onnxruntime_BUILD_DAWN_MONOLITHIC_LIBRARY "Build Dawn as a monolithic library" OFF)

cmake/deps.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,4 @@ directx_headers;https://github.com/microsoft/DirectX-Headers/archive/refs/tags/v
5757
cudnn_frontend;https://github.com/NVIDIA/cudnn-frontend/archive/refs/tags/v1.12.0.zip;7e733cfdc410d777b76122d64232499205589a96
5858
dawn;https://github.com/google/dawn/archive/9733be39e18186961d503e064874afe3e9ceb8d1.zip;2a4017c32892b90d072a9102eba90ae691fae36d
5959
kleidiai;https://github.com/ARM-software/kleidiai/archive/refs/tags/v1.4.0.tar.gz;22d3b57b54a61c194ab256ff11b0353a3b220244
60+
duktape;https://github.com/svaarala/duktape/releases/download/v2.7.0/duktape-2.7.0.tar.xz;8200c8e417dbab7adcc12c4dbdef7651cfc55794

cmake/external/onnxruntime_external_deps.cmake

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -772,6 +772,16 @@ if (onnxruntime_USE_WEBGPU)
772772
if (onnxruntime_ENABLE_PIX_FOR_WEBGPU_EP)
773773
list(APPEND onnxruntime_EXTERNAL_LIBRARIES webgpu_glfw glfw)
774774
endif()
775+
776+
if (NOT CMAKE_SYSTEM_NAME STREQUAL "Emscripten" AND onnxruntime_WGSL_TEMPLATE STREQUAL "dynamic")
777+
onnxruntime_fetchcontent_declare(
778+
duktape
779+
URL ${DEP_URL_duktape}
780+
URL_HASH SHA1=${DEP_SHA1_duktape}
781+
EXCLUDE_FROM_ALL
782+
)
783+
onnxruntime_fetchcontent_makeavailable(duktape)
784+
endif()
775785
endif()
776786

777787
if(onnxruntime_USE_COREML)

cmake/onnxruntime_providers_webgpu.cmake

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,17 @@
99
if (onnxruntime_ENABLE_WEBASSEMBLY_THREADS)
1010
add_definitions(-DENABLE_WEBASSEMBLY_THREADS=1)
1111
endif()
12+
if (onnxruntime_WGSL_TEMPLATE STREQUAL "dynamic")
13+
if (onnxruntime_DISABLE_EXCEPTIONS)
14+
message(FATAL_ERROR "Dynamic WGSL template generation requires exception handling to be enabled.")
15+
endif()
16+
if (CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
17+
message(FATAL_ERROR "Dynamic WGSL template generation is not supported when targeting WebAssembly.")
18+
endif()
19+
add_definitions(-DORT_WGSL_TEMPLATE_DYNAMIC=1)
20+
elseif (NOT onnxruntime_WGSL_TEMPLATE STREQUAL "static")
21+
message(FATAL_ERROR "Unsupported value for onnxruntime_WGSL_TEMPLATE: ${onnxruntime_WGSL_TEMPLATE}. Supported values are 'static' or 'dynamic'.")
22+
endif()
1223
file(GLOB_RECURSE onnxruntime_providers_webgpu_cc_srcs CONFIGURE_DEPENDS
1324
"${ONNXRUNTIME_ROOT}/core/providers/webgpu/*.h"
1425
"${ONNXRUNTIME_ROOT}/core/providers/webgpu/*.cc"
@@ -20,6 +31,7 @@
2031

2132
source_group(TREE ${REPO_ROOT} FILES ${onnxruntime_providers_webgpu_cc_srcs})
2233
onnxruntime_add_static_library(onnxruntime_providers_webgpu ${onnxruntime_providers_webgpu_cc_srcs})
34+
target_compile_features(onnxruntime_providers_webgpu PRIVATE cxx_std_20)
2335
onnxruntime_add_include_to_target(onnxruntime_providers_webgpu
2436
onnxruntime_common onnx onnx_proto flatbuffers::flatbuffers Boost::mp11 safeint_interface)
2537

@@ -117,4 +129,95 @@
117129
endif()
118130

119131
add_dependencies(onnxruntime_providers_webgpu ${onnxruntime_EXTERNAL_DEPENDENCIES})
132+
133+
if (onnxruntime_WGSL_TEMPLATE)
134+
# Define the WGSL templates directory and output directory
135+
set(WGSL_TEMPLATES_DIR "${ONNXRUNTIME_ROOT}/core/providers/webgpu/wgsl_templates")
136+
set(WGSL_GENERATED_ROOT "${CMAKE_CURRENT_BINARY_DIR}/wgsl_generated")
137+
138+
# Find npm and node executables
139+
find_program(NPM_EXECUTABLE "npm.cmd" "npm" REQUIRED)
140+
if(NOT NPM_EXECUTABLE)
141+
message(FATAL_ERROR "npm is required for WGSL template generation but was not found")
142+
endif()
143+
find_program(NODE_EXECUTABLE "node" REQUIRED)
144+
if (NOT NODE_EXECUTABLE)
145+
message(FATAL_ERROR "Node is required for WGSL template generation but was not found")
146+
endif()
147+
148+
# Install npm dependencies
149+
add_custom_command(
150+
OUTPUT "${WGSL_TEMPLATES_DIR}/node_modules/.install_complete"
151+
COMMAND ${NPM_EXECUTABLE} ci
152+
COMMAND ${CMAKE_COMMAND} -E touch "${WGSL_TEMPLATES_DIR}/node_modules/.install_complete"
153+
DEPENDS "${WGSL_TEMPLATES_DIR}/package.json" "${WGSL_TEMPLATES_DIR}/package-lock.json"
154+
WORKING_DIRECTORY ${WGSL_TEMPLATES_DIR}
155+
COMMENT "Installing npm dependencies for WGSL template generation"
156+
VERBATIM
157+
)
158+
159+
if (onnxruntime_WGSL_TEMPLATE STREQUAL "static")
160+
set(WGSL_GENERATED_DIR "${WGSL_GENERATED_ROOT}/wgsl_template_gen")
161+
# set(WGSL_GEN_OUTPUTS "${WGSL_GENERATED_DIR}/index.h" "${WGSL_GENERATED_DIR}/index_impl.h")
162+
# Define the output files that will be generated
163+
set(WGSL_GENERATED_INDEX_H "${WGSL_GENERATED_DIR}/index.h")
164+
set(WGSL_GENERATED_INDEX_IMPL_H "${WGSL_GENERATED_DIR}/index_impl.h")
165+
elseif(onnxruntime_WGSL_TEMPLATE STREQUAL "dynamic")
166+
set(WGSL_GENERATED_DIR "${WGSL_GENERATED_ROOT}/dynamic")
167+
# set(WGSL_GEN_OUTPUTS "${WGSL_GENERATED_DIR}/templates.js")
168+
set(WGSL_GENERATED_TEMPLATES_JS "${WGSL_GENERATED_DIR}/templates.js")
169+
endif()
170+
171+
# Ensure the output directory exists
172+
file(MAKE_DIRECTORY ${WGSL_GENERATED_DIR})
173+
174+
# Find all WGSL template input files
175+
file(GLOB_RECURSE WGSL_TEMPLATE_FILES "${ONNXRUNTIME_ROOT}/core/providers/webgpu/*.wgsl.template")
176+
177+
# Set wgsl-gen command line options as a list
178+
set(WGSL_GEN_OPTIONS "-i" "../" "--output" "${WGSL_GENERATED_DIR}" "-I" "wgsl_template_gen/" "--preserve-code-ref" "--verbose")
179+
if (onnxruntime_WGSL_TEMPLATE STREQUAL "static")
180+
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
181+
list(APPEND WGSL_GEN_OPTIONS "--generator" "static-cpp-literal")
182+
else()
183+
list(APPEND WGSL_GEN_OPTIONS "--generator" "static-cpp")
184+
endif()
185+
elseif(onnxruntime_WGSL_TEMPLATE STREQUAL "dynamic")
186+
list(APPEND WGSL_GEN_OPTIONS "--generator" "dynamic")
187+
endif()
188+
189+
# Generate WGSL templates
190+
add_custom_command(
191+
OUTPUT ${WGSL_GENERATED_INDEX_H} ${WGSL_GENERATED_INDEX_IMPL_H} ${WGSL_GENERATED_TEMPLATES_JS}
192+
COMMAND ${NPM_EXECUTABLE} run gen -- ${WGSL_GEN_OPTIONS}
193+
DEPENDS "${WGSL_TEMPLATES_DIR}/node_modules/.install_complete" ${WGSL_TEMPLATE_FILES}
194+
WORKING_DIRECTORY ${WGSL_TEMPLATES_DIR}
195+
COMMENT "Generating WGSL templates from *.wgsl.template files"
196+
COMMAND_EXPAND_LISTS
197+
VERBATIM
198+
)
199+
200+
# Create a target to represent the generation step
201+
add_custom_target(onnxruntime_webgpu_wgsl_generation
202+
DEPENDS ${WGSL_GENERATED_INDEX_H} ${WGSL_GENERATED_INDEX_IMPL_H} ${WGSL_GENERATED_TEMPLATES_JS}
203+
SOURCES ${WGSL_TEMPLATE_FILES}
204+
)
205+
206+
if (onnxruntime_WGSL_TEMPLATE STREQUAL "static")
207+
# Add the generated directory to include paths
208+
target_include_directories(onnxruntime_providers_webgpu PRIVATE ${WGSL_GENERATED_ROOT})
209+
elseif(onnxruntime_WGSL_TEMPLATE STREQUAL "dynamic")
210+
add_library(duktape_static STATIC "${duktape_SOURCE_DIR}/src/duktape.c")
211+
target_compile_features(duktape_static PRIVATE c_std_99)
212+
target_link_libraries(onnxruntime_providers_webgpu duktape_static)
213+
target_include_directories(onnxruntime_providers_webgpu PRIVATE ${duktape_SOURCE_DIR}/src)
214+
# Define the path to the generated templates.js file
215+
target_compile_definitions(onnxruntime_providers_webgpu PRIVATE
216+
"ORT_WGSL_TEMPLATES_JS_PATH=\"${WGSL_GENERATED_TEMPLATES_JS}\"")
217+
endif()
218+
219+
# Make sure generation happens before building the provider
220+
add_dependencies(onnxruntime_providers_webgpu onnxruntime_webgpu_wgsl_generation)
221+
endif()
222+
120223
set_target_properties(onnxruntime_providers_webgpu PROPERTIES FOLDER "ONNXRuntime")

csharp/tools/MauiModelTester/create_test_data.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def parse_args():
8484

8585

8686
def create_existing_data_map(pb_files: list[Path]):
87-
import onnx_test_data_utils as data_utils
87+
import onnx_test_data_utils as data_utils # noqa: PLC0415
8888

8989
data_map = {}
9090
for file in pb_files:
@@ -101,7 +101,7 @@ def add_model_and_test_data_to_app(
101101
input_map: dict[str, np.ndarray] | None = None,
102102
output_map: dict[str, np.ndarray] | None = None,
103103
):
104-
import ort_test_dir_utils as utils
104+
import ort_test_dir_utils as utils # noqa: PLC0415
105105

106106
output_path = SOLUTION_DIR / "Resources" / "Raw"
107107
test_name = "test_data"

docs/ContribOperators.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2053,6 +2053,8 @@ This version of the operator has been available since version 1 of the 'com.micr
20532053
#### Attributes
20542054

20552055
<dl>
2056+
<dt><tt>bits</tt> : int</dt>
2057+
<dd>Number of bits used for weight quantization. Must be either 4 or 8. </dd>
20562058
<dt><tt>block_size</tt> : int</dt>
20572059
<dd>(Optional) block size used for weight quantization. It needs to be a power of 2 and not smaller than 16.</dd>
20582060
<dt><tt>gather_axis</tt> : int</dt>

docs/python/_common/onnx_sphinx.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
def get_template():
2525
try:
26-
from jinja2 import Template
26+
from jinja2 import Template # noqa: PLC0415
2727
except ImportError: # pragma no cover
2828

2929
class Template:
@@ -251,7 +251,7 @@ def _clean_unicode(text):
251251

252252

253253
def _populate__get_all_schemas_with_history():
254-
import onnxruntime.capi.onnxruntime_pybind11_state as rtpy
254+
import onnxruntime.capi.onnxruntime_pybind11_state as rtpy # noqa: PLC0415
255255

256256
get_schemas = rtpy.get_all_operator_schema or rtpy.get_all_opkernel_def
257257

@@ -885,7 +885,7 @@ def setup(app):
885885
Sphinx extension `onnx_sphinx` displays documentation
886886
of all ONNX Operators.
887887
"""
888-
import sphinx
888+
import sphinx # noqa: PLC0415
889889

890890
app.add_config_value("onnx_doc_folder", "operators", "env")
891891
app.add_config_value("max_opsets", {}, "env")

0 commit comments

Comments
 (0)