Skip to content

Conversation

crypto-a
Copy link

@crypto-a crypto-a commented Sep 8, 2025

Fix Issues #2219, #2385 and the first part of #2489

This commit adds new test cases and the necessary implementation changes to correctly support the padding_idx=None option in the aten_embedding_bag operator. This aligns the ONNX Script operator with PyTorch's native behavior and expands test coverage for this feature.

Key Changes:

  • core.py: The aten_embedding_bag_padding_idx function has been updated to handle padding_idx=None. This new code routes the operation to the standard aten_embedding_bag implementation when no padding indices are specified.
  • extra_opinfo.py: Two new OpInfo definitions, test_embedding_bag_with_padding_idx_none and test_embedding_bag_with_padding_idx_int, have been added to the OP_DB list. These provide input samples to test the new and existing padding_idx functionality.
  • ops_test_data.py: The TESTED_TORCHLIB_OPS tuple has been updated to include the new tests, ensuring they are discovered and executed by the test runner.

@crypto-a
Copy link
Author

crypto-a commented Sep 8, 2025

@microsoft-github-policy-service agree

Copy link

codecov bot commented Sep 9, 2025

Codecov Report

❌ Patch coverage is 50.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 70.33%. Comparing base (b2d94fe) to head (7192035).
⚠️ Report is 20 commits behind head on main.

Files with missing lines Patch % Lines
onnxscript/function_libs/torch_lib/ops/core.py 50.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2549      +/-   ##
==========================================
+ Coverage   70.00%   70.33%   +0.33%     
==========================================
  Files         215      218       +3     
  Lines       25992    26430     +438     
  Branches     2606     2647      +41     
==========================================
+ Hits        18196    18590     +394     
- Misses       6896     6936      +40     
- Partials      900      904       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@crypto-a
Copy link
Author

@justinchuby I can handle the linting issues, but I’m confused about the other CI failures — could you help?

opinfo_core.OpInfo(
"test_embedding_bag_with_padding_idx_int",
op=torch.nn.functional.embedding_bag,
dtypes=(torch.float32,),
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it’s this line: you need the all_float_types() etc. construct for specifying supported dtypes. See other existing op infos for reference.

Copy link
Author

Choose a reason for hiding this comment

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

changed it to common_dtype.floating_types_and_half(), similar to other test cases

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

Successfully merging this pull request may close these issues.

2 participants