-
Notifications
You must be signed in to change notification settings - Fork 3.3k
[WebNN] Handle in-memory external data #25079
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Some initializers are stored as in-memory external data, WebNN EP should support these initializers. This PR: - Added `HasExternalDataInMemory` check for external data to avoid unexpected error. - Wrapped the `UnpackInitializerData` to make it compatible with external data. Fixed microsoft#25078
@yuslepukhin, @fs-eire, @fdwr, PTAL, thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR updates various WebNN operator builders to support in-memory external data for initializers. The changes add an in-memory external data check and update numerous calls to initializer unpacking and tensor reading functions to pass the graph viewer and logger for improved error reporting and compatibility.
- Added a check for in-memory external data in constant registration.
- Updated calls to UnpackInitializerData, ReadIntArrayFrom1DTensor, and ReadScalarTensorData to include graph viewer context.
- Modified several operator builders (e.g., triangular, split, slice, resize, reshape, pad, lstm, gru, gqa, expand, cumsum) to support these changes.
Reviewed Changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
onnxruntime/core/providers/webnn/builders/model_builder.cc | Added an in-memory external-data check and updated unpacking function call. |
onnxruntime/core/providers/webnn/builders/impl/triangular_op_builder.cc | Updated initializer unpacking to include additional parameters. |
onnxruntime/core/providers/webnn/builders/impl/split_op_builder.cc | Changed tensor reading for split input to pass the graph viewer. |
onnxruntime/core/providers/webnn/builders/impl/slice_op_builder.cc | Updated unpacking call signature for slice input tensors. |
onnxruntime/core/providers/webnn/builders/impl/resize_op_builder.cc | Modified scales and sizes unpacking calls to include graph viewer and logger context. |
onnxruntime/core/providers/webnn/builders/impl/reshape_op_builder.cc | Updated perm tensor unpacking call with the new function signature. |
onnxruntime/core/providers/webnn/builders/impl/pad_op_builder.cc | Updated pad and axis tensor reading to pass the graph viewer and adjusted error messages. |
onnxruntime/core/providers/webnn/builders/impl/lstm_op_builder.cc | Updated sequence lens reading to include graph viewer context. |
onnxruntime/core/providers/webnn/builders/impl/gru_op_builder.cc | Updated sequence lens reading for GRU with the graph viewer parameter. |
onnxruntime/core/providers/webnn/builders/impl/gqa_op_builder.cc | Modified scalar tensor reading to include graph viewer context. |
onnxruntime/core/providers/webnn/builders/impl/expand_op_builder.cc | Updated shape tensor reading by including the graph viewer. |
onnxruntime/core/providers/webnn/builders/impl/cumsum_op_builder.cc | Changed axis tensor unpacking to use the new interface with graph viewer. |
onnxruntime/core/providers/webnn/builders/helper.h | Introduced a new inline overload for UnpackInitializerData and updated helper functions. |
onnxruntime/core/providers/webnn/builders/impl/pad_op_builder.cc
Outdated
Show resolved
Hide resolved
onnxruntime/core/providers/webnn/builders/impl/pad_op_builder.cc
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with the typos fixed.
/azp run ONNX Runtime Web CI Pipeline,Windows GPU CI Pipeline,Linux Android Emulator QNN CI Pipeline,Windows GPU WebGPU CI Pipeline,Windows OpenVINO CI Pipeline |
/azp run Linux CPU CI Pipeline,Linux CPU Minimal Build E2E CI Pipeline,Linux GPU CI Pipeline,Linux GPU TensorRT CI Pipeline,Linux OpenVINO CI Pipeline,Linux QNN CI Pipeline,MacOS CI Pipeline,Windows ARM64 QNN CI Pipeline,Windows CPU CI Pipeline |
/azp run Windows GPU CUDA CI Pipeline,Windows GPU DML CI Pipeline,Windows GPU Doc Gen CI Pipeline,Win_TRT_Minimal_CUDA_Test_CI |
/azp run Windows GPU TensorRT CI Pipeline,onnxruntime-binary-size-checks-ci-pipeline,orttraining-linux-ci-pipeline,orttraining-linux-gpu-ci-pipeline,orttraining-ortmodule-distributed,Windows x64 QNN CI Pipeline,Big Models |
Azure Pipelines successfully started running 1 pipeline(s). |
/azp run Test Linux CUDA x64 Release,Test Linux TensorRT x64 Release,web_Debug / build_onnxruntime_web,web_Release / build_onnxruntime_web |
Azure Pipelines successfully started running 2 pipeline(s). |
No pipelines are associated with this pull request. |
Azure Pipelines successfully started running 1 pipeline(s). |
Azure Pipelines successfully started running 2 pipeline(s). |
Thanks, typos fixed. |
Description
Some initializers are stored as in-memory external data, WebNN EP should support these initializers.
Motivation and Context
This PR:
HasExternalDataInMemory
check for external data to avoid unexpected error.UnpackInitializerData
to make it compatible with external data.Fixed #25078