feat: support embedding_bag converter (1D input)#2395
Merged
zewenli98 merged 3 commits intopytorch:mainfrom Oct 25, 2023
Merged
feat: support embedding_bag converter (1D input)#2395zewenli98 merged 3 commits intopytorch:mainfrom
zewenli98 merged 3 commits intopytorch:mainfrom
Conversation
gs-olive
reviewed
Oct 16, 2023
Contributor
gs-olive
left a comment
There was a problem hiding this comment.
See comments for suggestions on improved type enforcement. It seems for this specific case, some operators have args[2] as a proper input, so it might be challenging to convert more generally with this numpy restriction.
Collaborator
Author
|
Thanks for the review. The issues above have been addressed! |
gs-olive
reviewed
Oct 18, 2023
gs-olive
approved these changes
Oct 20, 2023
Contributor
gs-olive
left a comment
There was a problem hiding this comment.
Looks good to me, pending CI!
7 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Support embedding_bag converter. Currently, only 1D input is supported.
schema: https://github.com/pytorch/pytorch/blob/bdecdfd202df3fa25fd9998070fd19fee4b14971/aten/src/ATen/native/native_functions.yaml#L2251
pytorch doc: https://pytorch.org/docs/stable/generated/torch.nn.functional.embedding_bag.html#torch-nn-functional-embedding-bag
Note:
offsetsis only used when input is 1D. If input is 2D of shape (B, N), it will be treated as B bags (sequences) each of fixed length N, and this will return B values aggregated in a way depending on the mode.offsetsis ignored and required to be None in this case. However, according to the schema,offsetsis required for input with any dimensions. There's no place describing how it works. There's a discussion in pytorch repooffsetsto be ndarray or torch tensor because we need to access data in it, butoffsetscould beITensorin some cases, which cannot be accessed.Fixes #2345
Type of change
Checklist: