-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MLBuffer destruction timeline #716
Comments
I'm in favor of Option 1. This was the original proposal intent #542:
|
In the current Chromium prototype, the promise is never resolved nor rejected, because I guess
I suppose this is the typical usage. |
Updated #543 with additional clarification on content/script timeline: destroy() must reject pending readBuffer promises. |
The updated proposal defines what happens to the promises returned by |
Thanks for raising the question, Reilly. I don't believe its possible to stop or cancel GPUs from executing in-flight commands without resetting the device. If a dispatch is pending (or still running on-device) then we can allow it to complete which should (on the device timeline) safely release any destroyed buffers used as input/output. |
In that case I'm not sure of the value of causing |
I don't feel strongly either way. However, I think it's atypical to call destroy() without first waiting on readBuffer(). Therefore, I'm okay with disallowing it and rejecting the current approach. |
Thinking about this more with the additional context of |
Could we have MLBuffer operations be defined across two timelines: script and device/queue. Then calling destroy() would reject pending promises and as its last step, issue the release operation for the device/queue timeline, as its first step. MLContext.destroy() could effectively call MLBuffer.destroy()... But this leads me to wonder, why are MLGraph(s) not destroyable too? Like |
Yes, I think explicitly splitting the timelines in the method's algorithm will make this clear for developers and implementers.
+1 to adding |
While prototyping an implementation of the
MLBuffer
interface for Chromium's TFLite-based WebNN backend I've encountered a question: What should happen if a developer executes the following code?As currently implemented
promise
will never be resolved. This is likely undesirable. We probably desire one of the following behaviors:promise
resolves with the contents of the buffer. More generally, the buffer is not destroyed until all pending operations referencing it are completed.promise
rejects (probably with anAbortError
orInvalidStateError
). More generally, any incomplete operation referencing the buffer is aborted (if possible).Option 1 is consistent with the idea that
readBuffer()
,writeBuffer()
anddispatch()
all queue tasks to run on a "timeline" separate from JavaScript execution.destroy()
would be one more such method. Option 2 seems useful for quickly releasing resources, but means the developer must take care to only calldestroy()
when they are truly done with the buffer (e.g. after awaiting thePromise
returned byreadBuffer()
).The text was updated successfully, but these errors were encountered: