-
Notifications
You must be signed in to change notification settings - Fork 96
Added padding_idx=None option and new test cases for aten_embedding_bag #2549
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
Merged
+80
−31
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
6b232d9
added fixed function logic
crypto-a 40f487b
added test cases for aten_embedding_bag_padding_idx
crypto-a 294eca3
fix: resolve lint warnings and comparison issue
crypto-a 7192035
fix: clean up _embedding_bag_input_wrangler padding_idx check
crypto-a 6e41cfe
fix: fixed bugs and issues with test cases
crypto-a d2da96e
style: fixed linting issues in code
crypto-a 1f84cc7
Merge branch 'fix-2219' into main
crypto-a b8aae85
Merge pull request #1 from crypto-a/main
crypto-a 5f6156b
fix: resolve embedding_bag untyped ONNX outputs with explicit casts
crypto-a 4789d56
fix: removed redundant tests
crypto-a 9ba946e
rollback return types
crypto-a ca6db1a
fixed style issue
crypto-a d3f7a58
Merge branch 'main' into fix-2219
crypto-a File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -184,6 +184,25 @@ def xfail( | |
| # Modify this section ########################################################## | ||
|
|
||
|
|
||
| def _embedding_bag_input_wrangler( | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Final round of reivews: Is this necessary? I think it should accept a None input? |
||
| args: list[Any], kwargs: dict[str, Any] | ||
| ) -> tuple[list[Any], dict[str, Any]]: | ||
| # ONNX attributes cannot be None; omit padding_idx if it's None. | ||
| if "padding_idx" in kwargs: | ||
| padding_idx = kwargs.pop("padding_idx") | ||
| if padding_idx is not None: | ||
| kwargs["padding_idx"] = int(padding_idx) | ||
|
|
||
| # Ensure indices/offsets are int64 (positional: weight, indices, offsets, ...) | ||
| if len(args) >= 3: | ||
| if isinstance(args[1], torch.Tensor): | ||
| args[1] = args[1].to(torch.long) | ||
| if isinstance(args[2], torch.Tensor): | ||
| args[2] = args[2].to(torch.long) | ||
|
|
||
| return args, kwargs | ||
|
|
||
|
|
||
| def _amin_amax_input_wrangler( | ||
| args: list[Any], kwargs: dict[str, Any] | ||
| ) -> tuple[list[Any], dict[str, Any]]: | ||
|
|
@@ -908,12 +927,17 @@ def _where_input_wrangler( | |
| core_ops.aten_embedding_bag, | ||
| tolerance={torch.float32: (1e-4, 5e-4)}, | ||
| compare_shape_only_for_output=(1, 2, 3), | ||
| ).skip(dtypes=(torch.float16,), reason="fixme: results mismatch in torch nightly."), | ||
| input_wrangler=_embedding_bag_input_wrangler, | ||
| ).skip( | ||
| dtypes=(torch.float16,), | ||
| reason="fixme: results mismatch in torch nightly.", | ||
| ), | ||
| TorchLibOpInfo( | ||
| "ops.aten.embedding_bag.padding_idx", | ||
| core_ops.aten_embedding_bag_padding_idx, | ||
| tolerance={torch.float16: (1e-2, 1e-2)}, | ||
| compare_shape_only_for_output=(1, 2, 3), | ||
| input_wrangler=_embedding_bag_input_wrangler, | ||
| ), | ||
| TorchLibOpInfo( | ||
| "ops.aten.embedding_renorm", | ||
|
|
||
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I checked https://github.com/pytorch/pytorch/blob/8656dea039bd0a31952a6a9792566e70b07429dc/aten/src/ATen/native/native_functions.yaml#L2372-L2378 and found that embedding_bag does not have padding_idx as a parameter. I think you only need to update aten_embedding_bag_padding_idx