Skip to content

Add Op (aten::masked_scatter) | feat (torchlib) #2112

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

Conversation

titaiwangms
Copy link
Contributor

@titaiwangms titaiwangms commented Mar 17, 2025

@titaiwangms titaiwangms added the module: torchlib Related to the torch/aten function lib in development label Mar 17, 2025
@titaiwangms titaiwangms requested a review from justinchuby March 17, 2025 23:46
Copy link

codecov bot commented Mar 17, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 72.98%. Comparing base (6be9d18) to head (7956be8).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2112      +/-   ##
==========================================
+ Coverage   72.97%   72.98%   +0.01%     
==========================================
  Files         216      216              
  Lines       28918    28928      +10     
  Branches     3425     3426       +1     
==========================================
+ Hits        21103    21114      +11     
+ Misses       6663     6662       -1     
  Partials     1152     1152              

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

ends = op.Gather(op.Shape(index), op.Constant(value_ints=[0]), axis=0)
source = op.Slice(source, starts, ends, axes)

return op.ScatterND(self, index, source)
Copy link
Member

Choose a reason for hiding this comment

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

What about self * (1-mask) + mask * source or mask * (source - self) + self ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The implementation is following torchscript converter. If we find it's too slow, we can change it later. I am unblocking Gemma3 for now.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe create a follow up issue for tracking?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@titaiwangms titaiwangms enabled auto-merge (squash) March 18, 2025 15:55
@titaiwangms titaiwangms merged commit 57dbc70 into microsoft:main Mar 18, 2025
26 of 29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module: torchlib Related to the torch/aten function lib in development
Projects
Development

Successfully merging this pull request may close these issues.

3 participants