Skip to content
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

[optimizer] Collapse Slices #1758

Closed
justinchuby opened this issue Jul 26, 2024 · 6 comments · Fixed by #1925
Closed

[optimizer] Collapse Slices #1758

justinchuby opened this issue Jul 26, 2024 · 6 comments · Fixed by #1925
Assignees
Labels
contribution welcome We welcome code contributions for this topic: optimizer

Comments

@justinchuby
Copy link
Collaborator

image

The optimizer currently does not collapse these slices, but there has to be a way to remove them I think?

@gramalingam
Copy link
Collaborator

Yes, it can be optimized.

Do you know where it is coming from? Just wondering if some change in source onnxscript function is also possible.

@justinchuby
Copy link
Collaborator Author

justinchuby commented Aug 1, 2024

This is coming from the aten slice ops when there are indexed assignments I believe. So they are from pytorch.

@justinchuby justinchuby added the contribution welcome We welcome code contributions for this label Aug 8, 2024
@titaiwangms
Copy link
Contributor

Found this in a timm model called ghostnet_100, which in onnx_dynamo, it generates 3 slices, while in torchscript, we only use 1. This can be repro on benchmark. cc @xadupre

@titaiwangms
Copy link
Contributor

titaiwangms commented Oct 29, 2024

The right side is dynamo, and the other side is torchscript.

Image

@titaiwangms
Copy link
Contributor

It also happens to slice_scatter as well.

Image

@titaiwangms titaiwangms self-assigned this Oct 29, 2024
@titaiwangms
Copy link
Contributor

Investigated more and found these op.Slice should probably be no op, since it's not slicing anything based on the output shape..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contribution welcome We welcome code contributions for this topic: optimizer
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants