You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, currently WebNN doesn't support control flow operations like if and while, so I am creating this issue to open the discussion on whether WebNN should support control flows.
We have a where which could be used similar to if, but it requires both branches to be computed, then toss away the branch we don't need, this is much less efficient to use it as if.
I don't see anything in current spec that can be used for while.
Use case:
For transformer like models, for the decoder part, it's essentially a while loop that keep feeding the output token back to the decoder, until it reaches the end token. If WebNN doesn't have the while op, this loop will exist on the javascript side, meaning that you will have this round trip and synchronization to client side JS for each iteration, much less efficient then encapsulating the whole logic into a single WebNN computation.
Hi, currently WebNN doesn't support control flow operations like
if
andwhile
, so I am creating this issue to open the discussion on whether WebNN should support control flows.We have a where which could be used similar to
if
, but it requires both branches to be computed, then toss away the branch we don't need, this is much less efficient to use it asif
.I don't see anything in current spec that can be used for
while
.Use case:
For transformer like models, for the decoder part, it's essentially a while loop that keep feeding the output token back to the decoder, until it reaches the end token. If WebNN doesn't have the
while
op, this loop will exist on the javascript side, meaning that you will have this round trip and synchronization to client side JS for each iteration, much less efficient then encapsulating the whole logic into a single WebNN computation.Framework support:
ONNX: loop, if
tensorflow: while_loop, cond
Thoughts?
The text was updated successfully, but these errors were encountered: