8000 torch.Tensor.repeat is divergent from np.repeat · Issue #50013 · pytorch/pytorch · GitHub
[go: up one dir, main page]

Skip to content

torch.Tensor.repeat is divergent from np.repeat #50013

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

Open
1 of 5 tasks
mruberry opened this issue Jan 3, 2021 · 3 comments
Open
1 of 5 tasks

torch.Tensor.repeat is divergent from np.repeat #50013

mruberry opened this issue Jan 3, 2021 · 3 comments
Labels
high priority module: deprecation module: numpy Related to numpy support, and also numpy compatibility of our operators triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module

Comments

@mruberry
Copy link
Collaborator
mruberry commented Jan 3, 2021

torch.Tensor.repeat, as its documentation notes, is divergent from np.repeat but similar to np.tile. Now that torch.tile is implemented, we can deprecate torch.repeat in favor of torch.tile by doing the following:

  • deprecate torch.Tensor.repeat in favor of torch.tile for a release
    • verify torch.tile implements the same behavior as np.tile and torch.repeat (see discussion and linked PRs)
    • audit and update internal callsites so PyTorch doesn't throw warnings by default
  • remove torch.repeat for a release (possibly requires writing an upgrade for serialized torchscript)
  • restore torch.repeat analogous to np.repeat

np.repeat is a top 50 NumPy function, and torch.Tensor.repeat (note that torch.repeat does not exist) is popular with hundreds of uses within Facebook.

cc @ezyang @gchanan @zou3519 @bdhirsh @jbschlosser @mruberry @rgommers @heitorschueroff

@mruberry mruberry added high priority module: numpy Related to numpy support, and also numpy compatibility of our operators module: deprecation labels Jan 3, 2021
@mruberry
Copy link
Collaborator Author
mruberry commented Jan 4, 2021

@ezyang suggests adding an example of how old code using this behavior would be modified to use this new behavior.

What would the release notes be?

@mruberry mruberry added triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module and removed triage review labels Jan 4, 2021
@Hitansh159
Copy link

yes, currently tile and repeat do the same thing the only difference is that repeat will not except the input tuple of lesser dimensions then tensor. Tile overcome this by assuming that user want to extend the dimensions to initial if input tuple is of lesser dimension.

also Tile is implemented with help of repeat function.

I want to contribute but the issue being that I am unable to build at my side.
I am trying since last 24 hrs.
if you can guide me with it it would be really helpful.
I tried searching for it I found that it will need VS 2019 MSCV toolkit I downloaded that and tried build but the processes is going on since more than 7 hrs.
I don't know what is the issue.

@mruberry
Copy link
Collaborator Author
mruberry commented Jan 6, 2021

Hi @Hitansh159, thanks for your interest, but this issue is currently only for discussion. We have not decided to do any work here, yet. It'd be great to have you contribute to PyTorch, though. You may want to look at this query of issues for something to start with:

https://github.com/pytorch/pytorch/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22

and check out our contribution guide here: https://pytorch.org/docs/stable/community/contribution_guide.html.

I'm sorry that you're having a problem building PyTorch. I'm not familiar with building on Windows, but if you're experiencing an issue then you may want to look at the PyTorch Forums (https://discuss.pytorch.org/) or ask a new question there, or if you believe you're encountering a bug in PyTorch on Windows then you can file an issue here describing the failure you're seeing.

facebook-github-bot pushed a commit that referenced this issue Jan 19, 2021
…50199)

Summary:
Reference: #50013

Pull Request resolved: #50199

Reviewed By: ngimel

Differential Revision: D25949791

Pulled By: mruberry

fbshipit-source-id: 10eaf2d749fac8c08847f50461e72ad1c75c61e3
@rgommers rgommers changed the title torch.repeat is divergent from np.repeat torch.Tensor.repeat is divergent from np.repeat Jul 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
high priority module: deprecation module: numpy Related to numpy support, and also numpy compatibility of our operators triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module
Projects
None yet
Development

No branches or pull requests

2 participants
0