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

change "repeat" to "repeat_interleave" and "tile" uniformly #827

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

Songyuanwei
Copy link
Collaborator

@Songyuanwei Songyuanwei commented Jan 16, 2025

What does this PR do?

Fixes # (issue)

Since mindspore.Tensor.repeat is different from the torch.Tensor.repeat for now, we check the original torch source code again and replace the mindspore.Tensor.repeat with mindspore.Tensor.repeat_interleave or mindspore.Tensor.tile according to the following alignment rules:
torch.Tensor.repeat -> mindspore.Tensor.tile
torch.Tensor.repeat_interleave -> mindspore.Tensor.repeat_interleave

Before submitting

  • This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
  • Did you read the contributor guideline?
  • Did you make sure to update the documentation with your changes? E.g. record bug fixes or new features in What's New. Here are the
    documentation guidelines
  • Did you build and run the code without any errors?
  • Did you report the running environment (NPU type/MS version) and performance in the doc? (better record it for data loading, model inference, or training tasks)
  • Did you write any new necessary tests?

Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

@xxx

@Songyuanwei Songyuanwei changed the title change "repeat" to "repeat_interleave" uniformly change "repeat" to "repeat_interleave" and "tile" uniformly Jan 20, 2025
songyuanwei added 2 commits January 22, 2025 17:44
@@ -49,7 +49,7 @@ def transform_conditional_images(image_paths, H, W, random_crop=True, normalize=
if normalize:

def image_norm(image):
image = image.mean(dim=0, keepdim=True).repeat(3, 1, 1)
image = image.mean(axis=0, keepdims=True).repeat(3, axis=0)
Copy link
Collaborator

Choose a reason for hiding this comment

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

repeat(3, 1, 1) -> tile(3, 1, 1)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

这个是numpy的mean和repeat,这里做了下参数修改。torch的repeat(3,1,1)和numpy的repeat(3,axis=0)对于(1, H, W)的image的生成结果是一样的。

@vigo999
Copy link
Contributor

vigo999 commented Feb 7, 2025

there is nothing under "What does this PR do".
can you explain more about this PR.

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.

6 participants