Skip to content

feat(atenlib): add op(chunk) #511

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 8 commits into from
Mar 11, 2023
Merged

feat(atenlib): add op(chunk) #511

merged 8 commits into from
Mar 11, 2023

Conversation

xiaowuhu
Copy link
Contributor

@xiaowuhu xiaowuhu commented Mar 9, 2023

No description provided.

@codecov
Copy link

codecov bot commented Mar 9, 2023

Codecov Report

Merging #511 (1bc35fa) into main (aa93917) will increase coverage by 0.06%.
The diff coverage is 82.35%.

@@            Coverage Diff             @@
##             main     #511      +/-   ##
==========================================
+ Coverage   72.72%   72.79%   +0.06%     
==========================================
  Files         109      109              
  Lines       10689    10703      +14     
  Branches     1102     1104       +2     
==========================================
+ Hits         7774     7791      +17     
+ Misses       2611     2607       -4     
- Partials      304      305       +1     
Impacted Files Coverage Δ
...s/function_libs/torch_aten/ops_correctness_test.py 87.93% <ø> (ø)
onnxscript/evaluator.py 85.83% <25.00%> (-0.26%) ⬇️
onnxscript/function_libs/torch_aten/ops/core.py 71.02% <100.00%> (+0.22%) ⬆️

... 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 9, 2023
@xiaowuhu xiaowuhu requested review from fatcat-z and justinchuby March 9, 2023 09:18
Copy link
Collaborator

@justinchuby justinchuby left a comment

Choose a reason for hiding this comment

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

LGTM! I would wait for Rama to review the parts in the evaluator

@justinchuby justinchuby requested a review from gramalingam March 9, 2023 15:31
@xiaowuhu
Copy link
Contributor Author

LGTM! I would wait for Rama to review the parts in the evaluator

@gramalingam pls help to review. The original implementation doesn't return valid output numbers and based on opset17(split).

num_per_chunk = op.Div(dim_size, chunks)
if op.Mod(dim_size, chunks) > 0: # type: ignore[operator]
# cannot be divisible, then num_in_chunk + 1
num_per_chunk = op.Add(num_per_chunk, 1)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I wonder if using Where will be more efficient or not

Copy link
Collaborator

Choose a reason for hiding this comment

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

Something like op.Where(op.Mod(dim_size, chunks) > 0, 1, 0) + num_per_chunk

Copy link
Collaborator

Choose a reason for hiding this comment

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

Even better: op.Cast(op.Mod(dim_size, chunks) > 0, to=INT64.value) + num_per_chunk

Copy link
Collaborator

Choose a reason for hiding this comment

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

The take away for me was If tends to be slow and should be replaced with other things when possible.

@justinchuby justinchuby requested a review from BowenBao March 10, 2023 01:10
@justinchuby
Copy link
Collaborator

Also cc @BowenBao for the logic

@justinchuby justinchuby added the module: torchlib Related to the torch/aten function lib in development label Mar 10, 2023
@justinchuby
Copy link
Collaborator

We can merge if there's no movement

@xiaowuhu xiaowuhu merged commit a8a878e into main Mar 11, 2023
@xiaowuhu xiaowuhu deleted the xiaowu/addOp(chunk) branch March 11, 2023 12:51
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
None yet
Development

Successfully merging this pull request may close these issues.

2 participants