[Web] Avoid unnecessary data copy for pre-allocated tensors - #25571
Conversation
|
Yulong Wang (@fs-eire), PTAL, thanks! |
8bd7e01 to
4810b63
Compare
|
/azp run Linux QNN CI Pipeline,Win_TRT_Minimal_CUDA_Test_CI,Windows ARM64 QNN CI Pipeline,Windows GPU Doc Gen CI Pipeline,Windows x64 QNN CI Pipeline |
|
Azure Pipelines successfully started running 5 pipeline(s). |
|
I may need to understand more details about why in this case, |
Currently this is WebNN only case, usually if we use pre-allocated output tensors, the
So I need to release this |
For onnxruntime/onnxruntime/wasm/api.cc Lines 605 to 607 in 131cf40 |
Oh, that's odd, as I tested |
Yulong Wang (@fs-eire), after further debugging, I find there're two places change the address of the
|
4810b63 to
a5cc31b
Compare
|
Yulong Wang (@fs-eire), friendly ping. |
please merge to latest main branch and add comments in line 866 "// TODO: revisit this part to ensure it works for WebGPU when both pre-allocated outputs and preferred location are specified" |
Ensure all pre-allocated tensors do not trigger unnecessary data copying. e.g. the WebNN EP always binds its tensor to 'ml-tensor'. In such cases, the tensor ID might change after binding, but copying data for these tensors should still be avoided. This improves efficiency and avoids redundant operations.
a5cc31b to
c92a638
Compare
Yulong Wang (@fs-eire), done. |
|
/azp run Linux QNN CI Pipeline, Win_TRT_Minimal_CUDA_Test_CI, Windows ARM64 QNN CI Pipeline, Windows GPU Doc Gen CI Pipeline, Windows x64 QNN CI Pipeline |
|
Azure Pipelines successfully started running 5 pipeline(s). |
|
Yulong Wang (@fs-eire), one unexpected failure CI, do I need to re-merge to latest main branch? |
7fa13a6
into
microsoft:main
Description
Ensure all pre-allocated tensors do not trigger unnecessary data copying. e.g. the WebNN EP always binds its tensor to 'ml-tensor'. In such cases, the tensor ID might change after binding, but copying data for these tensors should still be avoided.
Motivation and Context
This improves efficiency and avoids redundant operations.