From 60290393f3d3afe240b5a5886a5da2b8e2dcb835 Mon Sep 17 00:00:00 2001 From: Guenther Schmuelling Date: Tue, 17 Jan 2023 12:39:13 -0800 Subject: [PATCH] enable ort-extensions in wasm release builds (#14239) enable ort-extensions in wasm release builds. sentence piece, gpt2, bert and word piece tokenizers for now. wasm size will grow from 8.4MB to 8.9MB. --- cmake/external/extensions.cmake | 14 ++++++++++++++ .../github/azure-pipelines/templates/web-ci.yml | 4 ++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/cmake/external/extensions.cmake b/cmake/external/extensions.cmake index 5d7e3ad60c..54f1d659ad 100644 --- a/cmake/external/extensions.cmake +++ b/cmake/external/extensions.cmake @@ -21,6 +21,20 @@ if (onnxruntime_REDUCED_OPS_BUILD) set(OCOS_ENABLE_SELECTED_OPLIST ON CACHE INTERNAL "") endif() +if (onnxruntime_WEBASSEMBLY_DEFAULT_EXTENSION_FLAGS) + set(OCOS_ENABLE_SPM_TOKENIZER ON CACHE INTERNAL "") + set(OCOS_ENABLE_GPT2_TOKENIZER ON CACHE INTERNAL "") + set(OCOS_ENABLE_WORDPIECE_TOKENIZER ON CACHE INTERNAL "") + set(OCOS_ENABLE_BERT_TOKENIZER ON CACHE INTERNAL "") + set(OCOS_ENABLE_TF_STRING ON CACHE INTERNAL "") + set(SPM_USE_BUILTIN_PROTOBUF OFF CACHE INTERNAL "") + set(OCOS_ENABLE_STATIC_LIB ON CACHE INTERNAL "") + set(OCOS_ENABLE_BLINGFIRE OFF CACHE INTERNAL "") + set(OCOS_ENABLE_CV2 OFF CACHE INTERNAL "") + set(OCOS_ENABLE_OPENCV_CODECS OFF CACHE INTERNAL "") + set(OCOS_ENABLE_VISION OFF CACHE INTERNAL "") +endif() + # when onnxruntime-extensions is not a subdirectory of onnxruntime, # output binary directory must be explicitly specified. # and the output binary path is the same as CMake FetchContent pattern diff --git a/tools/ci_build/github/azure-pipelines/templates/web-ci.yml b/tools/ci_build/github/azure-pipelines/templates/web-ci.yml index ec7c89fccd..1540dc6f9d 100644 --- a/tools/ci_build/github/azure-pipelines/templates/web-ci.yml +++ b/tools/ci_build/github/azure-pipelines/templates/web-ci.yml @@ -50,7 +50,7 @@ stages: parameters: CommitOverride: true BuildConfig: 'Debug' - ExtraBuildArgs: '$(ExtraBuildArgs)' + ExtraBuildArgs: '--use_extensions --cmake_extra_defines onnxruntime_WEBASSEMBLY_DEFAULT_EXTENSION_FLAGS=ON $(ExtraBuildArgs)' PoolName: ${{ parameters.PoolName }} - stage: Build_web_Debug @@ -71,7 +71,7 @@ stages: parameters: CommitOverride: true BuildConfig: 'Release' - ExtraBuildArgs: '--skip_tests --enable_wasm_api_exception_catching --disable_rtti $(ExtraBuildArgs)' + ExtraBuildArgs: '--skip_tests --enable_wasm_api_exception_catching --disable_rtti --use_extensions --cmake_extra_defines onnxruntime_WEBASSEMBLY_DEFAULT_EXTENSION_FLAGS=ON $(ExtraBuildArgs)' PoolName: ${{ parameters.PoolName }} - ${{ if eq(parameters.BuildStaticLib, 'true') }}: