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

[DML EP] Attention Kernel #13371

Merged
merged 14 commits into from Oct 24, 2022
Merged

[DML EP] Attention Kernel #13371

merged 14 commits into from Oct 24, 2022

Conversation

sumitsays
Copy link
Contributor

@sumitsays sumitsays commented Oct 19, 2022

Description

DML EP kernel for com.microsoft.attention operator. It has been implemented via DML_Graph. References for this implementation:

  1. Hugging Face Attention for BERT
  2. Chapter 3 of book Orielly: Natural Language Processing with Transformers, Revised Edition

This PR also

  • includes a very tiny fix for QLinearSigmoid kernel, which is storing the temporary object into a named variable.
  • enables 4 L2 transformers LayerNorm, Gelu, MatMulScale, Attention.

Motivation and Context

  • Why is this change required? What problem does it solve?
    One of the main operators used in Transformer-based model. It contributes to the overall perf of DML EP for Transformer models.
  • If it fixes an open issue, please link to the issue here. N/A

@sumitsays sumitsays marked this pull request as ready for review October 20, 2022 00:55
Copy link
Contributor

@fdwr fdwr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@sumitsays sumitsays merged commit 24818cf into main Oct 24, 2022
@sumitsays sumitsays deleted the user/sumita/attention branch October 24, 2022 21:32
linnealovespie pushed a commit that referenced this pull request Oct 28, 2022
### Description
DML EP kernel for com.microsoft.attention operator. It has been
implemented via DML_Graph. References for this implementation:

1. [Hugging Face Attention for
BERT](https://github.com/huggingface/transformers/blob/310340d0d01929715b30863ee6f633974d75da16/src/transformers/models/bert/modeling_bert.py#L245-L284)
2. Chapter 3 of book Orielly: Natural Language Processing with
Transformers, Revised Edition

This PR also

- includes a very tiny fix for QLinearSigmoid kernel, which is storing
the temporary object into a named variable.
- enables 4 L2 transformers LayerNorm, Gelu, MatMulScale, Attention.



### Motivation and Context
- Why is this change required? What problem does it solve? 
One of the main operators used in Transformer-based model. It
contributes to the overall perf of DML EP for Transformer models.
- If it fixes an open issue, please link to the issue here. N/A

Co-authored-by: Sumit Agarwal <sumitagarwal@microsoft.com>
Co-authored-by: Dwayne Robinson <dwayner@microsoft.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants