Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 18 additions & 7 deletions cmake/external/onnxruntime_external_deps.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -774,13 +774,24 @@ if (onnxruntime_USE_WEBGPU)
endif()

if (NOT CMAKE_SYSTEM_NAME STREQUAL "Emscripten" AND onnxruntime_WGSL_TEMPLATE STREQUAL "dynamic")
onnxruntime_fetchcontent_declare(
duktape
URL ${DEP_URL_duktape}
URL_HASH SHA1=${DEP_SHA1_duktape}
EXCLUDE_FROM_ALL
)
onnxruntime_fetchcontent_makeavailable(duktape)
if(onnxruntime_USE_VCPKG)
find_package(unofficial-duktape CONFIG REQUIRED)
add_library(duktape_static ALIAS unofficial::duktape::duktape)
else()
onnxruntime_fetchcontent_declare(
duktape
URL ${DEP_URL_duktape}
URL_HASH SHA1=${DEP_SHA1_duktape}
EXCLUDE_FROM_ALL
)
onnxruntime_fetchcontent_makeavailable(duktape)

if(NOT TARGET duktape_static)
add_library(duktape_static STATIC "${duktape_SOURCE_DIR}/src/duktape.c")
target_compile_features(duktape_static PRIVATE c_std_99)
target_include_directories(duktape_static INTERFACE $<BUILD_INTERFACE:${duktape_SOURCE_DIR}/src>)
endif()
endif()
endif()
endif()

Expand Down
11 changes: 6 additions & 5 deletions cmake/onnxruntime_providers_webgpu.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,12 @@
file(MAKE_DIRECTORY ${WGSL_GENERATED_DIR})

# Find all WGSL template input files
file(GLOB_RECURSE WGSL_TEMPLATE_FILES "${ONNXRUNTIME_ROOT}/core/providers/webgpu/*.wgsl.template")
file(GLOB_RECURSE WGSL_TEMPLATE_FILES
"${ONNXRUNTIME_ROOT}/core/providers/webgpu/*.wgsl.template"
"${ONNXRUNTIME_ROOT}/contrib_ops/webgpu/*.wgsl.template")

# Set wgsl-gen command line options as a list
set(WGSL_GEN_OPTIONS "-i" "../" "--output" "${WGSL_GENERATED_DIR}" "-I" "wgsl_template_gen/" "--preserve-code-ref" "--verbose")
set(WGSL_GEN_OPTIONS "-i" "${ONNXRUNTIME_ROOT}/core/providers/webgpu/" "-i" "${ONNXRUNTIME_ROOT}/contrib_ops/webgpu/" "--output" "${WGSL_GENERATED_DIR}" "-I" "wgsl_template_gen/" "--preserve-code-ref" "--verbose")
if (onnxruntime_WGSL_TEMPLATE STREQUAL "static")
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
list(APPEND WGSL_GEN_OPTIONS "--generator" "static-cpp-literal")
Expand Down Expand Up @@ -207,10 +209,9 @@
# Add the generated directory to include paths
target_include_directories(onnxruntime_providers_webgpu PRIVATE ${WGSL_GENERATED_ROOT})
elseif(onnxruntime_WGSL_TEMPLATE STREQUAL "dynamic")
add_library(duktape_static STATIC "${duktape_SOURCE_DIR}/src/duktape.c")
target_compile_features(duktape_static PRIVATE c_std_99)
target_link_libraries(onnxruntime_providers_webgpu duktape_static)
target_include_directories(onnxruntime_providers_webgpu PRIVATE ${duktape_SOURCE_DIR}/src)
onnxruntime_add_include_to_target(onnxruntime_providers_webgpu duktape_static)

# Define the path to the generated templates.js file
target_compile_definitions(onnxruntime_providers_webgpu PRIVATE
"ORT_WGSL_TEMPLATES_JS_PATH=\"${WGSL_GENERATED_TEMPLATES_JS}\"")
Expand Down
8 changes: 8 additions & 0 deletions cmake/vcpkg.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@
"webgpu-ep": {
"description": "Build with WebGPU EP",
"dependencies": []
},
"webgpu-ep-wgsl-template-dynamic": {
"description": "Build with WebGPU EP with dynamic WGSL template code generator",
"dependencies": ["duktape"]
}
},
"overrides": [
Expand All @@ -104,6 +108,10 @@
{
"name": "flatbuffers",
"version": "23.5.26"
},
{
"name": "duktape",
"version": "2.7.0#2"
}
]
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
"author": "",
"license": "MIT",
"dependencies": {
"@fs-eire/wgsl-template": "^0.1.3"
"@fs-eire/wgsl-template": "^0.1.13"
}
}
2 changes: 2 additions & 0 deletions tools/ci_build/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,8 @@ def generate_vcpkg_install_options(build_dir, args):
vcpkg_install_options.append("--x-feature=vsinpu-ep")
if args.use_webgpu:
vcpkg_install_options.append("--x-feature=webgpu-ep")
if args.wgsl_template == "dynamic":
vcpkg_install_options.append("--x-feature=webgpu-ep-wgsl-template-dynamic")
if args.use_webnn:
vcpkg_install_options.append("--x-feature=webnn-ep")
if args.use_xnnpack:
Expand Down
Loading