Skip to content
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

Control flow operations: if, while #559

Open
philloooo opened this issue Feb 6, 2024 · 0 comments
Open

Control flow operations: if, while #559

philloooo opened this issue Feb 6, 2024 · 0 comments

Comments

@philloooo
Copy link
Contributor

philloooo commented Feb 6, 2024

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.

Framework support:
ONNX: loop, if
tensorflow: while_loop, cond

Thoughts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants