Skip to content

[BE] Remove erroneous const_cast#168165

Closed
malfet wants to merge 1 commit intogh/malfet/609/basefrom
gh/malfet/609/head
Closed

[BE] Remove erroneous const_cast#168165
malfet wants to merge 1 commit intogh/malfet/609/basefrom
gh/malfet/609/head

Conversation

@malfet
Copy link
Contributor

@malfet malfet commented Nov 19, 2025

Stack from ghstack (oldest at bottom):

Not sure what was the purpose of using TensorBase::const_data_ptr template, but 1st argument of memcpy should be a mutable pointer, therefore replacing it with TensorBase::data_ptr

Introduced in #134712

[ghstack-poisoned]
@pytorch-bot
Copy link

pytorch-bot bot commented Nov 19, 2025

🔗 Helpful Links

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

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

⏳ No Failures, 27 Pending

As of commit 9947627 with merge base 1c0bf2a (image):
💚 Looks good so far! There are no failures yet. 💚

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

@malfet malfet added the ciflow/trunk Trigger trunk jobs on your pull request label Nov 19, 2025
@malfet
Copy link
Contributor Author

malfet commented Nov 19, 2025

@pytorchbot merge -f "Lint + some builds are green, otherwise it's a no-op"

@pytorchmergebot
Copy link
Collaborator

Merge started

Your change will be merged immediately since you used the force (-f) flag, bypassing any CI checks (ETA: 1-5 minutes). Please use -f as last resort and instead consider -i/--ignore-current to continue the merge ignoring current failures. This will allow currently pending tests to finish and report signal before the merge.

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

pytorchmergebot pushed a commit that referenced this pull request Nov 21, 2025
Inspired by #168165

1st argument of memcpy should be a mutable pointer, therefore replacing it with TensorBase::mutable_data_ptr

Pull Request resolved: #168233
Approved by: https://github.com/cyyever, https://github.com/Skylion007
pytorchmergebot pushed a commit that referenced this pull request Nov 21, 2025
Resolve some dependent name disambiguation issues, which results in compilation errors when compiled with MSVC using C++20 standard. Failure look something like the following
```
C:\actions-runner\_work\pytorch\pytorch\aten\src\ATen\native\cuda\Nonzero.cu(215): error: type name is not allowed
        (void*)pinned_num_nonzeros_h.const_data_ptr<int>(),
                                                    ^

C:\actions-runner\_work\pytorch\pytorch\aten\src\ATen\native\cuda\Nonzero.cu(215): error: expected an expression
        (void*)pinned_num_nonzeros_h.const_data_ptr<int>(),
                                                         ^
```
And resolved by adding a `template` in front of it

The only C++20 specific change in the [standard](https://en.cppreference.com/w/cpp/language/dependent_name.html) that I can spot are the following:
> The following expressions are type-dependent :
> - an expression whose any subexpression is a type-dependent expression this, if the class is a dependent type.
> - an [identifier expression](https://en.cppreference.com/w/cpp/language/name.html) that is not a [concept-id](https://en.cppreference.com/w/cpp/language/constraints.html) and(since C++20)
> - contains an identifier for which name lookup finds at least one dependent declaration
> - contains a dependent [template-id](https://en.cppreference.com/w/cpp/language/templates.html#template-id)

Also replace `*((int*)ptr + offs)` with `static_cast<int *>(ptr)[offs]`
Pull Request resolved: #168132
Approved by: https://github.com/ngimel, https://github.com/Skylion007, https://github.com/cyyever
ghstack dependencies: #168165
JacobSzwejbka pushed a commit that referenced this pull request Dec 8, 2025
Inspired by #168165

1st argument of memcpy should be a mutable pointer, therefore replacing it with TensorBase::mutable_data_ptr

Pull Request resolved: #168233
Approved by: https://github.com/cyyever, https://github.com/Skylion007
JacobSzwejbka pushed a commit that referenced this pull request Dec 8, 2025
Resolve some dependent name disambiguation issues, which results in compilation errors when compiled with MSVC using C++20 standard. Failure look something like the following
```
C:\actions-runner\_work\pytorch\pytorch\aten\src\ATen\native\cuda\Nonzero.cu(215): error: type name is not allowed
        (void*)pinned_num_nonzeros_h.const_data_ptr<int>(),
                                                    ^

C:\actions-runner\_work\pytorch\pytorch\aten\src\ATen\native\cuda\Nonzero.cu(215): error: expected an expression
        (void*)pinned_num_nonzeros_h.const_data_ptr<int>(),
                                                         ^
```
And resolved by adding a `template` in front of it

The only C++20 specific change in the [standard](https://en.cppreference.com/w/cpp/language/dependent_name.html) that I can spot are the following:
> The following expressions are type-dependent :
> - an expression whose any subexpression is a type-dependent expression this, if the class is a dependent type.
> - an [identifier expression](https://en.cppreference.com/w/cpp/language/name.html) that is not a [concept-id](https://en.cppreference.com/w/cpp/language/constraints.html) and(since C++20)
> - contains an identifier for which name lookup finds at least one dependent declaration
> - contains a dependent [template-id](https://en.cppreference.com/w/cpp/language/templates.html#template-id)

Also replace `*((int*)ptr + offs)` with `static_cast<int *>(ptr)[offs]`
Pull Request resolved: #168132
Approved by: https://github.com/ngimel, https://github.com/Skylion007, https://github.com/cyyever
ghstack dependencies: #168165
tiendatngcs pushed a commit to tiendatngcs/pytorch-Dec25 that referenced this pull request Dec 10, 2025
Not sure what was the purpose of using `TensorBase::const_data_ptr` template, but 1st argument of `memcpy` should be a mutable pointer, therefore replacing it with `TensorBase::data_ptr`

Introduced in pytorch/pytorch#134712


ghstack-source-id: 7b660d2
Pull-Request: pytorch/pytorch#168165
@github-actions github-actions bot deleted the gh/malfet/609/head branch December 20, 2025 02:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/trunk Trigger trunk jobs on your pull request Merged release notes: cuda release notes category topic: bug fixes topic category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants