webmachinelearning / webnn

🧠 Web Neural Network API
https://www.w3.org/TR/webnn/
Other
397 stars 48 forks source link

Copy input ArrayBuffers #700

Closed a-sully closed 3 weeks ago

a-sully commented 5 months ago

Fixes #566


Preview | Diff

inexorabletash commented 4 months ago

My reading of "get a copy of the bytes" is that if the buffer is detached then an empty byte sequence is returned but we don't explicitly throw.

Per #351 (and my #723) we want to error if transferring a detached buffer (which will still be used for output buffers). Should we error for detached input buffers too?

I think that just requires adding If |view| is [=BufferSource/detached=], then throw a {{TypeError}}. to the steps.

(I think we'd still end up throwing in most cases since the subsequent size check will fail. Although if allow 0 size dimensions (#391) there would be a weird case where it might slip through that check. Harmless, but weird?)

a-sully commented 3 weeks ago

Abandoning since compute() is being deprecated in favor of dispatch(). See https://github.com/webmachinelearning/webnn/blob/main/mltensor-explainer.md#compute-vs-dispatch

All the logic regarding buffer transferring can be removed alongside compute(), which makes this CL irrelevant