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
11 changes: 11 additions & 0 deletions .github/workflows/linux-wasm-ci-build-and-test-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ jobs:
--enable_wasm_simd
${{ inputs.enable_wasm_threads == true && '--enable_wasm_threads' || '' }}
${{ inputs.extra_build_args }}
reduced_size_build_args: >-
--disable_ml_ops
--disable_generation_ops
--disable_types string float4 float8 optional sparsetensor
--include_ops_by_config onnxruntime/wasm/reduced_types.config
--enable_reduced_operator_type_support
Comment thread
skottmckay marked this conversation as resolved.

steps:
- name: Checkout code
Expand All @@ -68,6 +74,9 @@ jobs:
python-version: "3.12"
architecture: ${{ env.buildArch }}

- name: Install python dependencies
run: python -m pip install flatbuffers

- uses: microsoft/onnxruntime-github-actions/setup-build-tools@v0.0.9
with:
vcpkg-version: '2025.08.27'
Expand Down Expand Up @@ -109,6 +118,7 @@ jobs:
--use_webnn \
--target onnxruntime_webassembly \
${{ inputs.build_config == 'Release' && '--enable_wasm_api_exception_catching' || '' }} \
${{ env.reduced_size_build_args }} \
--skip_tests
working-directory: ${{ github.workspace }}

Expand All @@ -122,6 +132,7 @@ jobs:
--use_webnn \
--enable_wasm_jspi \
--target onnxruntime_webassembly \
${{ env.reduced_size_build_args }} \
--skip_tests
working-directory: ${{ github.workspace }}

Expand Down
17 changes: 15 additions & 2 deletions js/build_jsep.bat
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,21 @@ popd

set PATH=C:\Program Files\Git\usr\bin;%PATH%

call %ROOT%build.bat --config %CONFIG% %CONFIG_EXTRA_FLAG% --skip_submodule_sync --build_wasm --skip_tests^
--enable_wasm_simd --enable_wasm_threads --use_jsep --use_webnn --target onnxruntime_webassembly --build_dir %BUILD_DIR%
call %ROOT%build.bat^
--config %CONFIG%^
%CONFIG_EXTRA_FLAG%^
--parallel^
--skip_submodule_sync^
--build_wasm^
--target onnxruntime_webassembly^
--skip_tests^
--enable_wasm_simd^
--enable_wasm_threads^
--use_jsep^
--use_webnn^
--build_dir %BUILD_DIR%^
--include_ops_by_config %ROOT%onnxruntime\wasm\reduced_types.config^
--enable_reduced_operator_type_support

IF NOT "%ERRORLEVEL%" == "0" (
exit /b %ERRORLEVEL%
Expand Down
18 changes: 16 additions & 2 deletions js/build_webgpu.bat
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,22 @@ popd

set PATH=C:\Program Files\Git\usr\bin;%PATH%

call %ROOT%build.bat --config %CONFIG% %CONFIG_EXTRA_FLAG% --skip_submodule_sync --build_wasm --target onnxruntime_webassembly --skip_tests^
--enable_wasm_simd --enable_wasm_threads --use_webnn --use_webgpu --enable_wasm_jspi --build_dir %BUILD_DIR%
call %ROOT%build.bat^
--config %CONFIG%^
%CONFIG_EXTRA_FLAG%^
--parallel^
--skip_submodule_sync^
--build_wasm^
--target onnxruntime_webassembly^
--skip_tests^
--enable_wasm_simd^
--enable_wasm_threads^
--use_webnn^
--use_webgpu^
--enable_wasm_jspi^
--build_dir %BUILD_DIR%^
--include_ops_by_config %ROOT%onnxruntime\wasm\reduced_types.config^
--enable_reduced_operator_type_support

IF NOT "%ERRORLEVEL%" == "0" (
exit /b %ERRORLEVEL%
Expand Down
4 changes: 3 additions & 1 deletion js/build_webgpu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
"$ROOT_DIR/build.sh" \
--config "$CONFIG" \
--parallel \
${CONFIG_EXTRA_FLAG} \

Check warning on line 94 in js/build_webgpu.sh

View workflow job for this annotation

GitHub Actions / Optional Lint

[shellcheck] reported by reviewdog 🐶 Double quote to prevent globbing and word splitting. Raw Output: ./js/build_webgpu.sh:94:5: info: Double quote to prevent globbing and word splitting. (ShellCheck.SC2086)
--skip_submodule_sync \
--build_wasm \
--target onnxruntime_webassembly \
Expand All @@ -101,7 +101,9 @@
--use_webnn \
--use_webgpu \
--enable_wasm_jspi \
--build_dir "$BUILD_DIR"
--build_dir "$BUILD_DIR" \
--include_ops_by_config "$ROOT_DIR/onnxruntime/wasm/reduced_types.config" \
--enable_reduced_operator_type_support

# The 'set -e' command at the beginning of the script ensures that the script will exit
# immediately if the build.sh command (or any other command) fails.
Expand Down
14 changes: 14 additions & 0 deletions onnxruntime/wasm/reduced_types.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Reduced type configuration for WebAssembly builds.
# This limits globally allowed types for all operators to reduce binary size (~230KB).
# See https://onnxruntime.ai/docs/reference/operators/reduced-operator-config-file.html
#
# Usage: pass to build.py via:
# --include_ops_by_config onnxruntime/wasm/reduced_types.config --enable_reduced_operator_type_support
#
# Excluded types: float4, float8, float64 (double), int16, uint16

# Keep all operators - only apply type reduction
!no_ops_specified_means_all_ops_are_required

# Globally allowed types for all operators
!globally_allowed_types;bool,int8_t,uint8_t,int32_t,uint32_t,int64_t,uint64_t,float,MLFloat16
Comment thread
fs-eire marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ jobs:
ExceptionHandlingBuildArgs: '--enable_wasm_api_exception_catching'
${{ else }}:
ExceptionHandlingBuildArgs: ''
reducedSizeBuildArgs: '--disable_ml_ops --disable_generation_ops --disable_types string float4 float8 optional sparsetensor --include_ops_by_config $(Build.SourcesDirectory)/onnxruntime/wasm/reduced_types.config --enable_reduced_operator_type_support'
runCodesignValidationInjection: false
TODAY: $[format('{0:dd}{0:MM}{0:yyyy}', pipeline.startTime)]
ORT_CACHE_DIR: $(Agent.TempDirectory)/ort_ccache
Expand Down Expand Up @@ -92,6 +93,9 @@ jobs:
inputs:
versionSpec: '22.x'

- script: python -m pip install flatbuffers
displayName: 'Install python dependencies'

- ${{if eq(parameters.WithCache, true)}}:
- script: |
set -ex
Expand Down Expand Up @@ -141,7 +145,7 @@ jobs:
${{ else }}:
AdditionalKey: wasm_inferencing_webgpu | ${{ parameters.BuildConfig }}
CacheDir: $(ORT_CACHE_DIR)/wasm_inferencing_webgpu
Arguments: '$(CommonBuildArgs) --build_dir $(Build.BinariesDirectory)/wasm_inferencing_webgpu --use_webgpu --use_webnn --target onnxruntime_webassembly $(ExceptionHandlingBuildArgs) --skip_tests'
Arguments: '$(CommonBuildArgs) --build_dir $(Build.BinariesDirectory)/wasm_inferencing_webgpu --use_webgpu --use_webnn --target onnxruntime_webassembly $(ExceptionHandlingBuildArgs) $(reducedSizeBuildArgs) --skip_tests'
DisplayName: 'Build (simd + threads + WebGPU experimental)'
WithCache: ${{ parameters.WithCache }}

Expand All @@ -154,7 +158,7 @@ jobs:
${{ else }}:
AdditionalKey: wasm_inferencing_webgpu_jspi | ${{ parameters.BuildConfig }}
CacheDir: $(ORT_CACHE_DIR)/wasm_inferencing_webgpu_jspi
Arguments: '$(CommonBuildArgs) --build_dir $(Build.BinariesDirectory)/wasm_inferencing_webgpu_jspi --use_webgpu --use_webnn --enable_wasm_jspi --target onnxruntime_webassembly --skip_tests'
Arguments: '$(CommonBuildArgs) --build_dir $(Build.BinariesDirectory)/wasm_inferencing_webgpu_jspi --use_webgpu --use_webnn --enable_wasm_jspi --target onnxruntime_webassembly $(reducedSizeBuildArgs) --skip_tests'
DisplayName: 'Build (simd + threads + WebGPU experimental, JSPI)'
WithCache: ${{ parameters.WithCache }}

Expand Down
Loading