Skip to content

Conversation

@cyyever
Copy link
Collaborator

@cyyever cyyever commented Dec 19, 2024

This PR simplifies std::copy_n calls in CopyKernel and IndexKernel. std::copy_n is used to create a data pointer array from the input data pointers. However, more careful review reveals that the dest pointers are actually aliases of the original pointers. So we can removes the pointer manipulations.

cc @jgong5 @mingfeima @XiaobingSuper @sanchitintel @ashokei @jingxu10 @jerryzh168 @aditew01

@pytorch-bot
Copy link

pytorch-bot bot commented Dec 19, 2024

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/143544

Note: Links to docs will display an error until the docs builds have been completed.

✅ No Failures

As of commit f58e796 with merge base 3eddf04 (image):
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@pytorch-bot pytorch-bot bot added ciflow/inductor module: cpu CPU specific problem (e.g., perf, algorithm) labels Dec 19, 2024
@cyyever
Copy link
Collaborator Author

cyyever commented Dec 19, 2024

@pytorchbot label "topic: not user facing"

@pytorch-bot pytorch-bot bot added the topic: not user facing topic category label Dec 19, 2024
@cyyever cyyever marked this pull request as draft December 19, 2024 02:31
@cyyever cyyever changed the title [2/N] Avoid const_cast Avoid std::copy_n Feb 2, 2025
@cyyever
Copy link
Collaborator Author

cyyever commented Feb 2, 2025

@pytorchbot rebase

@pytorchmergebot
Copy link
Collaborator

@pytorchbot started a rebase job onto refs/remotes/origin/viable/strict. Check the current status here

@pytorchmergebot
Copy link
Collaborator

Successfully rebased const_cast2 onto refs/remotes/origin/viable/strict, please pull locally before adding more changes (for example, via git checkout const_cast2 && git pull --rebase)

@cyyever cyyever marked this pull request as ready for review February 2, 2025 04:25
@cyyever cyyever requested a review from Skylion007 February 2, 2025 09:58
@mikaylagawarecki mikaylagawarecki added the triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module label Feb 7, 2025
@github-actions github-actions bot added the Stale label Apr 8, 2025
@github-actions github-actions bot closed this May 8, 2025
@cyyever cyyever reopened this Oct 20, 2025
@pytorch pytorch deleted a comment from github-actions bot Oct 20, 2025
@cyyever cyyever changed the title Avoid std::copy_n Avoid std::copy_n in CopyKernel and IndexKernel Oct 20, 2025
@cyyever
Copy link
Collaborator Author

cyyever commented Oct 20, 2025

@pytorchbot rebase -b main

@cyyever cyyever requested review from CaoE, albanD and ezyang October 20, 2025 02:51
@pytorchmergebot
Copy link
Collaborator

@pytorchbot started a rebase job onto refs/remotes/origin/main. Check the current status here

@pytorchmergebot
Copy link
Collaborator

Successfully rebased const_cast2 onto refs/remotes/origin/main, please pull locally before adding more changes (for example, via git checkout const_cast2 && git pull --rebase)

@ezyang ezyang removed their request for review October 21, 2025 14:46
Copy link
Collaborator

@albanD albanD left a comment

Choose a reason for hiding this comment

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

I'm not familiar with this code. But I'm surprised these would just be dead code we can just remove?
Would you be able to give some details for each change on what they're doing and why it's ok to do them?

@cyyever
Copy link
Collaborator Author

cyyever commented Oct 22, 2025

@albanD Yes, they are redundant code, I have added some more descriptions.

@cyyever cyyever requested a review from albanD October 27, 2025 02:13
@Skylion007
Copy link
Collaborator

Is the test failure real?

@cyyever
Copy link
Collaborator Author

cyyever commented Nov 3, 2025

@pytorchbot rebase

@pytorchmergebot
Copy link
Collaborator

@pytorchbot started a rebase job onto refs/remotes/origin/viable/strict. Check the current status here

@pytorchmergebot
Copy link
Collaborator

Successfully rebased const_cast2 onto refs/remotes/origin/viable/strict, please pull locally before adding more changes (for example, via git checkout const_cast2 && git pull --rebase)

@cyyever cyyever added the ciflow/trunk Trigger trunk jobs on your pull request label Nov 3, 2025
@cyyever
Copy link
Collaborator Author

cyyever commented Nov 3, 2025

Is the test failure real?

No, it was flaky.

Copy link
Collaborator

@albanD albanD left a comment

Choose a reason for hiding this comment

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

Very nice simplification, thanks!

@albanD
Copy link
Collaborator

albanD commented Nov 3, 2025

@pytorchbot merge

@pytorchmergebot
Copy link
Collaborator

Merge started

Your change will be merged once all checks pass (ETA 0-4 Hours).

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

@cyyever cyyever deleted the const_cast2 branch November 3, 2025 23:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/inductor ciflow/trunk Trigger trunk jobs on your pull request Merged module: cpu CPU specific problem (e.g., perf, algorithm) open source Stale topic: not user facing topic category triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants