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

Need reverse output sequence for backward direction of gru and lstm operator emulations #801

Closed
BruceDai opened this issue Jan 7, 2025 · 3 comments

Comments

@BruceDai
Copy link
Contributor

BruceDai commented Jan 7, 2025

Current lstm operator emulation computes the forward hidden sequence from t = 1 to T, and the backward hidden sequence
from t = T to 1.

While lstm operator of WebNN API Spec says "the third element is the 4-D output tensor of shape [steps, numDirections, batchSize, hiddenSize] containing every output from each time step in the temporal sequence", so we need reverse output sequence for backward direction of lstm operator emulation from [hb_T, ..., hb_1] to [hb_1, ..., hb_T].

I've firstly submitted a PR webmachinelearning/webnn-baseline#123 for preview.

@fdwr @huningxin PTAL, thanks!

/cc @philloooo @fujunwei

@philloooo
Copy link
Contributor

@BruceDai does the gru emulation logic need to be updated too?

      sequence =
        (sequence ? builder.concat([sequence, currentOutput], 0) :
                    currentOutput);

->

      sequence =
        (sequence ? builder.concat([currentOutput, sequence], 0) :
                    currentOutput);

?

@BruceDai
Copy link
Contributor Author

BruceDai commented Jan 8, 2025

@BruceDai does the gru emulation logic need to be updated too?

Yes. I'm working to update it. And the solution for gru should be similar to webmachinelearning/webnn-baseline#123.

@BruceDai BruceDai changed the title Need reverse output sequence for backward direction of lstm operator emulation Need reverse output sequence for backward direction of gru and lstm operator emulations Jan 14, 2025
@inexorabletash
Copy link
Member

Now that the PRs linked above have merged, I don't think there is any further work here. Please re-open if I'm incorrect.

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

3 participants