WebNN: Define MLContext::destroy
interface
This CL defines MLContext::destroy
interface on blink side. It's
to destroy the MLContext
explicitly to let it be lost.
MLContext
retains weak references to all of the MLBuffer
,
MLGraph
and MLGraphBuilder
instances, their Mojo pipes will be
disconnected and their pending promises will be rejected at the
same time as the MLContext
is destroyed. Any calls rely on the
MLContext
are not allowed and will throw errors.
This CL sets disconnection handler for MLGraphBuilder
to reject
pending promise of creating MLGraph
.
This CL removes the unnecessary MLContext::CreateWebNNBuffer
method, refactors MLBuffer::ReadBufferImpl
method to create
the resolver inside and return the promise, refactors
MLContext::CreateWebNNGraphBuilder
to record the created
MLGraphBuilder
into MLContext
and return it.
Bug: 348904836, 354025380
Change-Id: Ia660fe2f109a089187237da9d6a0285247f19eb9
Cq-Include-Trybots: luci.chromium.try:win11-blink-rel
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5737474
Commit-Queue: Mingming1 Xu mingming1.xu@intel.com
Reviewed-by: Reilly Grant reillyg@chromium.org
Reviewed-by: ningxin hu ningxin.hu@intel.com
Reviewed-by: Rafael Cintron rafael.cintron@microsoft.com
Cr-Commit-Position: refs/heads/main@{#1338851}