[BE] Remove erroneous const_cast#168165
Conversation
🔗 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 PendingAs of commit 9947627 with merge base 1c0bf2a ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
|
@pytorchbot merge -f "Lint + some builds are green, otherwise it's a no-op" |
Merge startedYour change will be merged immediately since you used the force (-f) flag, bypassing any CI checks (ETA: 1-5 minutes). Please use Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
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
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
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
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
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
Stack from ghstack (oldest at bottom):
const_cast#168165Not sure what was the purpose of using
TensorBase::const_data_ptrtemplate, but 1st argument ofmemcpyshould be a mutable pointer, therefore replacing it withTensorBase::data_ptrIntroduced in #134712