2024-10-08 23:10:46 +00:00
|
|
|
# Copyright (c) Microsoft Corporation. All rights reserved.
|
|
|
|
|
# Licensed under the MIT License.
|
|
|
|
|
|
|
|
|
|
if (onnxruntime_MINIMAL_BUILD AND NOT onnxruntime_EXTENDED_MINIMAL_BUILD)
|
|
|
|
|
message(FATAL_ERROR "WebGPU EP can not be used in a basic minimal build. Please build with '--minimal_build extended'")
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
add_compile_definitions(USE_WEBGPU=1)
|
|
|
|
|
if (onnxruntime_ENABLE_WEBASSEMBLY_THREADS)
|
|
|
|
|
add_definitions(-DENABLE_WEBASSEMBLY_THREADS=1)
|
|
|
|
|
endif()
|
|
|
|
|
file(GLOB_RECURSE onnxruntime_providers_webgpu_cc_srcs CONFIGURE_DEPENDS
|
|
|
|
|
"${ONNXRUNTIME_ROOT}/core/providers/webgpu/*.h"
|
|
|
|
|
"${ONNXRUNTIME_ROOT}/core/providers/webgpu/*.cc"
|
|
|
|
|
)
|
|
|
|
|
if(NOT onnxruntime_DISABLE_CONTRIB_OPS)
|
|
|
|
|
source_group(TREE ${ONNXRUNTIME_ROOT} FILES ${onnxruntime_webgpu_contrib_ops_cc_srcs})
|
|
|
|
|
list(APPEND onnxruntime_providers_webgpu_cc_srcs ${onnxruntime_webgpu_contrib_ops_cc_srcs})
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
source_group(TREE ${REPO_ROOT} FILES ${onnxruntime_providers_webgpu_cc_srcs})
|
|
|
|
|
onnxruntime_add_static_library(onnxruntime_providers_webgpu ${onnxruntime_providers_webgpu_cc_srcs})
|
|
|
|
|
onnxruntime_add_include_to_target(onnxruntime_providers_webgpu
|
|
|
|
|
onnxruntime_common dawn::dawncpp_headers dawn::dawn_headers onnx onnx_proto flatbuffers::flatbuffers Boost::mp11 safeint_interface)
|
Add implementation of WebGPU EP (#22591)
### Description
This PR adds the actual implementation of the WebGPU EP based on
https://github.com/microsoft/onnxruntime/pull/22318.
This change includes the following:
<details>
<summary><b>core framework of WebGPU EP</b></summary>
- WebGPU EP factory classes for:
- handling WebGPU options
- creating WebGPU EP instance
- creating WebGPU context
- WebGPU Execution Provider classes
- GPU Buffer allocator
- data transfer
- Buffer management classes
- Buffer Manager
- BufferCacheManager
- DisabledCacheManager
- SimpleCacheManager
- LazyReleaseCacheManager
- BucketCacheManager
- Program classes
- Program (base)
- Program Cache Key
- Program Manager
- Shader helper classes
- Shader Helper
- ShaderIndicesHelper
- ShaderVariableHelper
- Utils
- GPU Query based profiler
- compute context
- string utils
- Miscs
- Python binding webgpu support (basic)
</details>
<details>
<summary><b>Kernel implementation</b></summary>
- onnx.ai (default opset):
- Elementwise (math): Abs, Neg, Floor, Ceil, Reciprocal, Sqrt, Exp, Erf,
Log, Sin, Cos, Tan, Asin, Acos, Atan, Sinh, Cosh, Asinh, Acosh, Atanh,
Tanh, Not, Cast
- Elementwise (activation): Sigmoid, HardSigmoid, Clip, Elu, Relu,
LeakyRelu, ThresholdedRelu, Gelu
- Binary (math): Add, Sub, Mul, Div, Pow, Equal, Greater,
GreaterOrEqual, Less, LessOrEqual
- (Tensors): Shape, Reshape, Squeeze, Unsqueeze
- Where
- Transpose
- Concat
- Expand
- Gather
- Tile
- Range
- LayerNormalization
- com.microsoft
- FastGelu
- MatMulNBits
- MultiHeadAttention
- RotaryEmbedding
- SkipLayerNormalization
- LayerNormalization
- SimplifiedLayerNormalization
- SkipSimplifiedLayerNormalization
</details>
<details>
<summary><b>Build, test and CI pipeline integration</b></summary>
- build works for Windows, macOS and iOS
- support onnxruntime_test_all and python node test
- added a new unit test for `--use_external_dawn` build flag.
- updated MacOS pipeline to build with WebGPU support
- added a new pipeline for WebGPU Windows
</details>
This change does not include:
- Node.js binding support for WebGPU (will be a separate PR)
2024-10-30 01:29:40 +00:00
|
|
|
if (NOT onnxruntime_USE_EXTERNAL_DAWN)
|
|
|
|
|
target_link_libraries(onnxruntime_providers_webgpu dawn::dawn_native)
|
|
|
|
|
endif()
|
|
|
|
|
target_link_libraries(onnxruntime_providers_webgpu dawn::dawn_proc)
|
2024-10-08 23:10:46 +00:00
|
|
|
|
|
|
|
|
set_target_properties(onnxruntime_providers_webgpu PROPERTIES FOLDER "ONNXRuntime")
|