Skip to content

feat(atenlib): add op(index put) #522

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
merged 20 commits into from
Mar 16, 2023
Merged

feat(atenlib): add op(index put) #522

merged 20 commits into from
Mar 16, 2023

Conversation

xiaowuhu
Copy link
Contributor

No description provided.

@codecov
Copy link

codecov bot commented Mar 14, 2023

Codecov Report

Merging #522 (b0e82c1) into main (bff0b52) will increase coverage by 0.07%.
The diff coverage is 86.11%.

@@            Coverage Diff             @@
##             main     #522      +/-   ##
==========================================
+ Coverage   73.75%   73.82%   +0.07%     
==========================================
  Files         109      109              
  Lines       10882    10917      +35     
  Branches     1131     1135       +4     
==========================================
+ Hits         8026     8060      +34     
+ Misses       2551     2550       -1     
- Partials      305      307       +2     
Impacted Files Coverage Δ
onnxscript/function_libs/torch_aten/ops/core.py 72.15% <85.71%> (+0.29%) ⬆️
...s/function_libs/torch_aten/ops_correctness_test.py 90.35% <100.00%> (+0.02%) ⬆️

... and 1 file with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@xiaowuhu xiaowuhu mentioned this pull request Mar 14, 2023
@justinchuby
Copy link
Collaborator

LMK if you are able to fix the test errors? I can take a look tomorrow too

@xiaowuhu
Copy link
Contributor Author

xiaowuhu commented Mar 15, 2023

LMK if you are able to fix the test errors? I can take a look tomorrow too

Yes, please. It is in graph_building.py.

"""index_put(Tensor self, Tensor?[] indices, Tensor values, bool accumulate=False) -> Tensor"""

raise NotImplementedError()
index = op.SequenceAt(indices, 0) # assume indices only have 1 element
Copy link
Collaborator

Choose a reason for hiding this comment

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

I am bit unclear about the assumption above. Is this just for now? Is the input type expected to be changed to INT64 ?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Looks like indices is a list of 1d tensors, so INT64 may not do it?

Copy link
Collaborator

Choose a reason for hiding this comment

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

On this line, was there a reason we assume indices only has one element?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

From the test case, all the indices have only one element. If it contains multiple elements, we need to use for/while to do the logic.
But for this aten op, the multiple elements can be combined to one element, for example, indices=[[0,1], [2,3]], can be combined to indices=[[0,1,2,3],].

Copy link
Collaborator

@justinchuby justinchuby Mar 16, 2023

Choose a reason for hiding this comment

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

Should we do a sequenceConcat or something like that?

Copy link
Contributor Author

@xiaowuhu xiaowuhu Mar 16, 2023

Choose a reason for hiding this comment

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

I tried in Torch, actually it cannot work like this:
torch.index_put( self=tensor(5x5), indices=(tensor([0]), tensor([1]),), values=tensor(2x5))
so we don't know how to use more than one element in indices tuple.

@justinchuby
Copy link
Collaborator

Graph builder fixed in #528

@justinchuby justinchuby merged commit bb129e6 into main Mar 16, 2023
@justinchuby justinchuby deleted the xiaowu/addOp(index_put) branch March 16, 2023 13:28
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.

3 participants