Skip to content

Need to define error handling of MLNamedArrayBufferViews transfer algorithm #351

@huningxin

Description

@huningxin

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!

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions