Skip to content

Support expand_dims#57116

Closed
asi1024 wants to merge 5 commits intopytorch:masterfrom
asi1024:expand_dims
Closed

Support expand_dims#57116
asi1024 wants to merge 5 commits intopytorch:masterfrom
asi1024:expand_dims

Conversation

@asi1024
Copy link
Copy Markdown
Contributor

@asi1024 asi1024 commented Apr 28, 2021

Fixes #56774

This PR implements torch.expand_dims for the compatibility with NumPy’s interface.
cc: @mruberry, @rgommers, @emcastillo and @kmaehashi

@asi1024 asi1024 requested a review from ezyang as a code owner April 28, 2021 10:10
@facebook-github-bot facebook-github-bot added cla signed oncall: jit Add this issue/PR to JIT oncall triage queue labels Apr 28, 2021
@facebook-github-bot
Copy link
Copy Markdown
Contributor

facebook-github-bot commented Apr 28, 2021

🔗 Helpful links

💊 CI failures summary and remediations

As of commit fde1880 (more details on the Dr. CI page):


  • 4/4 failures introduced in this PR

🕵️ 2 new failures recognized by patterns

The following CI failures do not appear to be due to upstream breakages:

See CircleCI build pytorch_linux_xenial_py3_6_gcc5_4_build (1/2)

Step: "(Optional) Merge target branch" (full log | diagnosis details | 🔁 rerun)

Automatic merge failed; fix conflicts and then commit the result.
CONFLICT (add/add): Merge conflict in .circleci/docker/ubuntu/Dockerfile
Auto-merging .circleci/docker/ubuntu/Dockerfile
CONFLICT (add/add): Merge conflict in .circleci/docker/ubuntu-cuda/Dockerfile
Auto-merging .circleci/docker/ubuntu-cuda/Dockerfile
CONFLICT (add/add): Merge conflict in .circleci/config.yml
Auto-merging .circleci/config.yml
CONFLICT (add/add): Merge conflict in .circleci/cimodel/data/pytorch_build_data.py
Auto-merging .circleci/cimodel/data/pytorch_build_data.py
CONFLICT (add/add): Merge conflict in .circleci/cimodel/data/binary_build_definitions.py
Auto-merging .circleci/cimodel/data/binary_build_definitions.py
Automatic merge failed; fix conflicts and then commit the result.


Exited with code exit status 1

See CircleCI build pytorch_xla_linux_bionic_py3_6_clang9_build (2/2)

Step: "(Optional) Merge target branch" (full log | diagnosis details | 🔁 rerun)

Automatic merge failed; fix conflicts and then commit the result.
CONFLICT (add/add): Merge conflict in .circleci/docker/ubuntu/Dockerfile
Auto-merging .circleci/docker/ubuntu/Dockerfile
CONFLICT (add/add): Merge conflict in .circleci/docker/ubuntu-cuda/Dockerfile
Auto-merging .circleci/docker/ubuntu-cuda/Dockerfile
CONFLICT (add/add): Merge conflict in .circleci/config.yml
Auto-merging .circleci/config.yml
CONFLICT (add/add): Merge conflict in .circleci/cimodel/data/pytorch_build_data.py
Auto-merging .circleci/cimodel/data/pytorch_build_data.py
CONFLICT (add/add): Merge conflict in .circleci/cimodel/data/binary_build_definitions.py
Auto-merging .circleci/cimodel/data/binary_build_definitions.py
Automatic merge failed; fix conflicts and then commit the result.


Exited with code exit status 1


2 failures not recognized by patterns:

Job Step Action
CircleCI Build Error Config Processing Error (Don't rerun) 🔁 rerun
GitHub Actions clang-format / clang-format Run clang-format 🔁 rerun

This comment was automatically generated by Dr. CI (expand for details).Follow this link to opt-out of these comments for your Pull Requests.

Please report bugs/suggestions to the (internal) Dr. CI Users group.

Click here to manually regenerate this comment.

@ezyang ezyang removed their request for review April 28, 2021 14:46
Copy link
Copy Markdown
Collaborator

@mruberry mruberry left a comment

Choose a reason for hiding this comment

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

Cool! Thanks @asi1024! It's nice to see how much easier adding an alias has become, at least for simple cases.

I have just one question about whether we should alias the inplace version of the op, too. Might as well?

cc @ngimel

CompositeExplicitAutograd: unsqueeze_

# expand_dims, alias of unsqueeze
- func: expand_dims(Tensor(a) self, int dim) -> Tensor(a)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

What's your thinking on aliasing the inplace version of the operation, unsqueeze_, as well?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The in-place version is out of Array API standard, so it does not necessarily need to be supported, but I think it's OK to support it. Done in 83a21ff!

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks great; I made one small tweak to the inplace method docs. I think this is now ready to merge!

@facebook-github-bot
Copy link
Copy Markdown
Contributor

@mruberry has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@mruberry
Copy link
Copy Markdown
Collaborator

mruberry commented May 2, 2021

Hey @asi1024, just fyi I'm going to need to follow-up on one internal hitch with this PR, so it may not land immediately

@asi1024
Copy link
Copy Markdown
Contributor Author

asi1024 commented May 6, 2021

@mruberry Thank you! Please let me know if there is any updates 😃

@mruberry
Copy link
Copy Markdown
Collaborator

mruberry commented May 6, 2021

@mruberry Thank you! Please let me know if there is any updates 😃

I will; we're preparing for the PyTorch 1.9 release now, however, so it might take some time to follow-up, unfortunately.

@pmeier pmeier added the module: python array api Issues related to the Python Array API label Jun 10, 2021
@asi1024
Copy link
Copy Markdown
Contributor Author

asi1024 commented Aug 4, 2021

@mruberry Kindly ping 😃

@mruberry
Copy link
Copy Markdown
Collaborator

@mruberry Kindly ping 😃

Thanks for the ping @asi1024. I'm hoping to follow-up on this soon.

@mruberry
Copy link
Copy Markdown
Collaborator

mruberry commented Sep 7, 2021

@mruberry Kindly ping 😃

Thanks for the ping @asi1024. I'm hoping to follow-up on this soon.

Still haven't forgotten about this. Just trying to work around the PyTorch 1.10 branch cut.

@rgommers
Copy link
Copy Markdown
Collaborator

Hey @asi1024, just fyi I'm going to need to follow-up on one internal hitch with this PR, so it may not land immediately

Details, from #58742 (comment):
Adding the alias would be great! expand_dims is on hold just because a dependency of PyTorch also defines an expand_dims function in a way where they can't build with PyTorch if it's added, and we're working with them to resolve this issue. This complication is atypical and unlikely to affect other aliases.

I assume this is a non-public package. Will it be possible to get them to fix it before the 1.11 release @mruberry?

@mruberry
Copy link
Copy Markdown
Collaborator

Hey @asi1024, just fyi I'm going to need to follow-up on one internal hitch with this PR, so it may not land immediately

Details, from #58742 (comment): Adding the alias would be great! expand_dims is on hold just because a dependency of PyTorch also defines an expand_dims function in a way where they can't build with PyTorch if it's added, and we're working with them to resolve this issue. This complication is atypical and unlikely to affect other aliases.

I assume this is a non-public package. Will it be possible to get them to fix it before the 1.11 release @mruberry?

Hard to know the timeline but I certainly hope so. I'm reviewing these internal failures today so hope to know more soon.

@pytorchbot
Copy link
Copy Markdown
Collaborator

Looks like this PR hasn't been updated in a while so we're going to go ahead and mark this as Stale.
Feel free to remove the Stale label if you feel this was a mistake.
If you are unable to remove the Stale label please contact a maintainer in order to do so.
Stale pull requests will automatically be closed 30 days after being marked Stale

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla signed module: python array api Issues related to the Python Array API oncall: jit Add this issue/PR to JIT oncall triage queue open source Stale

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support expand_dims

6 participants