Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
5 changes: 5 additions & 0 deletions cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ option(onnxruntime_ENABLE_WEBASSEMBLY_DEBUG_INFO "Enable this option to turn on
option(onnxruntime_ENABLE_WEBASSEMBLY_PROFILING "Enable this option to turn on WebAssembly profiling and preserve function names" OFF)
option(onnxruntime_ENABLE_WEBASSEMBLY_OUTPUT_OPTIMIZED_MODEL "Enable this option to allow WebAssembly to output optimized model" OFF)
option(onnxruntime_ENABLE_WEBASSEMBLY_RELAXED_SIMD "Enable WebAssembly Relaxed SIMD" OFF)
option(onnxruntime_WEBASSEMBLY_REDUCE_DATATYPE "Enable reduced datatype macro in WebAssembly builds" OFF)
Comment thread
fs-eire marked this conversation as resolved.
Outdated

# Enable bitcode for iOS
option(onnxruntime_ENABLE_BITCODE "Enable bitcode for iOS only" OFF)
Expand Down Expand Up @@ -1751,6 +1752,10 @@ if (CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
message(STATUS "WebAssembly Build is enabled")
list(APPEND ONNXRUNTIME_CMAKE_FILES onnxruntime_webassembly)

if (onnxruntime_WEBASSEMBLY_REDUCE_DATATYPE)
add_compile_definitions(ORT_WASM_REDUCE_DATATYPE)
endif()

if (onnxruntime_ENABLE_WEBASSEMBLY_OUTPUT_OPTIMIZED_MODEL)
add_compile_definitions(ORT_ENABLE_WEBASSEMBLY_OUTPUT_OPTIMIZED_MODEL)
endif()
Expand Down
30 changes: 30 additions & 0 deletions onnxruntime/core/providers/op_kernel_type_control_overrides.inc
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,36 @@ namespace op_kernel_type_control {
using types = ::onnxruntime::TypeList<__VA_ARGS__>; \
};

//
// The following section is the default overrides for a reduced-size WebAssembly build.
//
#if defined(__wasm__) && defined(ORT_WASM_REDUCE_DATATYPE)
Comment thread
fs-eire marked this conversation as resolved.
Outdated
ORT_SPECIFY_OP_KERNEL_ARG_ALLOWED_TYPES(kOnnxDomain, Cast, Input, 0,
bool,
int8_t, uint8_t, int32_t, uint32_t, int64_t, uint64_t,
float, MLFloat16)

ORT_SPECIFY_OP_KERNEL_ARG_ALLOWED_TYPES(kOnnxDomain, Scatter, Input, 0,
bool,
int8_t, uint8_t, int32_t, uint32_t, int64_t, uint64_t,
float, MLFloat16)

ORT_SPECIFY_OP_KERNEL_ARG_ALLOWED_TYPES(kOnnxDomain, ScatterElements, Input, 0,
bool,
int8_t, uint8_t, int32_t, uint32_t, int64_t, uint64_t,
float, MLFloat16)

ORT_SPECIFY_OP_KERNEL_ARG_ALLOWED_TYPES(kOnnxDomain, ScatterND, Input, 0,
bool,
int8_t, uint8_t, int32_t, uint32_t, int64_t, uint64_t,
float, MLFloat16)

ORT_SPECIFY_OP_KERNEL_GLOBAL_ALLOWED_TYPES(
bool,
int8_t, uint8_t, int16_t, uint16_t, int32_t, uint32_t, int64_t, uint64_t,
float, MLFloat16)
#endif // defined(__wasm__) && defined(ORT_WASM_REDUCE_DATATYPE)

// Examples:
// Specify allowed types per Op kernel arg:
// ORT_SPECIFY_OP_KERNEL_ARG_ALLOWED_TYPES(kOnnxDomain, Cast, Input, 0, float, int64_t);
Expand Down
1 change: 1 addition & 0 deletions tools/ci_build/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,7 @@ def generate_build_tree(
"-Donnxruntime_ENABLE_WEBASSEMBLY_THREADS=" + ("ON" if args.enable_wasm_threads else "OFF"),
"-Donnxruntime_ENABLE_WEBASSEMBLY_DEBUG_INFO=" + ("ON" if args.enable_wasm_debug_info else "OFF"),
"-Donnxruntime_ENABLE_WEBASSEMBLY_PROFILING=" + ("ON" if args.enable_wasm_profiling else "OFF"),
"-Donnxruntime_WEBASSEMBLY_REDUCE_DATATYPE=" + ("ON" if args.wasm_reduce_datatype else "OFF"),
"-Donnxruntime_ENABLE_LAZY_TENSOR=" + ("ON" if args.enable_lazy_tensor else "OFF"),
"-Donnxruntime_ENABLE_CUDA_PROFILING=" + ("ON" if args.enable_cuda_profiling else "OFF"),
"-Donnxruntime_USE_XNNPACK=" + ("ON" if args.use_xnnpack else "OFF"),
Expand Down
5 changes: 5 additions & 0 deletions tools/ci_build/build_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,11 @@ def add_webassembly_args(parser: argparse.ArgumentParser) -> None:
"""Adds arguments for WebAssembly (WASM) platform builds."""
parser.add_argument("--build_wasm", action="store_true", help="Build for WebAssembly.")
parser.add_argument("--build_wasm_static_lib", action="store_true", help="Build WebAssembly static library.")
parser.add_argument(
"--wasm_reduce_datatype",
action="store_true",
help="Enable WebAssembly reduced datatype support for kernel type control overrides.",
)
parser.add_argument("--emsdk_version", default="4.0.23", help="Specify version of emsdk.")
parser.add_argument(
"--enable_wasm_jspi", action="store_true", help="Enable WebAssembly JavaScript Promise Integration."
Expand Down
Loading