-
Notifications
You must be signed in to change notification settings - Fork 59
Description
According to the steps of the MLNamedArrayBufferViews transfer algorithm in WebNN spec, for each ArrayBufferView, it transfers the underlying ArrayBuffer of the view.
However, the ArrayBuffer transferring algorithm performs DetachArrayBuffer(arrayBuffer [, key]), defined by ECMAScript spec, that would throw a "TypeError" exception if the ArrayBuffer.[[ArrayBufferDetachKey]] is not key (key is set to undefined if not present). Because WebNN doesn't set key, it means the ArrayBuffer whose [[ArrayBufferDetachKey]] is set to a value other than undefined would fail, such as the value of WebAssembly.Memory's buffer attribute. For another example, the ArrayBuffer returned by WebGPU GPUBuffer::getMappedRange() who sets [[ArrayBufferDetachKey]] to "WebGPUBufferMapping".
WebNN spec should define how to handle this exception and what's the impact to the MLNamedArrayBufferViews. In particular, if the exception occurs when transferring the view in the middle of the loop, what should the implementation deal with the already transferred views, the failing view and the remaining views in the MLNamedArrayBufferViews.
This issue was raised by @wacky6 in WebNN Chromium CL review. Thanks Jiewei!